Skip to content

Commit 014b561

Browse files
author
Philipp Heckel
committed
Merge branch 'main' of github.com:binwiederhier/ntfy into main
2 parents f397456 + 5ea2751 commit 014b561

File tree

4 files changed

+35
-31
lines changed

4 files changed

+35
-31
lines changed

scripts/postinst.sh

+25-23
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,40 @@ set -e
66
#
77
# TODO: This is only tested on Debian.
88
#
9-
if [ "$1" = "configure" ] && [ -d /run/systemd/system ]; then
10-
# Create ntfy user/group
11-
id ntfy >/dev/null 2>&1 || useradd --system --no-create-home ntfy
12-
chown ntfy.ntfy /var/cache/ntfy
13-
chmod 700 /var/cache/ntfy
9+
if [ "$1" = "configure" ] || [ "$1" -ge 1 ]; then
10+
if [ -d /run/systemd/system ]; then
11+
# Create ntfy user/group
12+
id ntfy >/dev/null 2>&1 || useradd --system --no-create-home ntfy
13+
chown ntfy.ntfy /var/cache/ntfy
14+
chmod 700 /var/cache/ntfy
1415

15-
# Hack to change permissions on cache file
16-
configfile="/etc/ntfy/server.yml"
17-
if [ -f "$configfile" ]; then
18-
cachefile="$(cat "$configfile" | perl -n -e'/^\s*cache-file: ["'"'"']?([^"'"'"']+)["'"'"']?/ && print $1')" # Oh my, see #47
19-
if [ -n "$cachefile" ]; then
20-
chown ntfy.ntfy "$cachefile" || true
21-
chmod 600 "$cachefile" || true
16+
# Hack to change permissions on cache file
17+
configfile="/etc/ntfy/server.yml"
18+
if [ -f "$configfile" ]; then
19+
cachefile="$(cat "$configfile" | perl -n -e'/^\s*cache-file: ["'"'"']?([^"'"'"']+)["'"'"']?/ && print $1')" # Oh my, see #47
20+
if [ -n "$cachefile" ]; then
21+
chown ntfy.ntfy "$cachefile" || true
22+
chmod 600 "$cachefile" || true
23+
fi
2224
fi
23-
fi
2425

25-
# Restart services
26-
systemctl --system daemon-reload >/dev/null || true
27-
if systemctl is-active -q ntfy.service; then
28-
echo "Restarting ntfy.service ..."
29-
if [ -x /usr/bin/deb-systemd-invoke ]; then
30-
deb-systemd-invoke try-restart ntfy.service >/dev/null || true
31-
else
32-
systemctl restart ntfy.service >/dev/null || true
26+
# Restart services
27+
systemctl --system daemon-reload >/dev/null || true
28+
if systemctl is-active -q ntfy.service; then
29+
echo "Restarting ntfy.service ..."
30+
if [ -x /usr/bin/deb-systemd-invoke ]; then
31+
deb-systemd-invoke try-restart ntfy.service >/dev/null || true
32+
else
33+
systemctl restart ntfy.service >/dev/null || true
34+
fi
3335
fi
34-
fi
35-
if systemctl is-active -q ntfy-client.service; then
36+
if systemctl is-active -q ntfy-client.service; then
3637
echo "Restarting ntfy-client.service ..."
3738
if [ -x /usr/bin/deb-systemd-invoke ]; then
3839
deb-systemd-invoke try-restart ntfy-client.service >/dev/null || true
3940
else
4041
systemctl restart ntfy-client.service >/dev/null || true
4142
fi
4243
fi
44+
fi
4345
fi

scripts/postrm.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33

44
# Delete the config if package is purged
5-
if [ "$1" = "purge" ]; then
5+
if [ "$1" = "purge" ] || [ "$1" = "0" ]; then
66
id ntfy >/dev/null 2>&1 && userdel ntfy
77
rm -f /etc/ntfy/server.yml /etc/ntfy/client.yml
88
rmdir /etc/ntfy || true

scripts/preinst.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "$1" = "install" ] || [ "$1" = "upgrade" ]; then
4+
if [ "$1" = "install" ] || [ "$1" = "upgrade" ] || [ "$1" -ge 1 ]; then
55
# Migration of old to new config file name
66
oldconfigfile="/etc/ntfy/config.yml"
77
configfile="/etc/ntfy/server.yml"

scripts/prerm.sh

+8-6
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
set -e
33

44
# Stop systemd service
5-
if [ -d /run/systemd/system ] && [ "$1" = remove ]; then
6-
echo "Stopping ntfy.service ..."
7-
if [ -x /usr/bin/deb-systemd-invoke ]; then
8-
deb-systemd-invoke stop 'ntfy.service' >/dev/null || true
9-
else
10-
systemctl stop ntfy >/dev/null 2>&1 || true
5+
if [ -d /run/systemd/system ]; then
6+
if [ "$1" = "remove" ] || [ "$1" = "0" ]; then
7+
echo "Stopping ntfy.service ..."
8+
if [ -x /usr/bin/deb-systemd-invoke ]; then
9+
deb-systemd-invoke stop 'ntfy.service' >/dev/null || true
10+
else
11+
systemctl stop ntfy >/dev/null 2>&1 || true
12+
fi
1113
fi
1214
fi

0 commit comments

Comments
 (0)