#!/bin/sh
#
# $NetBSD: header,v 1.3 2014/12/30 15:13:20 wiz Exp $

SELF="$0"
PKGNAME="$1"
STAGE="$2"
shift 2

AWK="/usr/bin/awk"
BASENAME="/usr/bin/basename"
CAT="/bin/cat"
CHGRP="/usr/bin/chgrp"
CHMOD="/bin/chmod"
CHOWN="/usr/sbin/chown"
CMP="/usr/bin/cmp"
CP="/bin/cp"
DIRNAME="/usr/bin/dirname"
ECHO="echo"
ECHO_N="echo -n"
EGREP="/usr/bin/egrep"
EXPR="/bin/expr"
FALSE="false"
FIND="/usr/bin/find"
GREP="/usr/bin/grep"
GTAR=""
HEAD="/usr/bin/head"
ID="/usr/bin/id"
LINKFARM="/usr/sbin/linkfarm"
LN="/bin/ln"
LS="/bin/ls"
MKDIR="/bin/mkdir -p"
MV="mv -f"
PERL5="/usr/pkg/bin/perl"
PKG_ADMIN="/usr/sbin/pkg_admin"
PKG_INFO="/usr/sbin/pkg_info"
PWD_CMD="/bin/pwd"
RM="/bin/rm"
RMDIR="/bin/rmdir"
SED="/usr/bin/sed"
SETENV="/usr/bin/env"
SH="/bin/sh"
SORT="/usr/bin/sort"
SU="/usr/bin/su"
TEST="test"
TOUCH="/usr/bin/touch"
TR="/usr/bin/tr"
TRUE="true"
XARGS="/usr/bin/xargs"

CURDIR=`${PWD_CMD}`
: ${PKG_METADATA_DIR=${CURDIR}}
PKGBASE="courier-mta"

LOCALBASE="/usr/pkg"
X11BASE="/usr/X11R7"
PREFIX="/usr/pkg"

PKG_SYSCONFBASE="/usr/pkg/etc"
PKG_SYSCONFBASEDIR="/usr/pkg/etc"
PKG_SYSCONFDIR="/usr/pkg/etc/courier"
CONF_DEPENDS=""

CONF_IGNORE_FILES="*[~#] *.OLD *.orig *,v .pkgsrc */.pkgsrc"

case "${PKG_CONFIG:-YES}" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
	_PKG_CONFIG=yes
	;;
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
	_PKG_CONFIG=yes
	;;
esac

# $NetBSD: DEINSTALL,v 1.2 2007/10/15 15:37:13 jlam Exp $

