|
6 | 6 | #
|
7 | 7 | # TODO: This is only tested on Debian.
|
8 | 8 | #
|
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 |
14 | 15 |
|
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 |
22 | 24 | fi
|
23 |
| - fi |
24 | 25 |
|
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 |
33 | 35 | fi
|
34 |
| - fi |
35 |
| - if systemctl is-active -q ntfy-client.service; then |
| 36 | + if systemctl is-active -q ntfy-client.service; then |
36 | 37 | echo "Restarting ntfy-client.service ..."
|
37 | 38 | if [ -x /usr/bin/deb-systemd-invoke ]; then
|
38 | 39 | deb-systemd-invoke try-restart ntfy-client.service >/dev/null || true
|
39 | 40 | else
|
40 | 41 | systemctl restart ntfy-client.service >/dev/null || true
|
41 | 42 | fi
|
42 | 43 | fi
|
| 44 | + fi |
43 | 45 | fi
|
0 commit comments