From 52d502bce27dbebe784d87a0871f3f34e43fe948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 30 Mar 2015 21:43:59 +0200 Subject: [PATCH] debian: fix handling SysV units in disableSystemdUnits systemctl is-enabled always reports "disabled" for them (actually not a real "disabled", but and error, but exit code is the same). So simply always disable the unit, it is no-op for already disabled ones. BTW systemctl preset also do not work for them. --- debian/qubes-core-agent.postinst | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/debian/qubes-core-agent.postinst b/debian/qubes-core-agent.postinst index a891ae9..e311730 100755 --- a/debian/qubes-core-agent.postinst +++ b/debian/qubes-core-agent.postinst @@ -149,25 +149,20 @@ displayFailedStatus() { # Disable systemd units disableSystemdUnits() { for unit in $*; do - systemctl is-enabled ${unit} > /dev/null 2>&1 && { - echo "Disabling ${unit}..." - systemctl is-active ${unit} > /dev/null 2>&1 && { - systemctl stop ${unit} > /dev/null 2>&1 || displayFailedStatus stop ${unit} - } - if [ -f /lib/systemd/system/${unit} ]; then - if fgrep -q '[Install]' /lib/systemd/system/${unit}; then - systemctl disable ${unit} > /dev/null 2>&1 || displayFailedStatus disable ${unit} - else - echo "Masking service: ${unit}" - systemctl mask ${unit} - fi - else - systemctl disable ${unit} > /dev/null 2>&1 || displayFailedStatus disable ${unit} - fi - } || { - echo "It appears ${unit} is already disabled!" - #displayFailedStatus is-disabled ${unit} + echo "Disabling ${unit}..." + systemctl is-active ${unit} > /dev/null 2>&1 && { + systemctl stop ${unit} > /dev/null 2>&1 || displayFailedStatus stop ${unit} } + if [ -f /lib/systemd/system/${unit} ]; then + if fgrep -q '[Install]' /lib/systemd/system/${unit}; then + systemctl disable ${unit} > /dev/null 2>&1 || displayFailedStatus disable ${unit} + else + echo "Masking service: ${unit}" + systemctl mask ${unit} + fi + else + systemctl disable ${unit} > /dev/null 2>&1 || displayFailedStatus disable ${unit} + fi done }