#dent	"@(#)/etc/init.d/smtpinit.sl 1.1 UW2.01 02/07/95 13441 NOVELL"
if [ ! -d /usr/bin ]
then			# /usr not mounted
	exit
fi

if [ -z "$LC_ALL" -a -z "$LC_MESSAGES" ]
then
	if [ -z "$LANG" ]
	then
		LNG=`defadm locale LANG 2>/dev/null`
		if [ "$?" != 0 ]
		then LANG=C
		else eval $LNG
		fi
	fi
	export LANG
fi
LABEL="UX:$0"
CAT=uxrc

mldmode > /dev/null 2>&1
if [ "$?" = "0" ]
then			# Enhanced Security running
	exit
fi

case "$1" in
'start')
	pid=`ps -e | grep smtpd$ | awk '{print $1}'`
	kill $pid 2>/dev/null
	pid=`ps -e | grep smtp$ | awk '{print $1}'`
	kill $pid 2>/dev/null
	/usr/lib/mail/surrcmd/createSurr
	rm -f /etc/mail/smtpd.pid
	rm -f /etc/mail/smtp.pid
	chmod +w /dev/osm
#	/usr/lib/mail/surrcmd/smtpd -d 2 >/dev/osm 2>&1
	/usr/lib/mail/surrcmd/smtpd
	echo smtpd started! >/dev/osm
#	/usr/lib/mail/surrcmd/smtp >/dev/osm 2>&1
#	echo smtp started! >/dev/osm
	sleep 1
	chown smtp /var/spool/mailq/C* 2>/dev/null
	chown smtp /var/spool/mailq/D* 2>/dev/null
	chgrp mail /var/spool/mailq/C* 2>/dev/null
	chgrp mail /var/spool/mailq/D* 2>/dev/null
	chown smtp /var/spool/mailq/Logs/*
	chgrp mail /var/spool/mailq/Logs/*
	;;
'stop')
	pid=`ps -e | grep smtpd$ | awk '{print $1}'`
	kill $pid 2>/dev/null
	rm -f /etc/mail/smtpd.pid
	pid=`ps -e | grep smtp$ | awk '{print $1}'`
	kill $pid 2>/dev/null
	rm -f /etc/mail/smtp.pid
	;;
*)
	USAGE="$0 { start | stop }"
	pfmt -l $LABEL -s action -g $CAT:4 "Usage: %s\n" "$USAGE"
	;;
esac
