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

prefix="/usr/local"
exec_prefix="/usr/local"
datarootdir="/usr/local/share"
sysconfdir="/usr/local/etc/courier"
sbindir="${exec_prefix}/sbin"
bindir="/usr/local/bin"
libexecdir="/usr/local/libexec"
datadir="/usr/local/share/courier"

. ${sysconfdir}/sqwebmaild

case $1 in
start)
	case "`cat ${sysconfdir}/calendarmode 2>/dev/null`" in
	net)
	/usr/bin/env -i /bin/sh -c " set -a ;
		prefix=${prefix} ;
		exec_prefix=${exec_prefix} ;
		sbindir=${sbindir} ;
		libexecdir=${libexecdir} ;
		. ${sysconfdir}/sqwebmaild ; \
		/usr/local/sbin/courierlogger -pid=${PIDFILE}.pcp $LOGGEROPTS -start \
			${libexecdir}/courier/pcpd server"
		;;
	*)
		;;
	esac

	/usr/bin/env -i /bin/sh -c " set -a ;
		prefix=${prefix} ;
		exec_prefix=${exec_prefix} ;
		sbindir=${sbindir} ;
		libexecdir=${libexecdir} ;
		. ${sysconfdir}/sqwebmaild ; \
		/bin/mkdir -p `dirname $PIDFILE` ; \
		/usr/local/sbin/courierlogger -pid="'${PIDFILE}'" $LOGGEROPTS -start \
			${libexecdir}/courier/sqwebmaild"
	;;
stop)
	/usr/local/sbin/courierlogger -pid=${PIDFILE} -stop
	/usr/local/sbin/courierlogger -pid=${PIDFILE}.pcp -stop
	;;
reload)
	/usr/local/sbin/courierlogger -pid=${PIDFILE} -restart
	/usr/local/sbin/courierlogger -pid=${PIDFILE}.pcp -restart
	;;
esac
