1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
From: Peymaneh <peymaneh@posteo.net>
Date: Fri, 23 Dec 2022 21:20:44 +0100
Subject: postinst/postrm: do not leave directories on purge
dist/scripts/postinstall.sh | 7 +++++++
dist/scripts/postremove.sh | 3 ++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/dist/scripts/postinstall.sh b/dist/scripts/postinstall.sh
index ded3661..b9b84b5 100644
@@ -19,6 +19,13 @@ if [ "$1" = "configure" ]; then
usermod -aG www-data caddy
fi
+ # handle cases where package was installed and then purged;
+ # user and group will still exist but with no home dir
+ if [ ! -d /var/lib/caddy ]; then
+ mkdir -p /var/lib/caddy
+ chown caddy:caddy /var/lib/caddy
+ fi
+
# Add log directory with correct permissions
if [ ! -d /var/log/caddy ]; then
mkdir -p /var/log/caddy
diff --git a/dist/scripts/postremove.sh b/dist/scripts/postremove.sh
index 040913f..af7cd49 100644
@@ -19,4 +19,5 @@ if [ "$1" = "purge" ]; then
deb-systemd-helper unmask caddy.service >/dev/null || true
deb-systemd-helper unmask caddy-api.service >/dev/null || true
fi
-fi
\ No newline at end of file
+ rm -rf /var/lib/caddy /var/log/caddy /etc/caddy
+fi
|