2014-10-31 06:59:20 +01:00
|
|
|
#!/bin/bash
|
|
|
|
# postinst script for core-agent-linux
|
|
|
|
#
|
|
|
|
# see: dh_installdeb(1)
|
|
|
|
|
2014-11-07 06:09:54 +01:00
|
|
|
set -e
|
2014-10-31 06:59:20 +01:00
|
|
|
|
2015-09-20 06:01:57 +02:00
|
|
|
# The postinst script may be called in the following ways:
|
2014-10-31 06:59:20 +01:00
|
|
|
# * <postinst> 'configure' <most-recently-configured-version>
|
|
|
|
# * <old-postinst> 'abort-upgrade' <new version>
|
|
|
|
# * <conflictor's-postinst> 'abort-remove' 'in-favour' <package>
|
|
|
|
# <new-version>
|
|
|
|
# * <postinst> 'abort-remove'
|
|
|
|
# * <deconfigured's-postinst> 'abort-deconfigure' 'in-favour'
|
|
|
|
# <failed-install-package> <version> 'removing'
|
|
|
|
# <conflicting-package> <version>
|
|
|
|
#
|
|
|
|
# For details, see http://www.debian.org/doc/debian-policy/ or
|
|
|
|
# https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html or
|
|
|
|
# the debian-policy package
|
|
|
|
|
2014-11-09 18:58:57 +01:00
|
|
|
|
2015-08-02 23:30:26 +02:00
|
|
|
debug() {
|
|
|
|
if [ "${DEBDEBUG}" == "1" ]; then
|
|
|
|
echo -e ""$@""
|
2014-11-09 18:58:57 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-07-24 11:02:56 +02:00
|
|
|
systemdPreload() {
|
|
|
|
# Debian systemd helper does not yet honour preset, therefore use
|
|
|
|
# systemctl preset on each unit file (not using preset-all either since
|
|
|
|
# wheezy does not support it) listed in 75-qubes-vm.preset.
|
2015-04-22 08:04:10 +02:00
|
|
|
|
2015-07-24 11:02:56 +02:00
|
|
|
systemctl --no-reload preset-all > /dev/null 2>&1 && PRESET_FAILED=0 || PRESET_FAILED=1
|
|
|
|
|
|
|
|
# Mask any static unit files that are marked to be disabled
|
|
|
|
grep '^[[:space:]]*[^#;]' /lib/systemd/system-preset/75-qubes-vm.preset | while read action unit_name; do
|
|
|
|
case "${action}" in
|
|
|
|
disable)
|
|
|
|
if [ -e "/lib/systemd/system/${unit_name}" ]; then
|
|
|
|
if ! fgrep -q '[Install]' "/lib/systemd/system/${unit_name}"; then
|
|
|
|
deb-systemd-helper mask "${unit_name}" > /dev/null 2>&1 || true
|
2015-04-22 08:04:10 +02:00
|
|
|
fi
|
2014-10-31 06:59:20 +01:00
|
|
|
fi
|
2015-04-22 08:04:10 +02:00
|
|
|
;;
|
2015-07-24 11:02:56 +02:00
|
|
|
*)
|
|
|
|
# preset-all is not available in wheezy; so preset each unit file listed in 75-qubes-vm.preset
|
|
|
|
if [ "${PRESET_FAILED}" -eq 1 ]; then
|
|
|
|
systemctl --no-reload preset "${unit_name}" > /dev/null 2>&1 || true
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
2015-04-22 08:04:10 +02:00
|
|
|
done
|
|
|
|
|
2015-07-24 11:02:56 +02:00
|
|
|
systemctl daemon-reload
|
2014-11-08 00:28:04 +01:00
|
|
|
}
|
|
|
|
|
2015-08-02 23:30:26 +02:00
|
|
|
installSerialConf() {
|
|
|
|
debug "Installing over-ridden serial.conf init script..."
|
|
|
|
if [ -e /etc/init/serial.conf ]; then
|
|
|
|
cp /usr/share/qubes/serial.conf /etc/init/serial.conf
|
|
|
|
fi
|
|
|
|
}
|
2014-11-08 00:28:04 +01:00
|
|
|
|
|
|
|
case "${1}" in
|
|
|
|
configure)
|
2015-08-02 23:30:26 +02:00
|
|
|
# Initial installation of package only
|
|
|
|
# ($2 contains version number on update; nothing on initial installation)
|
|
|
|
if [ -z "${2}" ]; then
|
|
|
|
|
|
|
|
debug "FIRST INSTALL..."
|
2015-11-28 17:00:36 +01:00
|
|
|
# Create NetworkManager configuration if we do not have it
|
|
|
|
if ! [ -e /etc/NetworkManager/NetworkManager.conf ]; then
|
|
|
|
echo '[main]' > /etc/NetworkManager/NetworkManager.conf
|
|
|
|
echo 'plugins = keyfile' >> /etc/NetworkManager/NetworkManager.conf
|
|
|
|
echo '[keyfile]' >> /etc/NetworkManager/NetworkManager.conf
|
|
|
|
fi
|
|
|
|
/usr/lib/qubes/qubes-fix-nm-conf.sh
|
|
|
|
|
2015-08-02 23:30:26 +02:00
|
|
|
# Location of files which contains list of protected files
|
2016-10-22 17:43:16 +02:00
|
|
|
. /usr/lib/qubes/init/functions
|
2015-08-02 23:30:26 +02:00
|
|
|
|
|
|
|
# ensure that hostname resolves to 127.0.1.1 resp. ::1 and that /etc/hosts is
|
|
|
|
# in the form expected by qubes-sysinit.sh
|
2016-10-22 17:43:16 +02:00
|
|
|
if ! is_protected_file /etc/hostname ; then
|
2015-08-02 23:30:26 +02:00
|
|
|
for ip in '127\.0\.1\.1' '::1'; do
|
|
|
|
if grep -q "^${ip}\(\s\|$\)" /etc/hosts; then
|
|
|
|
sed -i "/^${ip}\s/,+0s/\(\s`hostname`\)\+\(\s\|$\)/\2/g" /etc/hosts || true
|
|
|
|
sed -i "s/^${ip}\(\s\|$\).*$/\0 `hostname`/" /etc/hosts || true
|
|
|
|
else
|
|
|
|
echo "${ip//\\/} `hostname`" >> /etc/hosts || true
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
# remove hostname from 127.0.0.1 line (in debian the hostname is by default
|
|
|
|
# resolved to 127.0.1.1)
|
2016-10-22 17:43:16 +02:00
|
|
|
if ! is_protected_file /etc/hosts ; then
|
2015-08-02 23:30:26 +02:00
|
|
|
sed -i "/^127\.0\.0\.1\s/,+0s/\(\s`hostname`\)\+\(\s\|$\)/\2/g" /etc/hosts || true
|
|
|
|
fi
|
|
|
|
|
|
|
|
chown user:user /home_volatile/user
|
|
|
|
|
|
|
|
# Set default "runlevel"
|
|
|
|
rm -f /etc/systemd/system/default.target
|
|
|
|
ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
|
|
|
|
|
|
|
|
# Systemd preload-all
|
|
|
|
systemdPreload
|
|
|
|
|
2015-10-15 04:34:55 +02:00
|
|
|
# Maybe install overridden serial.conf init script
|
2015-08-02 23:30:26 +02:00
|
|
|
installSerialConf
|
|
|
|
fi
|
|
|
|
|
|
|
|
debug "UPDATE..."
|
2014-11-08 00:28:04 +01:00
|
|
|
# disable some Upstart services
|
|
|
|
for init in plymouth-shutdown \
|
|
|
|
prefdm \
|
|
|
|
splash-manager \
|
|
|
|
start-ttys \
|
|
|
|
tty ; do
|
2015-01-24 22:41:05 +01:00
|
|
|
dpkg-divert --divert /etc/init/${init}.conf.qubes-disabled --package qubes-core-agent --rename --add /etc/init/${init}.conf
|
2014-11-08 00:28:04 +01:00
|
|
|
done
|
2015-07-24 11:02:56 +02:00
|
|
|
dpkg-divert --divert /etc/init/serial.conf.qubes-orig --package qubes-core-agent --rename --add /etc/init/serial.conf
|
2015-04-22 08:04:10 +02:00
|
|
|
|
2014-10-31 06:59:20 +01:00
|
|
|
# Remove old firmware updates link
|
|
|
|
if [ -L /lib/firmware/updates ]; then
|
2014-11-08 00:28:04 +01:00
|
|
|
rm -f /lib/firmware/updates
|
2014-10-31 06:59:20 +01:00
|
|
|
fi
|
|
|
|
|
2016-07-25 13:51:20 +02:00
|
|
|
# remove old symlinks
|
|
|
|
if [ -L /etc/systemd/system/sysinit.target.wants/qubes-random-seed.service ]; then
|
2016-07-28 19:13:30 +02:00
|
|
|
rm /etc/systemd/system/sysinit.target.wants/qubes-random-seed.service
|
2016-07-25 13:51:20 +02:00
|
|
|
fi
|
2016-07-28 19:08:09 +02:00
|
|
|
if [ -L /etc/systemd/system/multi-user.target.wants/qubes-mount-home.service ]; then
|
2016-07-28 19:13:30 +02:00
|
|
|
rm /etc/systemd/system/multi-user.target.wants/qubes-mount-home.service
|
2016-07-25 13:51:20 +02:00
|
|
|
fi
|
|
|
|
|
2015-07-18 15:05:15 +02:00
|
|
|
if ! dpkg-statoverride --list /var/lib/qubes/dom0-updates >/dev/null 2>&1; then
|
|
|
|
dpkg-statoverride --update --add user user 775 /var/lib/qubes/dom0-updates
|
|
|
|
fi
|
|
|
|
|
2015-10-06 19:13:52 +02:00
|
|
|
# Update Qubes App Menus
|
2015-08-02 23:30:26 +02:00
|
|
|
/usr/lib/qubes/qubes-trigger-sync-appmenus.sh || true
|
2014-10-31 06:59:20 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
abort-upgrade|abort-remove|abort-deconfigure)
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
2014-11-05 04:37:34 +01:00
|
|
|
triggered)
|
2014-11-08 00:28:04 +01:00
|
|
|
for trigger in ${2}; do
|
|
|
|
case "${trigger}" in
|
|
|
|
|
2014-11-07 06:09:54 +01:00
|
|
|
/usr/share/applications)
|
2015-08-02 23:30:26 +02:00
|
|
|
debug "Updating Qubes App Menus..."
|
2014-11-08 00:28:04 +01:00
|
|
|
/usr/lib/qubes/qubes-trigger-sync-appmenus.sh || true
|
|
|
|
;;
|
|
|
|
|
2015-10-15 04:34:55 +02:00
|
|
|
# Install overridden serial.conf init script
|
2014-11-08 00:28:04 +01:00
|
|
|
/etc/init/serial.conf)
|
2015-08-02 23:30:26 +02:00
|
|
|
installSerialConf
|
2014-11-08 00:28:04 +01:00
|
|
|
;;
|
|
|
|
|
2014-11-07 06:09:54 +01:00
|
|
|
esac
|
|
|
|
done
|
2015-07-24 11:02:56 +02:00
|
|
|
exit 0
|
2014-11-05 04:37:34 +01:00
|
|
|
;;
|
|
|
|
|
2014-10-31 06:59:20 +01:00
|
|
|
*)
|
2014-11-08 00:28:04 +01:00
|
|
|
echo "postinst called with unknown argument \`${1}'" >&2
|
2014-10-31 06:59:20 +01:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# dh_installdeb will replace this with shell code automatically
|
|
|
|
# generated by other debhelper scripts.
|
|
|
|
|
|
|
|
#DEBHELPER#
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|
|
|
|
# vim: set ts=4 sw=4 sts=4 et :
|