#! /bin/sh
#
# Copyright 1998 - 2005 Double Precision, Inc.
# See COPYING for distribution information.


prefix=/usr
exec_prefix=/usr
bindir=${exec_prefix}/bin
libexecdir=/usr/libexec

if test ! -f /etc/courier-imap/pop3d
then
	echo "/etc/courier-imap/pop3d does not exist, forgot make install-configure?"
	exit 1
fi

if test ! -f /etc/courier-imap/pop3d-ssl
then
	echo "/etc/courier-imap/pop3d-ssl does not exist, forgot make install-configure?"
	exit 1
fi

. /etc/courier-imap/pop3d-ssl
. /etc/courier-imap/pop3d

case $1 in
start)
	/usr/bin/env -i /bin/sh -c " set -a ;
		prefix=/usr ;
		exec_prefix=/usr ;
		bindir=${exec_prefix}/bin ;
		libexecdir=/usr/libexec ;
		. /etc/courier-imap/pop3d-ssl ; \
		. /etc/courier-imap/pop3d ; \
		PROXY_HOSTNAME=$PROXY_HOSTNAME ; \
		TLS_PROTOCOL=$TLS_STARTTLS_PROTOCOL ; \
		/usr/libexec/slackrepo/mkdir -p `dirname $PIDFILE` ; \
		/usr/sbin/courierlogger -pid=$PIDFILE -start $LOGGEROPTS \
		/usr/libexec/couriertcpd -address=$ADDRESS \
			-maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP \
			$TCPDOPTS \
			$PORT ${exec_prefix}/sbin/pop3login \
				${exec_prefix}/bin/pop3d ${MAILDIRPATH}"
	;;
stop)
	/usr/sbin/courierlogger -pid=$PIDFILE -stop
	;;
esac
exit 0
