summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoscripts/postinst-systemd-dont-enable15
-rw-r--r--autoscripts/postinst-systemd-enable11
-rwxr-xr-xscript/dh_systemd_enable10
3 files changed, 24 insertions, 12 deletions
diff --git a/autoscripts/postinst-systemd-dont-enable b/autoscripts/postinst-systemd-dont-enable
index 7641052..2bf34ec 100644
--- a/autoscripts/postinst-systemd-dont-enable
+++ b/autoscripts/postinst-systemd-dont-enable
@@ -1,7 +1,10 @@
-if [ -x "/usr/bin/deb-systemd-helper" ]; then
- # This might seem weird at first glance, but the seemingly useless
- # enable/disable is necessary to make deb-systemd-helper create its
- # state file to properly disable the unit files at purge time.
- deb-systemd-helper --quiet enable #UNITFILES# >/dev/null || true
- deb-systemd-helper --quiet disable #UNITFILES# >/dev/null || true
+if deb-systemd-helper debian-is-installed #UNITFILE#; then
+ if deb-systemd-helper was-enabled #UNITFILE#; then
+ # Create new symlinks, if any.
+ deb-systemd-helper enable #UNITFILE# >/dev/null || true
+ fi
fi
+
+# 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 #UNITFILE# >/dev/null || true
diff --git a/autoscripts/postinst-systemd-enable b/autoscripts/postinst-systemd-enable
index 0503034..859b7f4 100644
--- a/autoscripts/postinst-systemd-enable
+++ b/autoscripts/postinst-systemd-enable
@@ -1,3 +1,10 @@
-if [ -x "/usr/bin/deb-systemd-helper" ]; then
- deb-systemd-helper enable #UNITFILES# >/dev/null || true
+# was-enabled defaults to true, so new installations run enable.
+if deb-systemd-helper was-enabled #UNITFILE#; then
+ # Enables the unit on first installation, creates new
+ # symlinks on upgrades if the unit file has changed.
+ deb-systemd-helper enable #UNITFILE# >/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 #UNITFILE# >/dev/null || true
fi
diff --git a/script/dh_systemd_enable b/script/dh_systemd_enable
index 63f2e3d..12c555c 100755
--- a/script/dh_systemd_enable
+++ b/script/dh_systemd_enable
@@ -159,10 +159,12 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
next if @units == 0;
my $unitargs = join(" ", map { basename($_) } @units);
- if ($dh{NO_ENABLE}) {
- autoscript($package, "postinst", "postinst-systemd-dont-enable", "s/#UNITFILES#/$unitargs/");
- } else {
- autoscript($package, "postinst", "postinst-systemd-enable", "s/#UNITFILES#/$unitargs/");
+ for my $unit (@units) {
+ if ($dh{NO_ENABLE}) {
+ autoscript($package, "postinst", "postinst-systemd-dont-enable", "s/#UNITFILE#/$unit/");
+ } else {
+ autoscript($package, "postinst", "postinst-systemd-enable", "s/#UNITFILE#/$unit/");
+ }
}
autoscript($package, "postrm", "postrm-systemd", "s/#UNITFILES#/$unitargs/");