53 lines
1.3 KiB
Bash
53 lines
1.3 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
# postrm script for logcorrelator .deb package
|
|
|
|
case "$1" in
|
|
remove)
|
|
# On remove, leave config and data files
|
|
;;
|
|
|
|
purge)
|
|
# On purge, remove everything
|
|
|
|
# Stop service if running
|
|
if [ -x /bin/systemctl ] && [ -d /run/systemd/system ]; then
|
|
systemctl stop logcorrelator.service 2>/dev/null || true
|
|
systemctl disable logcorrelator.service 2>/dev/null || true
|
|
systemctl daemon-reload
|
|
fi
|
|
|
|
# Remove configuration
|
|
rm -rf /etc/logcorrelator
|
|
|
|
# Remove data and logs
|
|
rm -rf /var/lib/logcorrelator
|
|
rm -rf /var/log/logcorrelator
|
|
rm -rf /var/run/logcorrelator
|
|
|
|
# Remove user and group
|
|
if getent passwd logcorrelator > /dev/null 2>&1; then
|
|
userdel logcorrelator 2>/dev/null || true
|
|
fi
|
|
|
|
if getent group logcorrelator > /dev/null 2>&1; then
|
|
groupdel logcorrelator 2>/dev/null || true
|
|
fi
|
|
;;
|
|
|
|
abort-upgrade|abort-remove|abort-deconfigure)
|
|
# On abort, restart the service
|
|
if [ -x /bin/systemctl ] && [ -d /run/systemd/system ]; then
|
|
systemctl start logcorrelator.service 2>/dev/null || true
|
|
fi
|
|
;;
|
|
|
|
*)
|
|
echo "postrm called with unknown argument '$1'" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
exit 0
|