:
#	@(#) rc2.sh 23.1 91/08/29 
#
#	Copyright (C) 1988-1991 The Santa Cruz Operation, Inc.
#		All Rights Reserved.
#	The information in this file is provided for the exclusive use of
#	the licensees of The Santa Cruz Operation, Inc.  Such users have the
#	right to use, modify, and incorporate this code into other products
#	for purposes authorized by the license agreement provided they include
#	this notice and the associated copyright notice with any such product.
#	The information in this file is provided "AS IS" without warranty.
#
#	Copyright (c) 1984, 1986, 1987, 1988 AT&T
#	  All Rights Reserved

#	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
#	The copyright notice above does not evidence any
#	actual or intended publication of such source code.


#	"Run Commands" executed when the system is changing to init state 2,
#	traditionally called "multi-user".

# Begin SCO_BASE
PATH=/etc:/bin:/usr/bin
export PATH
exec < /dev/console > /dev/console 2>&1		# input and output from console
bootlog=/etc/bootlog

# if autoboot is on
[ "$1" = -a ] && {
	AUTOFLAG=-a
	AUTOBOOT="| tee -a $bootlog"	
	BOOTLOG=$bootlog
	export AUTOFLAG AUTOBOOT BOOTLOG

	echo "System autoboot at `date`" >> $BOOTLOG
}

# End SCO_BASE


set `who -r`
if [ "$9" = "S" ]
then
	echo 'The system is coming up.  Please wait.'
	BOOT=yes

elif [ "$7" = "2" ]
then
	echo 'Changing to state 2.'
	if [ -d /etc/rc2.d ]
	then
		for f in /etc/rc2.d/K*
		{
			if [ -s ${f} ]
			then
				/bin/sh ${f} stop
			fi
		}
	fi
fi

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

# PC 6300+ Style Installation - execute rc scripts from driver packages
if [ -d /etc/idrc.d ]
then
	for f in /etc/idrc.d/*
	{
		if [ -s ${f} ]
		then
			/bin/sh ${f}
		fi
	}
fi
if [ "${BOOT}" = "yes" -a -d /etc/rc.d ]
then
	for f in `ls /etc/rc.d`
	{
		if [ ! -d /etc/rc.d/$f -a "$f" != "README" -a ! -s /etc/init.d/${f} ]
		then
			/bin/sh /etc/rc.d/${f} 
		fi
	}
fi

# Begin SCO_BASE
# run /etc/rc script for Xenix compatibility
if [ "${BOOT}" = "yes" -a -s /etc/rc ]
then
	/bin/sh /etc/rc
fi
# End SCO_BASE

if [ "${BOOT}" = "yes" -a "$7" = "2" ]
then
	echo 'The system is ready.'
elif [ "$7" = "2" ]
then
	echo 'Change to state 2 has been completed.'
fi

