Debian Codegraph @

dist/scripts/postinstall.sh

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 2 — not the installed (fully patched) source.
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 # Add log directory with correct permissions
23 if [ ! -d /var/log/caddy ]; then
24 mkdir -p /var/log/caddy
25 chown -R caddy:caddy /var/log/caddy
26 fi
27 fi
28
29 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
30 # This will only remove masks created by d-s-h on package removal.
31 deb-systemd-helper unmask caddy.service >/dev/null || true
32 deb-systemd-helper unmask caddy-api.service >/dev/null || true
33
34 # was-enabled defaults to true, so new installations run enable.
35 if deb-systemd-helper --quiet was-enabled caddy.service; then
36 # Enables the unit on first installation, creates new
37 # symlinks on upgrades if the unit file has changed.
38 deb-systemd-helper enable caddy.service >/dev/null || true
39 deb-systemd-invoke start caddy.service >/dev/null || true
40 else
41 # Update the statefile to add new symlinks (if any), which need to be
42 # cleaned up on purge. Also remove old symlinks.
43 deb-systemd-helper update-state caddy.service >/dev/null || true
44 deb-systemd-helper update-state caddy-api.service >/dev/null || true
45 fi
46
47 # Restart only if it was already started
48 if [ -d /run/systemd/system ]; then
49 systemctl --system daemon-reload >/dev/null || true
50 if [ -n "$2" ]; then
51 deb-systemd-invoke try-restart caddy.service >/dev/null || true
52 deb-systemd-invoke try-restart caddy-api.service >/dev/null || true
53 fi
54 fi
55 fi