cloudflare-dns-updater/debian/postinst

37 lines
1.5 KiB
Text
Raw Permalink Normal View History

#!/bin/sh
#DEBHELPER#
# Also enable User Service
# Automatically added by cargo-deb
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
if deb-systemd-helper --user debian-installed cloudflare-dns-updater.service; then
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper --user unmask cloudflare-dns-updater.service >/dev/null || true
if deb-systemd-helper --user --quiet was-enabled cloudflare-dns-updater.service; then
# Create new symlinks, if any.
deb-systemd-helper --user enable cloudflare-dns-updater.service >/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 cloudflare-dns-updater.service >/dev/null || true
fi
# End automatically added section
# Automatically added by cargo-deb
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
if [ -d /run/systemd/system ]; then
USER="$(who | head -1 | awk '{print $1;}')"
runuser -l $USER -c "XDG_RUNTIME_DIR=/run/user/$(id -u $USER) systemctl --user daemon-reload >/dev/null || true"
if [ -n "$2" ]; then
_dh_action=restart
else
_dh_action=start
fi
runuser -l $USER -c "XDG_RUNTIME_DIR=/run/user/$(id -u $USER) deb-systemd-invoke --user $_dh_action cloudflare-dns-updater.service >/dev/null || true"
fi
fi
# End automatically added section