summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Grünbichler <f.gruenbichler@proxmox.com>2018-10-28 15:08:48 +0000
committerNiels Thykier <niels@thykier.net>2018-10-28 15:39:38 +0000
commit9f02cb6fae8a822092ef504f46cbdd0a4f5547c2 (patch)
tree7ebd3ca24c6e32d2cb3237d58a6a0a5c0f2c56cc
parentc4a06ca230ad87da093da8c8cfd68bdb41b0ccdf (diff)
downloaddebhelper-9f02cb6fae8a822092ef504f46cbdd0a4f5547c2.tar.gz
dh_installsystemd: Refactor to suport new maintscripts actions easier
Extracted from MR !14. Signed-off-by: Niels Thykier <niels@thykier.net>
-rw-r--r--autoscripts/postinst-systemd-restart2
-rw-r--r--autoscripts/postinst-systemd-restartnostart2
-rwxr-xr-xdh_installsystemd21
3 files changed, 16 insertions, 9 deletions
diff --git a/autoscripts/postinst-systemd-restart b/autoscripts/postinst-systemd-restart
index 048e9685..8155bc05 100644
--- a/autoscripts/postinst-systemd-restart
+++ b/autoscripts/postinst-systemd-restart
@@ -2,7 +2,7 @@ if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-decon
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
if [ -n "$2" ]; then
- _dh_action=restart
+ _dh_action=#RESTART_ACTION#
else
_dh_action=start
fi
diff --git a/autoscripts/postinst-systemd-restartnostart b/autoscripts/postinst-systemd-restartnostart
index 8ac28fb3..d3f199cf 100644
--- a/autoscripts/postinst-systemd-restartnostart
+++ b/autoscripts/postinst-systemd-restartnostart
@@ -2,7 +2,7 @@ if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-decon
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
if [ -n "$2" ]; then
- deb-systemd-invoke try-restart #UNITFILES# >/dev/null || true
+ deb-systemd-invoke #RESTART_ACTION# #UNITFILES# >/dev/null || true
fi
fi
fi
diff --git a/dh_installsystemd b/dh_installsystemd
index d1ba5708..48a0e787 100755
--- a/dh_installsystemd
+++ b/dh_installsystemd
@@ -389,27 +389,34 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
}
if (@start_units) {
- my $units = { 'UNITFILES' => join(' ', @start_units) };
+ my $replace = { 'UNITFILES' => join(' ', @start_units) };
if ($dh{RESTART_AFTER_UPGRADE}) {
- my $snippet = $dh{NO_START} ? 'postinst-systemd-restartnostart' : 'postinst-systemd-restart';
- autoscript($package, 'postinst', $snippet, $units, \%options);
+ my $snippet;
+ if ($dh{NO_START}) {
+ $snippet = 'postinst-systemd-restartnostart';
+ $replace->{RESTART_ACTION} = 'try-restart';
+ } else {
+ $snippet = 'postinst-systemd-restart';
+ $replace->{RESTART_ACTION} = 'restart';
+ }
+ autoscript($package, 'postinst', $snippet, $replace, \%options);
} elsif (!$dh{NO_START}) {
# (stop|start) service (before|after) upgrade
- autoscript($package, 'postinst', 'postinst-systemd-start', $units, \%options);
+ autoscript($package, 'postinst', 'postinst-systemd-start', $replace, \%options);
}
if ($dh{R_FLAG} || $dh{RESTART_AFTER_UPGRADE}) {
# stop service only on remove
- autoscript($package, 'prerm', 'prerm-systemd-restart', $units, \%options);
+ autoscript($package, 'prerm', 'prerm-systemd-restart', $replace, \%options);
} elsif (!$dh{NO_START}) {
# always stop service
- autoscript($package, 'prerm', 'prerm-systemd', $units, \%options);
+ autoscript($package, 'prerm', 'prerm-systemd', $replace, \%options);
}
# Run this with "default" order so it is always after other
# service related autosnippets.
- autoscript($package, 'postrm', 'postrm-systemd-reload-only', $units);
+ autoscript($package, 'postrm', 'postrm-systemd-reload-only', $replace);
}
}