#ident	"@(#)sadmin:admin/menu/machinemgmt/singleuser 1.1 (C) Ferranti"
#menu# stop all running programs then enter single user mode
#help# 
#help#	This procedure will stop all running programs, log all users off the
#help#	system and then enter single user mode. 

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 brings the system down as fast as possible and
	enter single user mode.  It is not a very friendly thing to do on a 
	system which several users are using.
	Entering  q  will quit this procedure.' \
	'Once started, this procedure CANNOT BE STOPPED.
Do you want to go to single user "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.
	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
#	-is assumes that init s goes to single user.
/etc/shutdown -y -g${grace} -is
