RedFlag/installer/linux/debian/postrm
Fimeg 765ec4188f publish: carry the Windows product into the projection
The tree adds the installer, service and test paths admitted by this source commit. Nothing else changes about what may cross.

Source-Sha: 3e4a3aa4ce092e9e3f51bc78daf3ddc14d9638f8

Policy-Sha: 3e4a3aa4ce092e9e3f51bc78daf3ddc14d9638f8

Tree-Digest: 89d6fce3828a0e0de0c8eeb41ee6750f4462217e2a04b5190297134d7f4a50c3
2026-09-09 12:47:34 -04:00

34 lines
1.2 KiB
Shell

#!/bin/sh
# Removal drops package-created state outside dpkg's file list. Config, keys and
# the journal survive `remove` and are only destroyed on `purge` — a re-install
# over a removed package must find its authority intact.
set -e
RUN_BIN_DIR=/usr/local/bin
case "$1" in
remove|purge)
for b in redflag-agent redflag-helper redflag-desktop; do
# Only our own symlinks; a self-updated real binary is left for the operator.
if [ -L "$RUN_BIN_DIR/$b" ] && [ "$(readlink "$RUN_BIN_DIR/$b")" = "/usr/bin/$b" ]; then
rm -f "$RUN_BIN_DIR/$b"
fi
done
[ -d /run/systemd/system ] && systemctl daemon-reload || true
;;
esac
if [ "$1" = purge ]; then
# Authority material is root-owned and irreplaceable; say what is going.
echo "[INFO] [deb] [postrm] purging RedFlag configuration, local authority key and journal"
rm -f /etc/sudoers.d/redflag-agent-mint
rm -rf /etc/redflag /var/lib/redflag /var/log/redflag
if getent passwd redflag-agent >/dev/null 2>&1; then
deluser --system redflag-agent >/dev/null 2>&1 || true
fi
if getent group redflag-local >/dev/null 2>&1; then
delgroup --system redflag-local >/dev/null 2>&1 || true
fi
fi
exit 0