#!/bin/sh
#
# $FreeBSD: ports/security/courier-authlib/files/pkg-deinstall.in,v 1.2 2005/07/30 21:55:23 oliver Exp $
#

PKG_PREFIX=${PKG_PREFIX:=/usr/local}
LOCALSTATEDIR=${LOCALSTATEDIR:=/var/spool/courier}

USER=courier
GROUP=courier

if [ ":$2" = ":POST-DEINSTALL" ]; then
    if [ -z "${PACKAGE_BUILDING}" -a -z "${BATCH}" ]; then
        echo ""
        echo "Warning: Removing user courier will also delete any"
        echo "	 undelivered mail in the mail queue directories!!!"
        echo "	 Do *not* do it if you're upgrading and would like"
        echo "	 courier to continue trying to deliver this mail."
        echo ""
    else
        AFFIRM='-y'
    fi
    [ -d "$LOCALSTATEDIR" ] && /usr/sbin/chown -Rh ${USER}:${GROUP} "$LOCALSTATEDIR"
    /usr/sbin/rmuser ${AFFIRM} ${USER} 2> /dev/null
    [ -d "$LOCALSTATEDIR" ] && /usr/sbin/chown root:wheel "$LOCALSTATEDIR"
fi

exit 0
