#! /bin/sh

### The basic   zmailer   script works also in SysV init environment.
### This isn't absolutely necessary.

if [ -z "$ZCONFIG" ] ; then
    ZCONFIG=/opt/mail/zmailer.conf
fi

if [ -r $ZCONFIG ]; then
	. $ZCONFIG
else
	exit 0
fi

case "$1" in
start)
	if [ "${SMTPSERVER}" ]; then
		$MAILBIN/zmailer smtp
	elif [ ${MAILSERVER-NONE} = NONE -a -x $MAILBIN/zmailer ]; then
		$MAILBIN/zmailer bootclean
		$MAILBIN/zmailer
	fi
	touch /var/lock/subsys/zmailer
	;;

stop)
	if [ ${MAILSERVER-NONE} = NONE -a -x $MAILBIN/zmailer ]; then
		$MAILBIN/zmailer kill
	fi
	rm -f /var/lock/subsys/zmailer
	;;

*)
	echo "Usage: zmailer.init {start|stop}"
	exit 0
	;;
esac
exit 0