case ${STAGE} in
DEINSTALL)
	#
	# Note some additional files that may be created by the sysadmin
	# that can probably be removed.
	#
	if ${TEST} -x ./+FILES; then
		for file in						\
			${PKG_SYSCONFDIR}/aliases-esmtp			\
			${PKG_SYSCONFDIR}/aliases-esmtp.dat		\
			${PKG_SYSCONFDIR}/aliases-local			\
			${PKG_SYSCONFDIR}/aliases-local.dat		\
			${PKG_SYSCONFDIR}/aliases-uucp			\
			${PKG_SYSCONFDIR}/aliases-uucp.dat		\
			${PKG_SYSCONFDIR}/aliases.dat			\
			${PKG_SYSCONFDIR}/aliasfilteracct		\
			${PKG_SYSCONFDIR}/backuprelay			\
			${PKG_SYSCONFDIR}/batchsize			\
			${PKG_SYSCONFDIR}/bofh				\
			${PKG_SYSCONFDIR}/dotextension			\
			${PKG_SYSCONFDIR}/dsnfrom			\
			${PKG_SYSCONFDIR}/dsnlimit			\
			${PKG_SYSCONFDIR}/esmtpacceptmailfor		\
			${PKG_SYSCONFDIR}/esmtpacceptmailfor.dat	\
			${PKG_SYSCONFDIR}/esmtpd.pem			\
			${PKG_SYSCONFDIR}/esmtpd.rand			\
			${PKG_SYSCONFDIR}/esmtpdelay			\
			${PKG_SYSCONFDIR}/esmtpgreeting			\
			${PKG_SYSCONFDIR}/esmtphelo			\
			${PKG_SYSCONFDIR}/esmtppercentrelay		\
			${PKG_SYSCONFDIR}/esmtppercentrelay.dat		\
			${PKG_SYSCONFDIR}/esmtproutes			\
			${PKG_SYSCONFDIR}/esmtptimeout			\
			${PKG_SYSCONFDIR}/esmtptimeoutconnect		\
			${PKG_SYSCONFDIR}/esmtptimeoutdata		\
			${PKG_SYSCONFDIR}/esmtptimeouthelo		\
			${PKG_SYSCONFDIR}/esmtptimeoutkeepalive		\
			${PKG_SYSCONFDIR}/esmtptimeoutkeepaliveping	\
			${PKG_SYSCONFDIR}/esmtptimeoutquit		\
			${PKG_SYSCONFDIR}/faxqueuetime			\
			${PKG_SYSCONFDIR}/hosteddomains			\
			${PKG_SYSCONFDIR}/hosteddomains.dat		\
			${PKG_SYSCONFDIR}/locals			\
			${PKG_SYSCONFDIR}/localtimeout			\
			${PKG_SYSCONFDIR}/me				\
			${PKG_SYSCONFDIR}/msgidhost			\
			${PKG_SYSCONFDIR}/nochangingfrom		\
			${PKG_SYSCONFDIR}/queuefill			\
			${PKG_SYSCONFDIR}/queuehi			\
			${PKG_SYSCONFDIR}/queuelo			\
			${PKG_SYSCONFDIR}/queuetime			\
			${PKG_SYSCONFDIR}/retryalpha			\
			${PKG_SYSCONFDIR}/retrybeta			\
			${PKG_SYSCONFDIR}/retrydelta			\
			${PKG_SYSCONFDIR}/retrygamma			\
			${PKG_SYSCONFDIR}/sizelimit			\
			${PKG_SYSCONFDIR}/smtpaccess.dat		\
			${PKG_SYSCONFDIR}/submitdelay			\
			${PKG_SYSCONFDIR}/usexsender			\
			${PKG_SYSCONFDIR}/uucpme			\
			${PKG_SYSCONFDIR}/uucpneighbors			\
			${PKG_SYSCONFDIR}/uucprewriteheaders		\
			${PKG_SYSCONFDIR}/warntime			\
			${PKG_SYSCONFDIR}/webadmin/password
		do
			${ECHO} "# FILE: $file . /dev/null" >> ./+FILES
		done
	fi

	# Unconditionally remove socket files.
	for sockfile in							\
		/var/courier/allfilters/.dupfilter		\
		/var/courier/allfilters/.perlfilter		\
		/var/courier/allfilters/dupfilter			\
		/var/courier/allfilters/perlfilter		\
		/var/courier/filters/.dupfilter			\
		/var/courier/filters/.perlfilter			\
		/var/courier/filters/dupfilter			\
		/var/courier/filters/perlfilter
	do
		if ${TEST} -f "$sockfile"; then
			${ECHO} "Removing socket file:"
			${ECHO} "	$sockfile"
			${RM} -f $sockfile
		fi
	done

	# Unconditionally remove temporary files, but not directories
	# which are part of the message queue.
	#
	${RM} -f /var/courier/tmp/* 2>/dev/null
	;;
esac
# $NetBSD: deinstall,v 1.5 2017/06/14 16:23:09 prlw1 Exp $

case ${STAGE} in
DEINSTALL)
  #
  # Unregister package from ocaml-findlib.
  #
  ${TEST} ! -x ./+OCAML_FINDLIB_REGISTER ||
    ./+OCAML_FINDLIB_REGISTER REMOVE ${OCAML_FINDLIB_DIR}

	#
	# Unregister info files.
	#
	${TEST} ! -x ./+INFO_FILES ||
		./+INFO_FILES REMOVE ${PKG_METADATA_DIR}
	#
	# Remove any icon theme caches.
	#
	${TEST} ! -x ./+ICON_THEMES ||
		./+ICON_THEMES REMOVE ${PKG_METADATA_DIR}
	#
	# Remove shells from /etc/shells.
	#
	${TEST} ! -x ./+SHELL ||
		./+SHELL REMOVE ${PKG_METADATA_DIR}
	${TEST} ! -x ./+SHELL ||
		./+SHELL CHECK-REMOVE ${PKG_METADATA_DIR}

	# Remove configuration files if they don't differ from the default
	# config file.
	#
	${TEST} ! -x ./+FILES ||
		./+FILES REMOVE ${PKG_METADATA_DIR}
	;;

POST-DEINSTALL)
	#
	# Update any fonts databases.
	#
	${TEST} ! -x ./+FONTS ||
		./+FONTS ${PKG_METADATA_DIR}
	#
	# Update any icon theme caches.
	#
	${TEST} ! -x ./+ICON_THEMES ||
		./+ICON_THEMES UPDATE ${PKG_METADATA_DIR}
	#
	# Rebuild the system run-time library search path database.
	#
	${TEST} ! -x ./+SHLIBS ||
		./+SHLIBS REMOVE ${PKG_METADATA_DIR}
	#
	# Remove empty directories and unused users/groups.
	#
	${TEST} ! -x ./+DIRS ||
		./+DIRS REMOVE ${PKG_METADATA_DIR}
	${TEST} ! -x ./+USERGROUP ||
		./+USERGROUP REMOVE ${PKG_METADATA_DIR}
	#
	# Check for any existing bits after we're finished de-installing.
	#
	${TEST} ! -x ./+USERGROUP ||
		./+USERGROUP CHECK-REMOVE ${PKG_METADATA_DIR}
	${TEST} ! -x ./+FILES ||
		./+FILES CHECK-REMOVE ${PKG_METADATA_DIR}
	${TEST} ! -x ./+DIRS ||
		./+DIRS CHECK-REMOVE ${PKG_METADATA_DIR}
	;;
esac

# $NetBSD: footer,v 1.1 2006/05/21 23:50:15 jlam Exp $

exit 0

