:
#	"@(#)restart.sh	1.9 91/01/10"
#
#	Copyright (c) 1990 Altos Computer Systems
#	All Rights Reserved 
#
#	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ALTOS	
#	The copyright notice above does not evidence any   
#	actual or intended publication of such source code.
#
#

PATH=/bin:/usr/bin:/etc; export PATH
. /etc/TIMEZONE

trap "rm -f ${PFDATEFILE}; exit 1" 1 2 3 5 15

ARGV0=$0
PFDATEFILE=/tmp/pfdate
RSDATE=`date +"%d %h %H:%M"`
HOST=`cat /etc/systemid`
if [ -s $PFDATEFILE ]
then
	PFDATE=`cat ${PFDATEFILE}`
else
	PFDATE="an unknown time"
fi

if grep VERBOSE=NO /etc/default/boot >/dev/null 2>&1
then
	rclog=/etc/rclog
else
	rclog=/dev/console
fi

set `who -r`
case "$3" in
2|3|4)		# multiuser
	rcdir=/etc/rc${3}.d
	;;
S|s|1|5|6)	# singleuser or shutdown
	rcdir=/etc/rc0.d
	;;
*)		# unknown run level
	echo "${ARGV0}: unknown run level." >>$rclog 2>&1
	exit 1
	;;
esac

if [ -d "$rcdir" ]
then
	for f in ${rcdir}/R*
	do
		if [ -s "$f" ]
		then
			/bin/sh ${f} start >>$rclog 2>&1
		fi
	done
fi

if [ -x /usr/bin/mailx ]
then
su root -c "/usr/bin/mailx -s shutsave-notice root" <<EOF

Notice from ${HOST}:

A power failure had occured at ${PFDATE}, and a shutsave-restart
operation was successfully performed at ${RSDATE}.

root@${HOST}

EOF
fi

rm -f $PFDATEFILE
exit 0


