#! /bin/sh delete_account() { local u g home u=$1 g=$2 echo -n "Removing group \"${g}\"... " pw groupdel -n ${g} echo "done." echo -n "Removing user \"${u}\"... " eval home=~${u} echo 'y' | pw userdel -n ${u} echo "done." } zero_crontab() { local u u=$1 echo -n 'Zeroing crontab(5) file belonging to user "%%USER%%"... ' crontab -u ${u} /dev/null || exit echo 'done.' echo '(The crontab(5) will be deleted completely when user "%%USER%%" is removed.)' } export PATH=/bin:/usr/bin:/usr/sbin case $2 in DEINSTALL) zero_crontab %%USER%% if ps -axwU %%USER%% | grep -q python; then echo 'Killing all running processes belonging to user "%%USER%%".' killall -m -u %%USER%% python sleep 2 fi ;; POST-DEINSTALL) if [ -d %%MAILMANDIR%% ]; then echo '%%MAILMANDIR%% is not empty - this installation may have active lists!' echo '- The "%%USER%%" user and "%%GROUP%%" group were therefore not deleted.' echo '- You may delete them with "pw groupdel %%GROUP%%; pw userdel %%USER%%".' else delete_account %%USER%% %%GROUP%% fi ;; esac