
#	ATT: ident	"sadmin:admin/menu/machinemgmt/firmware	2.3"

#ident	"@(#)sadmin/admin/menu/machinemgmt:shutdown	25.1"

#menu# stop all running programs then enter single user mode
#help# 
#help#	This procedure will stop all running programs, close any open files,
#help#	write out information to disk (such as directory information), and
#help#	then enter single user mode.  From single user mode, one can run machine
#help#	diagnostics or power the machine off.

trap 'exit 0' 1 2  15
flags="-qq -k$$"

cd /
wholist=`who`
if [ `echo "${wholist}"  |  wc -l` -gt 1 ]
then
	echo "Users currently logged in:\\n${wholist}"
fi

if  checkyn ${flags} -f -H'
	An express to single user mode brings the system down as fast as
	possible and enters single user mode.  It is not a very friendly
	thing to do on a system which several users are using.' \
	'Once started, this procedure CANNOT BE STOPPED.
Do you want to go to single user mode "express"?'
then
	grace=0
else
	grace=`checkre ${flags} -D60 -fe -H'
	There are 1 or 2 warning messages (depending on whether there is more
	than one user on the system) before the system is shut down.  The delay
	you specify here is used between the messages and between the last
	message and the beginning of the shut down to single user mode.
	Entering  q  will quit this procedure.' \
'Enter the number of seconds to allow
between the warning messages (default 60): [?, q]' \
		'^[0-9]\{1,\}$' 'Must be all digits.' \
		'^.\{1,4\}$' 'No more than 4 digits.  That is good for over 2.7 hours.'`
fi

trap '' 1 2 3  15
setpgrp /etc/shutdown -g${grace} ||  exit 1	# -g added - dux0
#	A trick to keep the shell from announcing the death of a process and
#	yet keep the command from returning.
sleep 1200&
trap 'kill -9 0 2>/dev/null' 15
wait
