Properly handle systemd start/stop during Debian package install, closes #30
parent
07a1fe3acb
commit
6fbbb0c7b5
|
@ -53,6 +53,8 @@ nfpms:
|
||||||
- src: config/ntfy.service
|
- src: config/ntfy.service
|
||||||
dst: /lib/systemd/system/ntfy.service
|
dst: /lib/systemd/system/ntfy.service
|
||||||
scripts:
|
scripts:
|
||||||
|
postinstall: "scripts/postinst.sh"
|
||||||
|
preremove: "scripts/prerm.sh"
|
||||||
postremove: "scripts/postrm.sh"
|
postremove: "scripts/postrm.sh"
|
||||||
archives:
|
archives:
|
||||||
-
|
-
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Restart systemd service if it was already running. Note that "deb-systemd-invoke try-restart" will
|
||||||
|
# only act if the service is already running. If it's not running, it's a no-op.
|
||||||
|
#
|
||||||
|
# TODO: This is only tested on Debian.
|
||||||
|
#
|
||||||
|
if [ "$1" = "configure" ] && [ -d /run/systemd/system ]; then
|
||||||
|
systemctl --system daemon-reload >/dev/null || true
|
||||||
|
if systemctl is-active -q ntfy.service; then
|
||||||
|
echo "Restarting ntfy.service ..."
|
||||||
|
if [ -x /usr/bin/deb-systemd-invoke ]; then
|
||||||
|
deb-systemd-invoke try-restart ntfy.service >/dev/null || true
|
||||||
|
else
|
||||||
|
systemctl restart ntfy.service >/dev/null || true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -e
|
||||||
systemctl stop ntfy >/dev/null 2>&1 || true
|
|
||||||
|
# Delete the config if package is purged
|
||||||
if [ "$1" = "purge" ]; then
|
if [ "$1" = "purge" ]; then
|
||||||
rm -rf /etc/ntfy
|
echo "Deleting /etc/ntfy ..."
|
||||||
|
rm -rf /etc/ntfy || true
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Stop systemd service
|
||||||
|
if [ -d /run/systemd/system ] && [ "$1" = remove ]; then
|
||||||
|
echo "Stopping ntfy.service ..."
|
||||||
|
if [ -x /usr/bin/deb-systemd-invoke ]; then
|
||||||
|
deb-systemd-invoke stop 'ntfy.service' >/dev/null || true
|
||||||
|
else
|
||||||
|
systemctl stop ntfy >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
fi
|
Loading…
Reference in New Issue