From aad80361fb5c320c9c7aab530029d16725b0f76e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Tue, 13 Mar 2018 10:46:37 +0100 Subject: [PATCH] postinst: refactor service/timer handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit reduce code duplication, and reload-or-restart timers just like service units instead of just starting them. Signed-off-by: Fabian Grünbichler --- debian/postinst | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/debian/postinst b/debian/postinst index 685f3c28..ebce2536 100755 --- a/debian/postinst +++ b/debian/postinst @@ -54,43 +54,28 @@ case "$1" in # same as dh_systemd_enable (code copied) - for timer in pvesr pve-daily-update; do - deb-systemd-helper unmask $timer.timer >/dev/null || true + UNITS="pvedaemon.service pveproxy.service spiceproxy.service pvestatd.service pvebanner.service pvesr.timer pve-daily-update.timer" + NO_RESTART_UNITS="pvenetcommit.service pve-guests.service" + + for unit in ${UNITS} ${NO_RESTART_UNITS}; do + deb-systemd-helper unmask "$unit" >/dev/null || true # was-enabled defaults to true, so new installations run enable. - if deb-systemd-helper --quiet was-enabled $timer.timer; then + if deb-systemd-helper --quiet was-enabled "$unit"; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. - deb-systemd-helper enable $timer.timer >/dev/null || true + deb-systemd-helper enable "$unit" >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. - deb-systemd-helper update-state $timer.timer >/dev/null || true - fi - done - - for service in pvedaemon pveproxy spiceproxy pvestatd pvebanner pvenetcommit pve-guests; do - deb-systemd-helper unmask $service.service >/dev/null || true - - # was-enabled defaults to true, so new installations run enable. - if deb-systemd-helper --quiet was-enabled $service.service; then - # Enables the unit on first installation, creates new - # symlinks on upgrades if the unit file has changed. - deb-systemd-helper enable $service.service >/dev/null || true - else - # Update the statefile to add new symlinks (if any), which need to be - # cleaned up on purge. Also remove old symlinks. - deb-systemd-helper update-state $service.service >/dev/null || true + deb-systemd-helper update-state "$unit" >/dev/null || true fi done if test ! -e /proxmox_install_mode; then - - for service in pvedaemon pveproxy spiceproxy pvestatd; do - deb-systemd-invoke reload-or-restart $service + for unit in ${UNITS}; do + deb-systemd-invoke reload-or-restart "$unit" done - - deb-systemd-invoke start pvesr.timer pve-daily-update.timer >/dev/null || true fi if test -z "$2"; then