archlinux: update installer script to use systemd preset file
This commit is contained in:
parent
9890ed191a
commit
8584290295
@ -1,3 +1,4 @@
|
|||||||
|
qubes_preset_file="75-qubes-vm.preset"
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
## Pre-Install functions ##
|
## Pre-Install functions ##
|
||||||
@ -101,6 +102,8 @@ update_qubesconfig() {
|
|||||||
# echo '# Yum does not support inclusion of config dir...' >> /etc/yum.conf
|
# echo '# Yum does not support inclusion of config dir...' >> /etc/yum.conf
|
||||||
# echo 'include=file:///etc/yum.conf.d/qubes-proxy.conf' >> /etc/yum.conf
|
# echo 'include=file:///etc/yum.conf.d/qubes-proxy.conf' >> /etc/yum.conf
|
||||||
#fi
|
#fi
|
||||||
|
#/usr/lib/qubes/update-proxy-configs
|
||||||
|
# Archlinux pacman configuration is handled in update_finalize
|
||||||
|
|
||||||
# Location of files which contains list of protected files
|
# Location of files which contains list of protected files
|
||||||
mkdir -p /etc/qubes/protected-files.d
|
mkdir -p /etc/qubes/protected-files.d
|
||||||
@ -146,58 +149,135 @@ EOF
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
############################
|
||||||
|
## Service Management Functions ##
|
||||||
|
############################
|
||||||
|
is_masked() {
|
||||||
|
if [ ! -L /etc/systemd/system/"$1" ]
|
||||||
|
then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
target=`readlink /etc/systemd/system/"$1" 2>/dev/null` || :
|
||||||
|
if [ "$target" = "/dev/null" ]
|
||||||
|
then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
mask() {
|
||||||
|
ln -sf /dev/null /etc/systemd/system/"$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
unmask() {
|
||||||
|
if ! is_masked "$1"
|
||||||
|
then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
rm -f /etc/systemd/system/"$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
preset_units() {
|
||||||
|
local represet=
|
||||||
|
cat "$1" | while read action unit_name
|
||||||
|
do
|
||||||
|
if [ "$action" = "#" -a "$unit_name" = "Units below this line will be re-preset on package upgrade" ]
|
||||||
|
then
|
||||||
|
represet=1
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo "$action $unit_name" | grep -q '^[[:space:]]*[^#;]' || continue
|
||||||
|
[ -n "$action" -a -n "$unit_name" ] || continue
|
||||||
|
if [ "$2" = "initial" -o "$represet" = "1" ]
|
||||||
|
then
|
||||||
|
if [ "$action" = "disable" ] && is_static "$unit_name"
|
||||||
|
then
|
||||||
|
if ! is_masked "$unit_name"
|
||||||
|
then
|
||||||
|
# We must effectively mask these units, even if they are static.
|
||||||
|
mask "$unit_name"
|
||||||
|
fi
|
||||||
|
elif [ "$action" = "enable" ] && is_static "$unit_name"
|
||||||
|
then
|
||||||
|
if is_masked "$unit_name"
|
||||||
|
then
|
||||||
|
# We masked this static unit before, now we unmask it.
|
||||||
|
unmask "$unit_name"
|
||||||
|
fi
|
||||||
|
systemctl --no-reload preset "$unit_name" >/dev/null 2>&1 || :
|
||||||
|
else
|
||||||
|
systemctl --no-reload preset "$unit_name" >/dev/null 2>&1 || :
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
restore_units() {
|
||||||
|
grep '^[[:space:]]*[^#;]' "$1" | while read action unit_name
|
||||||
|
do
|
||||||
|
if is_static "$unit_name" && is_masked "$unit_name"
|
||||||
|
then
|
||||||
|
# If the unit had been masked by us, we must unmask it here.
|
||||||
|
# Otherwise systemctl preset will fail badly.
|
||||||
|
unmask "$unit_name"
|
||||||
|
fi
|
||||||
|
systemctl --no-reload preset "$unit_name" >/dev/null 2>&1 || :
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
configure_systemd() {
|
configure_systemd() {
|
||||||
|
|
||||||
PRESET_FAILED=0
|
|
||||||
|
|
||||||
if [ $1 -eq 1 ]; then
|
if [ $1 -eq 1 ]; then
|
||||||
# Needs to be started two times to deal with services name changes (systemctl bug?)
|
preset_units /usr/lib/systemd/system-preset/$qubes_preset_file initial
|
||||||
echo "Resetting systemd services to defaults presets (PASS 1)"
|
changed=true
|
||||||
systemctl --no-reload preset-all 2>&1 && PRESET_FAILED=0 || PRESET_FAILED=1
|
|
||||||
echo "Resetting systemd services to defaults presets (PASS 2)"
|
|
||||||
systemctl --no-reload preset-all 2>&1 && PRESET_FAILED=0 || PRESET_FAILED=1
|
|
||||||
else
|
else
|
||||||
services="qubes-dvm qubes-misc-post qubes-firewall qubes-mount-dirs"
|
preset_units /usr/lib/systemd/system-preset/$qubes_preset_file upgrade
|
||||||
services="$services qubes-netwatcher qubes-network qubes-sysinit"
|
changed=true
|
||||||
services="$services qubes-iptables qubes-updates-proxy qubes-qrexec-agent"
|
|
||||||
services="$services qubes-random-seed"
|
|
||||||
for srv in $services; do
|
|
||||||
echo "Enable service defaults for $service"
|
|
||||||
systemctl --no-reload preset $srv.service
|
|
||||||
done
|
|
||||||
systemctl --no-reload preset qubes-update-check.timer
|
|
||||||
# Upgrade path - now qubes-iptables is used instead
|
# Upgrade path - now qubes-iptables is used instead
|
||||||
systemctl --no-reload preset iptables.service
|
for svc in iptables ip6tables
|
||||||
systemctl --no-reload preset ip6tables.service
|
do
|
||||||
|
if [ -f "$svc".service ]
|
||||||
|
then
|
||||||
|
systemctl --no-reload preset "$svc".service
|
||||||
|
changed=true
|
||||||
|
fi
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set default "runlevel"
|
if [ $1 -eq 1 ]; then
|
||||||
rm -f /etc/systemd/system/default.target
|
then
|
||||||
ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
|
# First install.
|
||||||
|
# Set default "runlevel".
|
||||||
|
# FIXME: this ought to be done via kernel command line.
|
||||||
|
# The fewer deviations of the template from the seed
|
||||||
|
# image, the better.
|
||||||
|
rm -f /etc/systemd/system/default.target
|
||||||
|
ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
|
||||||
|
changed=true
|
||||||
|
fi
|
||||||
|
|
||||||
grep '^[[:space:]]*[^#;]' /lib/systemd/system-preset/75-qubes-vm.preset | while read action unit_name; do
|
# remove old symlinks
|
||||||
case "$action" in
|
if [ -L /etc/systemd/system/sysinit.target.wants/qubes-random-seed.service ]
|
||||||
(disable)
|
then
|
||||||
if [ -f /lib/systemd/system/$unit_name ]; then
|
rm -f /etc/systemd/system/sysinit.target.wants/qubes-random-seed.service
|
||||||
if ! fgrep -q '[Install]' /lib/systemd/system/$unit_name; then
|
changed=true
|
||||||
# forcibly disable
|
fi
|
||||||
ln -sf /dev/null /etc/systemd/system/$unit_name
|
if [ -L /etc/systemd/system/multi-user.target.wants/qubes-mount-home.service ]
|
||||||
fi
|
then
|
||||||
fi
|
rm -f /etc/systemd/system/multi-user.target.wants/qubes-mount-home.service
|
||||||
;;
|
changed=true
|
||||||
*)
|
fi
|
||||||
# preset-all is not available in fc20; so preset each unit file listed in 75-qubes-vm.preset
|
|
||||||
if [ $1 -eq 1 -a "${PRESET_FAILED}" -eq 1 ]; then
|
|
||||||
systemctl --no-reload preset "${unit_name}" > /dev/null 2>&1 || true
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
systemctl daemon-reload
|
if [ "x$changed" != "x" ]
|
||||||
|
then
|
||||||
|
systemctl daemon-reload
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
######################
|
||||||
|
## Archlinux Specific Functions ##
|
||||||
|
######################
|
||||||
config_prependtomark() {
|
config_prependtomark() {
|
||||||
FILE=$1
|
FILE=$1
|
||||||
APPENDBEFORELINE=$2
|
APPENDBEFORELINE=$2
|
||||||
@ -244,6 +324,8 @@ update_finalize() {
|
|||||||
# Include /etc/pacman.d drop-in directory
|
# Include /etc/pacman.d drop-in directory
|
||||||
config_appendtomark "/etc/pacman.conf" "$QUBES_MARKER" "Include = /etc/pacman.d/*.conf"
|
config_appendtomark "/etc/pacman.conf" "$QUBES_MARKER" "Include = /etc/pacman.d/*.conf"
|
||||||
|
|
||||||
|
/usr/lib/qubes/update-proxy-configs
|
||||||
|
|
||||||
# Archlinux specific: Update pam.d configuration for su to enable systemd-login wrapper
|
# Archlinux specific: Update pam.d configuration for su to enable systemd-login wrapper
|
||||||
# Also remove pam_unix.so from su configuration
|
# Also remove pam_unix.so from su configuration
|
||||||
# as system-login (which include system-auth) already gives pam_unix.so
|
# as system-login (which include system-auth) already gives pam_unix.so
|
||||||
@ -346,11 +428,37 @@ pre_remove() {
|
|||||||
mv /var/lib/qubes/serial.orig /etc/init/serial.conf
|
mv /var/lib/qubes/serial.orig /etc/init/serial.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ $1 -eq 0 ] ; then
|
||||||
|
# Run this only during uninstall.
|
||||||
|
# Save the preset file to later use it to re-preset services there
|
||||||
|
# once the Qubes OS preset file is removed.
|
||||||
|
mkdir -p /run/qubes-uninstall
|
||||||
|
cp -f /usr/lib/systemd/system-preset/$qubes_preset_file /run/qubes-uninstall/
|
||||||
|
cp -f /usr/lib/systemd/system-preset/$qubes_preset_file /run/qubes-uninstall/
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
## arg 1: the old package version
|
## arg 1: the old package version
|
||||||
post_remove() {
|
post_remove() {
|
||||||
|
|
||||||
|
changed=
|
||||||
|
|
||||||
|
if [ -d /run/qubes-uninstall ]
|
||||||
|
then
|
||||||
|
# We have a saved preset file (or more).
|
||||||
|
# Re-preset the units mentioned there.
|
||||||
|
restore_units /run/qubes-uninstall/$qubes_preset_file
|
||||||
|
rm -rf /run/qubes-uninstall
|
||||||
|
changed=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "x$changed" != "x" ]
|
||||||
|
then
|
||||||
|
systemctl daemon-reload
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ -L /lib/firmware/updates ] ; then
|
if [ -L /lib/firmware/updates ] ; then
|
||||||
rm /lib/firmware/updates
|
rm /lib/firmware/updates
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user