#! /bin/sh
#
# |-----------------------------------------------------------|
# | Copyright (c) 1991, 1990 MIPS Computer Systems, Inc.      |
# | All Rights Reserved                                       |
# |-----------------------------------------------------------|
# |          Restricted Rights Legend                         |
# | Use, duplication, or disclosure by the Government is      |
# | subject to restrictions as set forth in                   |
# | subparagraph (c)(1)(ii) of the Rights in Technical        |
# | Data and Computer Software Clause of DFARS 252.227-7013.  |
# |         MIPS Computer Systems, Inc.                       |
# |         950 DeGuigne Avenue                               |
# |         Sunnyvale, California 94088-3650, USA             |
# |-----------------------------------------------------------|
#
# $Header: rc0,v 1.17.2.1 92/06/24 13:35:47 marker Exp $

#	"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.

# So created files (*.pid, log files, etc) will not be world writable
umask 002

stty sane clocal tab3 2>/dev/null
echo 'The system is coming down.  Please wait.'

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

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

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

trap "" 15
kill -15 -1
sleep 10
/etc/killall  9
sleep 10
sync;sync;sync
set `who -r`
# umount /proc when init 0 but not init 1
if [ "_$7" = "_1" ]; then
	/etc/umount -v -k -t local -D PROC -D fd
else
	/etc/umount -v -k -t local
fi
stty sane clocal 2>/dev/null
sync;  sync
echo '
The system is down.'
sync
