PREIN
/bin/sh
egrep "^htdig:" /etc/group >/dev/null
if [ $? = 1 ]; then
echo "adding htdig group"
groupadd -r htdig
fi
egrep "^htdig:" /etc/passwd >/dev/null
if [ $? = 1 ]; then
echo "adding htdig user"
useradd -r -g htdig -s "" -d /var/lib/htdig htdig
fi
egrep "^htdig:.*/var/lib/htdig:" /etc/passwd >/dev/null
if [ $? = 1 ]; then
echo "updating htdig homedir"
perl -pi -e "s,^(htdig:.*:)[^:]+(:[^:]*)$,\1/var/lib/htdig\2," /etc/passwd
fi
PREUN
/bin/sh
# we're uninstalling
if [ $1 = 0 ]; then
egrep "^htdig:" /etc/passwd >/dev/null
if [ $? = 0 ]; then
echo "removing htdig user"
userdel htdig # userdel seems to nuke the group too..
fi
egrep "^htdig:" /etc/group >/dev/null
if [ $? = 0 ]; then
echo "removing htdig group"
groupdel htdig
fi
fi