#!/sbin/sh
#
#
#pragma ident "@(#)SUNWscnsm.sh	1.5 99/10/27 SMI"
#
#ident	"@(#)SUNWhansm.sh 1.2     96/12/02 SMI"
#
# /etc/init.d/SUNWhansm - Start/Stop the sendmail daemon only
# to drain /var/spool/mqueue.
#
# This is used with SUNWhansm - Highly Available Netscape Mail package.
# The Netscape daemon is listening to the SMTP port.
#

#
# The network and streams should already be built by the time
# this script runs.
#
# If sendmail is already executing, don't re-execute it.
#
PATH=/usr/bin:/bin

case $1 in 
'start')
	if [ -f /usr/lib/sendmail.bk -o -f /usr/lib/sendmail.bak ]; then
		if [ -f /etc/mail/sendmail.cf ]; then
			if [ -d /var/spool/mqueue ]; then
				(cd /var/spool/mqueue; rm -f nf* lf*)
			else
				mkdir /var/spool/mqueue
				chown root /var/spool/mqueue
				chgrp staff /var/spool/mqueue
				chmod 750 /var/spool/mqueue
			fi
		
			pid=`/usr/bin/ps -e | /usr/bin/grep sendmail | \
				/usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
			if test ! "$pid" ; then
				if [ -f /usr/lib/sendmail.bk ]; then
					/usr/lib/sendmail.bk  -q1h; 
				else
					if [ -f /usr/lib/sendmail.bak ]; then
						/usr/lib/sendmail.bak  -q1h; 
					fi
				fi
			fi
		fi
	fi	

	;;
'stop')
	pid=`/usr/bin/ps -e | /usr/bin/grep sendmail | /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
	if test "$pid"
	then
		kill $pid
	fi
	;;
*)
	echo "usage: /etc/rc2.d/S88SUNWscnsm {start|stop}"
	;;
esac
