:
#
#	@(#) Init 96.1 01/01/02 SCOINC
#
# **************************************************************************
# 
# 	Copyright (c) 1990-2001		The Santa Cruz Operation, Inc.
# 
# 	All rights reserved.  No part of this program or publication may be
# 	reproduced, transmitted, transcribed, stored in a retrieval system,
# 	or translated into any language or computer language, in any form or
# 	by any means, electronic, mechanical, magnetic, optical, chemical,
# 	biological, or otherwise, without the prior written permission of:
# 	
# 		The Santa Cruz Operation, Inc.		(408) 425-7222
# 		400 Encinal St., Santa Cruz, California 95060 USA
# 
# **************************************************************************
#
# SendMail startup/shutdown script.
#
# Modification History
#
# M003, 02-Jan-2001, andrean
#	- Add rebuild of aliases file on startup, since AutoRebuildAliases
#	  option has been removed from the default sendmail.cf.  There is a
#	  potential for a denial of service attack if AutoRebuildAliases is
#	  set so the option has been deprecated as of sendmail version 8.10
#	  and will be removed from a future version.
#
# M002, 01-Oct-94, keithr
#	- No need to put sendmail into the background when used
#	  with the -bd flag.
#
# M001, 15-May-94, keithr
#	- The output of ps -e doesn't always start with a space
#	  in Everest, so I had to change the sed command.
#
# M000, 05-May-94, keithr
#	- Created.
#
case $1 in
    start)
	set -- `who -r`
	if [ "$9" = "S" ]		# run only during boot time
	then
	    if [ -x /usr/lib/sendmail ]
	    then
		if [ ! -f /etc/sendmail.pid ]
		then
			touch /etc/sendmail.pid
		fi
		/usr/lib/sendmail -bi >/dev/null 2>&1
		/bin/su root -c "/usr/lib/sendmail -bd -q1h" 2> /dev/null
	    fi
	fi
	;;

    stop)
	if [ -x /bin/ps -a -x /bin/kill ]
	then
	    #
	    # su root to set luid (required for systems with SECLUID set)
	    #
	    pid=`su root -c "ps -e" \
		| sed -n -e '/ sendmail$/s/^ *\([1-9][0-9]*\) .*$/\1/p'`

	    if [ -n "$pid" ]
	    then
		kill $pid
	    fi
	fi
	;;

    *)
	echo "Usage: $0 {start|stop}" >&2
	;;
esac
