fix: delete users only if exist

This commit is contained in:
2026-04-06 09:05:27 +02:00
parent b91099579e
commit 6e6f02af54

View File

@@ -95,12 +95,23 @@ systemctl reenable gitea.service
systemctl restart gitea.service nginx.service
%postun
# If removing, delete users and db
# If uninstalling, then delete users and db
if [ $1 == 0 ]; then
# Remove gitea user if existing
if id gitea >/dev/null 2>&1; then
userdel --force --remove gitea
fi
# Remove gitea database if existing
if runuser --user=postgres -- psql --quiet --tuples-only --command='\du' | grep --quiet gitea; then
runuser --user=postgres -- psql --command='DROP DATABASE gitea; DROP USER gitea;'
fi
# Remove actrunner users if existing
for i in $(seq 1 4); do
if id actrunner$i >/dev/null 2>&1; then
userdel --force --remove actrunner$i
fi
done
fi