#! /sbin/sh
#Tag 0x00000f00
#ident "$Revision: 1.29 $"

#	"Run Commands" for init state 0
#	Leaves the system in a state where it is safe to turn off the power
#	or go to firmware.

stty sane tab3 2>/dev/null

if [ -d /etc/rc0.d ]
then
	for f in /etc/rc0.d/K*
	{
		if [ -s ${f} ]
		then
			/sbin/sh ${f} stop
		fi
	}

#	system cleanup functions ONLY (things that end fast!)	

	for f in /etc/rc0.d/S*
	{
		if [ -s ${f} ]
		then
			/sbin/sh ${f} start
		fi
	}
fi

trap "" 15
kill -15 -1
sleep 1
/sbin/killall  9

# unmount anything that didn't get unmounted before.
_DLMNTS=""
if [ "`/sbin/nvram diskless 2> /dev/null`" -eq 1 ] ; then
	_DLMNTS=",/swap,/sbin"
fi
/sbin/umount -ak -b /proc,/debug,/var,/usr,/dev/fd${_DLMNTS}

# install reconfigured kernel
if test -x /unix.install; then
    mv /unix.install /unix
fi

# sometimes one of the umount -k's during shutdown will block, and keep
# / from being umounted cleanly
/sbin/killall umount

sync
