diff options
author | Daniele Nicolodi <daniele@grinta.net> | 2018-06-12 19:47:20 -0600 |
---|---|---|
committer | Daniele Nicolodi <daniele@grinta.net> | 2018-10-14 01:35:49 -0600 |
commit | 9076fc79b27a7b7aa5f8a1e3b1e0f54a781aefba (patch) | |
tree | b4b9481fdd95cdc2129267a350874e450ee6ec0a /autoscripts | |
parent | a69dfe2854a4ba25008fb4d17db561ad33034b8d (diff) | |
download | debhelper-9076fc79b27a7b7aa5f8a1e3b1e0f54a781aefba.tar.gz |
dh_installsystemduser: New helper to handle systemd user instance units
Add a new 'dh_installsystemduser' helper responsible for istalling
package maintainer supplied systemd user instance units and to produce
postinst and postrm maintiner scripts code blocks to appropriately
enable, mask and disable units when the package is installed,
upgraded, or removed.
Diffstat (limited to 'autoscripts')
-rw-r--r-- | autoscripts/postinst-systemd-user-dont-enable | 15 | ||||
-rw-r--r-- | autoscripts/postinst-systemd-user-enable | 15 | ||||
-rw-r--r-- | autoscripts/postrm-systemd-user | 12 |
3 files changed, 42 insertions, 0 deletions
diff --git a/autoscripts/postinst-systemd-user-dont-enable b/autoscripts/postinst-systemd-user-dont-enable new file mode 100644 index 00000000..0837257f --- /dev/null +++ b/autoscripts/postinst-systemd-user-dont-enable @@ -0,0 +1,15 @@ +if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then + if deb-systemd-helper --user debian-installed #UNITFILE# ; then + # This will only remove masks created by d-s-h on package removal. + deb-systemd-helper --user unmask #UNITFILE# >/dev/null || true + + if deb-systemd-helper --quiet --user was-enabled #UNITFILE# ; then + # Create new symlinks, if any. + deb-systemd-helper --user 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 --user update-state #UNITFILE# >/dev/null || true +fi diff --git a/autoscripts/postinst-systemd-user-enable b/autoscripts/postinst-systemd-user-enable new file mode 100644 index 00000000..b16f61fb --- /dev/null +++ b/autoscripts/postinst-systemd-user-enable @@ -0,0 +1,15 @@ +if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then + # This will only remove masks created by d-s-h on package removal. + deb-systemd-helper --user unmask #UNITFILE# >/dev/null || true + + # was-enabled defaults to true, so new installations run enable. + if deb-systemd-helper --quiet --user was-enabled #UNITFILE# ; then + # Enables the unit on first installation, creates new + # symlinks on upgrades if the unit file has changed. + deb-systemd-helper --user 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 --user update-state #UNITFILE# >/dev/null || true + fi +fi diff --git a/autoscripts/postrm-systemd-user b/autoscripts/postrm-systemd-user new file mode 100644 index 00000000..bf48d1a3 --- /dev/null +++ b/autoscripts/postrm-systemd-user @@ -0,0 +1,12 @@ +if [ "$1" = "remove" ]; then + if [ -x "/usr/bin/deb-systemd-helper" ] ; then + deb-systemd-helper --user mask #UNITFILES# >/dev/null || true + fi +fi + +if [ "$1" = "purge" ]; then + if [ -x "/usr/bin/deb-systemd-helper" ] ; then + deb-systemd-helper --user purge #UNITFILES# >/dev/null || true + deb-systemd-helper --user unmask #UNITFILES# >/dev/null || true + fi +fi |