Debian Codegraph @

dist/scripts/postinstall.sh

raw symbols ◀ ▶ SCIP
2 Debian patches touch this file
1 #!/bin/sh
2 set -e
3
4 if [ "$1" = "configure" ]; then
5 # Add user and group
6 if ! getent group caddy >/dev/null; then
7 groupadd --system caddy
8 fi
9 if ! getent passwd caddy >/dev/null; then
10 useradd --system \
11 --gid caddy \
12 --create-home \
13 --home-dir /var/lib/caddy \
14 --shell /usr/sbin/nologin \
15 --comment "Caddy web server" \
16 caddy
17 fi
18 if getent group www-data >/dev/null; then
19 usermod -aG www-data caddy
20 fi
21
•22 # handle cases where package was installed and then purged;
23 # user and group will still exist but with no home dir
24 if [ ! -d /var/lib/caddy ]; then
25 mkdir -p /var/lib/caddy
26 chown caddy:caddy /var/lib/caddy
27 fi
28
29 # Add log directory with correct permissions
30 if [ ! -d /var/log/caddy ]; then
31 mkdir -p /var/log/caddy
•32 chown caddy:caddy /var/log/caddy
33 fi
34 fi
35
36 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
37 # This will only remove masks created by d-s-h on package removal.
38 deb-systemd-helper unmask caddy.service >/dev/null || true
39 deb-systemd-helper unmask caddy-api.service >/dev/null || true
40
41 # was-enabled defaults to true, so new installations run enable.
42 if deb-systemd-helper --quiet was-enabled caddy.service; then
43 # Enables the unit on first installation, creates new
44 # symlinks on upgrades if the unit file has changed.
45 deb-systemd-helper enable caddy.service >/dev/null || true
46 deb-systemd-invoke start caddy.service >/dev/null || true
47 else
48 # Update the statefile to add new symlinks (if any), which need to be
49 # cleaned up on purge. Also remove old symlinks.
50 deb-systemd-helper update-state caddy.service >/dev/null || true
51 deb-systemd-helper update-state caddy-api.service >/dev/null || true
52 fi
53
54 # Restart only if it was already started
55 if [ -d /run/systemd/system ]; then
56 systemctl --system daemon-reload >/dev/null || true
57 if [ -n "$2" ]; then
58 deb-systemd-invoke try-restart caddy.service >/dev/null || true
59 deb-systemd-invoke try-restart caddy-api.service >/dev/null || true
60 fi
61 fi
•62 fi