freebsd-ports/irc/dancer-ircd/pkg-deinstall
Akinori MUSHA 13e5cb29f3 Add user & group in package building too.
Submitted by:	bento

Remove user & group on deinstallation (only on bento).
2003-04-24 20:18:10 +00:00

56 lines
911 B
Bash

#!/bin/sh
#
# $FreeBSD$
#
ask() {
local question default answer
question=$1
default=$2
if [ -z "$BATCH" ]; then
read -p "${question} [${default}]? " answer
fi
if [ x${answer} = x ]; then
answer=${default}
fi
echo ${answer}
}
yesno() {
local dflt question answer
question=$1
dflt=$2
while :; do
answer=$(ask "${question}" "${dflt}")
case "${answer}" in
[Yy]*) return 0;;
[Nn]*) return 1;;
esac
echo "Please answer yes or no."
done
}
delete_account() {
local u g
u=$1
g=$2
if yesno "Do you want me to remove group \"${g}\"" y; then
pw groupdel -n ${g}
echo "Done."
fi
if yesno "Do you want me to remove user \"${u}\"" y; then
pw userdel -n ${u}
echo "Done."
fi
}
if [ "$2" != "POST-DEINSTALL" ]; then
exit 0
fi
if [ -n "$PACKAGE_BUILDING" ]; then
delete_account ircd ircd
fi