[pve-devel] [RFC manager 15/15] postinst: use autogenerated DEBHELPER parts for systemd stuff

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Jan 24 14:12:40 CET 2018


Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 debian/postinst | 45 ++-------------------------------------------
 debian/postrm   | 34 +---------------------------------
 debian/rules    |  7 ++++++-
 3 files changed, 9 insertions(+), 77 deletions(-)

diff --git a/debian/postinst b/debian/postinst
index 42e0f085..11762027 100755
--- a/debian/postinst
+++ b/debian/postinst
@@ -49,49 +49,6 @@ case "$1" in
 	echo '|/usr/bin/pvemailforward' >/root/.forward
     fi
 
-    systemctl --system daemon-reload >/dev/null || true
-
-    # same as dh_systemd_enable (code copied)
-
-    for timer in pvesr; do
-	deb-systemd-helper unmask $timer.timer >/dev/null || true
-
-	# was-enabled defaults to true, so new installations run enable.
-	if deb-systemd-helper --quiet was-enabled $timer.timer; 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
-	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
-	fi
-    done
-
-    if test ! -e /proxmox_install_mode; then
-
-	for service in pvedaemon pveproxy spiceproxy pvestatd; do
-	    deb-systemd-invoke reload-or-restart $service
-	done
-
-	deb-systemd-invoke start pvesr.timer >/dev/null || true
-    fi
-
     if test -z "$2"; then
       : # no old version, nothing to do
     else
@@ -111,4 +68,6 @@ case "$1" in
      exit 0;;
 esac
 
+#DEBHELPER#
+
 exit 0
diff --git a/debian/postrm b/debian/postrm
index 5cc18ca4..e4d53294 100755
--- a/debian/postrm
+++ b/debian/postrm
@@ -19,36 +19,4 @@ case "$1" in
     ;;
 esac
 
-# same as dh_systemd_enable (code copied)
-systemctl --system daemon-reload >/dev/null || true
-
-PVESERVICES="pvedaemon pveproxy spiceproxy pvestatd pvebanner pvenetcommit pve-guests"
-PVETIMERS="pvesr"
-
-if [ "$1" = "remove" ]; then
-    for timer in ${PVETIMERS}; do
-	if [ -x "/usr/bin/deb-systemd-helper" ]; then
-	    deb-systemd-helper mask $timer.timer >/dev/null
-	fi
-    done
-    for service in ${PVESERVICES}; do
-	if [ -x "/usr/bin/deb-systemd-helper" ]; then
-	    deb-systemd-helper mask $service.service >/dev/null
-	fi
-    done
-fi
-
-if [ "$1" = purge ]; then
-    for timer in ${PVETIMERS}; do
-	if [ -x "/usr/bin/deb-systemd-helper" ]; then
-	    deb-systemd-helper purge $timer.timer >/dev/null
-	    deb-systemd-helper unmask $timer.timer >/dev/null
-	fi
-    done
-    for service in ${PVESERVICES}; do
-	if [ -x "/usr/bin/deb-systemd-helper" ]; then
-	    deb-systemd-helper purge $service.service >/dev/null
-	    deb-systemd-helper unmask $service.service >/dev/null
-	fi
-    done
-fi
+#DEBHELPER#
diff --git a/debian/rules b/debian/rules
index f2c2cb77..188f216b 100755
--- a/debian/rules
+++ b/debian/rules
@@ -10,4 +10,9 @@ override_dh_fixperms:
 	dh_fixperms -Xpvemailforward -Xvar/log/pveproxy
 
 %:
-	dh $@
+	dh $@ --with=systemd
+
+override_dh_systemd_start:
+	dh_systemd_start pve-daily-update.timer pvesr.timer
+	dh_systemd_start pvedaemon pveproxy spiceproxy pvestatd
+	dh_systemd_start --remaining-packages
-- 
2.14.2





More information about the pve-devel mailing list