Debian Codegraph @

dist/scripts/postinstall.sh

raw symbols ◀ ▶ SCIP
2 Debian patches touch this file
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 set -e
3
4 if [scip-shell system . . `[`. "$1" = "configure" ]; then
5 # Add user and group
6 if ! getentscip-shell system . . getent. group caddy >/dev/nullscip-shell filesystem . . `/dev/null`.; then
7 groupaddscip-shell system . . groupadd. --system caddy
8 fi
9 if ! getentscip-shell system . . getent. passwd caddy >/dev/nullscip-shell filesystem . . `/dev/null`.; then
10 useraddscip-shell system . . useradd. --system \
11 --gid caddy \
12 --create-home \
13 --home-dir /var/lib/caddyscip-shell filesystem . . `/var/lib/caddy`. \
14 --shell /usr/sbin/nologinscip-shell filesystem . . `/usr/sbin/nologin`. \
15 --comment "Caddy web server" \
16 caddy
17 fi
18 if getentscip-shell system . . getent. group www-data >/dev/nullscip-shell filesystem . . `/dev/null`.; then
19 usermodscip-shell system . . 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 [scip-shell system . . `[`. ! -d /var/lib/caddyscip-shell filesystem . . `/var/lib/caddy`. ]; then
25 mkdirscip-shell system . . mkdir. -p /var/lib/caddyscip-shell filesystem . . `/var/lib/caddy`.
26 chownscip-shell system . . chown. caddy:caddy /var/lib/caddyscip-shell filesystem . . `/var/lib/caddy`.
27 fi
28
29 # Add log directory with correct permissions
30 if [scip-shell system . . `[`. ! -d /var/log/caddyscip-shell filesystem . . `/var/log/caddy`. ]; then
31 mkdirscip-shell system . . mkdir. -p /var/log/caddyscip-shell filesystem . . `/var/log/caddy`.
•32 chownscip-shell system . . chown. caddy:caddy /var/log/caddyscip-shell filesystem . . `/var/log/caddy`.
33 fi
34 fi
35
36 if [scip-shell system . . `[`. "$1" = "configure" ] || [scip-shell system . . `[`. "$1" = "abort-upgrade" ] || [scip-shell system . . `[`. "$1" = "abort-deconfigure" ] || [scip-shell system . . `[`. "$1" = "abort-remove" ] ; then
37 # This will only remove masks created by d-s-h on package removal.
38 deb-systemd-helperscip-shell system . . deb-systemd-helper. unmask caddy.service >/dev/nullscip-shell filesystem . . `/dev/null`. || truescip-shell system . . true.
39 deb-systemd-helperscip-shell system . . deb-systemd-helper. unmask caddy-api.service >/dev/nullscip-shell filesystem . . `/dev/null`. || truescip-shell system . . true.
40
41 # was-enabled defaults to true, so new installations run enable.
42 if deb-systemd-helperscip-shell system . . 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-helperscip-shell system . . deb-systemd-helper. enable caddy.service >/dev/nullscip-shell filesystem . . `/dev/null`. || truescip-shell system . . true.
46 deb-systemd-invokescip-shell system . . deb-systemd-invoke. start caddy.service >/dev/nullscip-shell filesystem . . `/dev/null`. || truescip-shell system . . 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-helperscip-shell system . . deb-systemd-helper. update-state caddy.service >/dev/nullscip-shell filesystem . . `/dev/null`. || truescip-shell system . . true.
51 deb-systemd-helperscip-shell system . . deb-systemd-helper. update-state caddy-api.service >/dev/nullscip-shell filesystem . . `/dev/null`. || truescip-shell system . . true.
52 fi
53
54 # Restart only if it was already started
55 if [scip-shell system . . `[`. -d /run/systemd/systemscip-shell filesystem . . `/run/systemd/system`. ]; then
56 systemctl --system daemon-reload >/dev/nullscip-shell filesystem . . `/dev/null`. || truescip-shell system . . true.
57 if [scip-shell system . . `[`. -n "$2" ]; then
58 deb-systemd-invokescip-shell system . . deb-systemd-invoke. try-restart caddy.service >/dev/nullscip-shell filesystem . . `/dev/null`. || truescip-shell system . . true.
59 deb-systemd-invokescip-shell system . . deb-systemd-invoke. try-restart caddy-api.service >/dev/nullscip-shell filesystem . . `/dev/null`. || truescip-shell system . . true.
60 fi
61 fi
•62 fi