#! /bin/sh
# $Id: pop3d.rc.in,v 1.17 2008/05/04 13:12:47 mrsam Exp $
#
# Copyright 1998 - 2005 Double Precision, Inc.
# See COPYING for distribution information.


prefix=/usr/local
exec_prefix=/usr/local
bindir=/usr/local/bin
libexecdir=/usr/local/libexec

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

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

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

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