diff --git a/debian/postinst b/debian/postinst new file mode 100755 index 00000000..027d5520 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,25 @@ +#!/bin/sh +set -e +if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then + useradd --user-group -M --system dvmhost --shell /bin/false || true + usermod --groups dialout --append dvmhost || true + chown dvmhost:dvmhost /opt/dvm/config.yml + chown dvmhost:dvmhost /opt/dvm/iden_table.dat + chown dvmhost:dvmhost /opt/dvm/rid_acl.dat + chown dvmhost:dvmhost /opt/dvm/tg_acl.dat + chown dvmhost:dvmhost /opt/dvm/log + + # This will only remove masks created by d-s-h on package removal. + deb-systemd-helper unmask 'dvmhost.service' >/dev/null || true + + # was-enabled defaults to true, so new installations run enable. + if deb-systemd-helper --quiet was-enabled 'dvmhost.service'; then + # Enables the unit on first installation, creates new + # symlinks on upgrades if the unit file has changed. + deb-systemd-helper enable 'dvmhost.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 'dvmhost.service' >/dev/null || true + fi +fi diff --git a/debian/postrm b/debian/postrm new file mode 100755 index 00000000..fa461188 --- /dev/null +++ b/debian/postrm @@ -0,0 +1,20 @@ +#!/bin/sh +set -e +if [ "$1" = "remove" ]; then + userdel dvmhost || true + groupdel dvmhost || true + + if [ -x "/usr/bin/deb-systemd-helper" ]; then + deb-systemd-helper mask 'dvmhost.service' >/dev/null || true + fi +fi + +if [ "$1" = "purge" ]; then + userdel dvmhost || true + groupdel dvmhost || true + + if [ -x "/usr/bin/deb-systemd-helper" ]; then + deb-systemd-helper purge 'dvmhost.service' >/dev/null || true + deb-systemd-helper unmask 'dvmhost.service' >/dev/null || true + fi +fi