From: Peymaneh 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(-) --- a/dist/scripts/postinstall.sh +++ b/dist/scripts/postinstall.sh @@ -19,6 +19,13 @@ 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