#! /bin/bash
# $Id: pop3d.rc.in,v 1.8 2002/10/25 12:15:17 mrsam Exp $
#
# Copyright 1998 - 2002 Double Precision, Inc.
# See COPYING for distribution information.

RUNLEVEL=3
NEEDS="+network +remotefs"
.  /etc/init.d/smgl_functions

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

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

case $1 in
start)
	LIBAUTHMODULES=""
	for f in `builtin echo $AUTHMODULES`; do
		LIBAUTHMODULES="$LIBAUTHMODULES ${libexecdir}/authlib/$f"
	done

	if test -x ${libexecdir}/authlib/authdaemond; then
		/bin/env - ${libexecdir}/authlib/authdaemond start
	fi

	/bin/env - /bin/sh -c " set -a ;
			prefix=/usr ;
			exec_prefix=/usr ;
			bindir=${exec_prefix}/bin ;
			libexecdir=${libexecdir} ;
			. /etc/courier-imap/pop3d ; \
			. /etc/courier-imap/pop3d-ssl ; \
			TLS_PROTOCOL=$TLS_STARTTLS_PROTOCOL ; \
			export TLS_PROTOCOL ;
			${libexecdir}/couriertcpd -address=$ADDRESS \
			-stderrlogger=${exec_prefix}/sbin/courierlogger \
			-stderrloggername=pop3d \
			-maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP \
			-pid=$PIDFILE $TCPDOPTS \
			$PORT ${exec_prefix}/sbin/pop3login $LIBAUTHMODULES \
			${exec_prefix}/bin/pop3d Maildir"
	;;
stop)
	${libexecdir}/couriertcpd -pid=$PIDFILE -stop
	if test -x ${libexecdir}/authlib/authdaemond; then
		${libexecdir}/authlib/authdaemond stop
	fi
	;;
esac
exit 0
