diff --git a/.goreleaser.yml b/.goreleaser.yml
index 8a98d0af73cd2a2c0148af1a41569196516bfcc9..ae217ee557d93acdd9c500a42d3991b814f11cbd 100644
--- a/.goreleaser.yml
+++ b/.goreleaser.yml
@@ -53,6 +53,8 @@ nfpms:
       - src: config/ntfy.service
         dst: /lib/systemd/system/ntfy.service
     scripts:
+      postinstall: "scripts/postinst.sh"
+      preremove: "scripts/prerm.sh"
       postremove: "scripts/postrm.sh"
 archives:
   -
diff --git a/scripts/postinst.sh b/scripts/postinst.sh
new file mode 100755
index 0000000000000000000000000000000000000000..0a09edbf5e2cd078e10e8a62ede41a43c5dcd451
--- /dev/null
+++ b/scripts/postinst.sh
@@ -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
diff --git a/scripts/postrm.sh b/scripts/postrm.sh
index 4588bc2770ab0713a24f69ff481081c11702a80d..1eac8a71a155fcc4a82918728057a1deb473b3e9 100755
--- a/scripts/postrm.sh
+++ b/scripts/postrm.sh
@@ -1,6 +1,8 @@
 #!/bin/sh
-set -eu
-systemctl stop ntfy >/dev/null 2>&1 || true
+set -e
+
+# Delete the config if package is purged
 if [ "$1" = "purge" ]; then
-  rm -rf /etc/ntfy
+  echo "Deleting /etc/ntfy ..."
+  rm -rf /etc/ntfy || true
 fi
diff --git a/scripts/prerm.sh b/scripts/prerm.sh
new file mode 100755
index 0000000000000000000000000000000000000000..f3668550c11ed7e5017b8936de756c2756f296a9
--- /dev/null
+++ b/scripts/prerm.sh
@@ -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