57 lines
1.3 KiB
Bash
57 lines
1.3 KiB
Bash
#!/bin/sh
|
|
# based on arpwatch.postrm: v2 2004/09/15 KELEMEN Peter <fuji@debian.org>
|
|
# postrm: v1 2006/10/12 Jan Wagner <waja@cyconet.org>
|
|
|
|
NUSER="postfw"
|
|
NGROUP="postfw"
|
|
|
|
set -e
|
|
|
|
case "$1" in
|
|
purge)
|
|
# find first and last SYSTEM_UID numbers
|
|
for LINE in `grep SYSTEM_UID /etc/adduser.conf | grep -v "^#"`; do
|
|
case $LINE in
|
|
FIRST_SYSTEM_UID*)
|
|
FIST_SYSTEM_UID=`echo $LINE | cut -f2 -d '='`
|
|
;;
|
|
LAST_SYSTEM_UID*)
|
|
LAST_SYSTEM_UID=`echo $LINE | cut -f2 -d '='`
|
|
;;
|
|
*)
|
|
;;
|
|
esac
|
|
done
|
|
# remove system account if necessary
|
|
if [ -n "$FIST_SYSTEM_UID" ] && [ -n "$LAST_SYSTEM_UID" ]; then
|
|
if USERID=`getent passwd $NUSER | cut -f 3 -d ':'`; then
|
|
if [ -n "$USERID" ]; then
|
|
if [ "$FIST_SYSTEM_UID" -le "$USERID" ] && \
|
|
[ "$USERID" -le "$LAST_SYSTEM_UID" ]; then
|
|
if which deluser > /dev/null; then
|
|
deluser --quiet $NUSER || true
|
|
# And then remove the group
|
|
GROUPID=`getent group $NGROUP | cut -f 3 -d ':'`
|
|
if [ -n "$GROUPID" ]; then
|
|
if which delgroup > /dev/null; then
|
|
delgroup --quiet $NGROUP || true
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
;;
|
|
|
|
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
|
|
;;
|
|
|
|
*)
|
|
echo "postrm called with unknown argument \`$1'" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
#DEBHELPER#
|