#!/bin/sh


if [ "$2" != "POST-DEINSTALL" ]; then
	exit 0
fi

POLIPOUSER=polipo
POLIPOGROUP=polipo

PCONFIGDIR=/usr/local/etc/polipo/
PPIDDIR=/var/run/polipo/
POLIPOCACHE=/var/cache/polipo
POLIPOLOG=/var/log/polipo
POLIPOPID=/var/run/polipo/polipo.pid
POLIPODATA=/magus/work/usr/mports/www/polipo/work/fake-inst-i386/usr/local/share/polipo


if pw usershow "${POLIPOUSER}" 2>/dev/null 1>&2; then
	echo "---> To delete ${POLIPOUSER} user permanently, use 'pw userdel \"${POLIPOUSER}\"'"
fi

if [ -d "$POLIPOCACHE" ]; then
	rm -r "$POLIPOCACHE" || exit 1
fi
if [ -d "$PPIDDIR" ]; then
	rm -r "$PPIDDIR" || exit 1
fi

if fgrep "${POLIPOLOG}" "/etc/newsyslog.conf" 2>/dev/null 1>&2; then
 	echo "---> You should remove from /etc/newsyslog.conf the \"${POLIPOLOG}\" entry manually."
fi

rmdir $POLIPODATA/www/doc $POLIPODATA/www $POLIPODATA 2>/dev/null
rmdir $PCONFIGDIR 2>/dev/null || echo "---> If you not plan to reinstall polipo, you can safely remove ${PCONFIGDIR}."
exit 0
