#!/sbin/sh
#
# ident "@(#)smtp-postfix	1.00	2005/05/08 SY"

ERRMSG1='WARNING: /var/mail is NFS-mounted without setting actimeo=0,'
ERRMSG2='this can cause mailbox locking and access problems.'
POSTFIX="/usr/sbin/postfix"
MAIN_CF="/etc/postfix/main.cf"
MASTER_CF="/etc/postfix/master.cf"
ALIASES_FILE="/etc/mail/aliases"

case "$1" in 
'refresh')
	if [ -f $POSTFIX -a -f $MAIN_CF -a -f $MASTER_CF ]; then
		$POSTFIX reload
	fi	
        ;;

'start')
	if [ -f $POSTFIX -a -f $MAIN_CF -a -f $MASTER_CF ]; then
		$POSTFIX start
	fi	

	if /usr/bin/nawk 'BEGIN{s = 1}
	    $2 == "/var/mail" && $3 == "nfs" && $4 !~ /actimeo=0/ &&
	    $4 !~ /noac/{s = 0} END{exit s}' /etc/mnttab; then

		/usr/bin/logger -p mail.crit "$ERRMSG1"
		/usr/bin/logger -p mail.crit "$ERRMSG2"
	fi
	;;

'stop')
	if [ -f $POSTFIX -a -f $MAIN_CF -a -f $MASTER_CF ]; then
		$POSTFIX stop
	fi	
	;;

*)
	echo "Usage: $0 { start | stop | refresh }"
	exit 1
	;;
esac
exit 0
