#! /bin/sh
#
# Copyright 2004-2005 S. Varshavchik.
# See COPYING for distribution information.

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

. ${sysconfdir}/sqwebmaild

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

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