#
# This is the Installation CD system startup file.  
# It manages starting up all the necessary servers 
# and ensuring a sane system state.  Once the Installer
# is done it reboots the machine.
#
# Do not edit or change this file.  
#

# ++++++++++
#	function: launch exectuable_path [ thread_to_wait_for ]
# +++++

launch () {
	if [ -f "/boot/$1" ]
	then
		"/boot/$1" &
		[ "$2" != "" ] && waitfor "$2"
		return 1
	else
		echo There is no "$1"
	fi
	return 0
}


#
# First we set up a bunch environment variables that we'll need later.
#

export PATH=:/bin:/boot/beos/apps:/boot/beos/preferences
export HOME=/boot/home
export SHELL=/bin/sh
export USER=ethyl
export GROUP=group

#
# Start only the necessary servers
# 
SERVERS=beos/system/servers
SCRIPTS=beos/system/boot

launch $SERVERS/app_server picasso		# launch app_server
launch $SERVERS/registrar _roster_thread_	# launch registrar
waitfor _input_server_event_loop_			# wait for input devices



#
# Start the Installer
#
APPS=beos/apps

if [ -f /boot/$APPS/Installer ]
then
	/boot/$APPS/Installer
else
	# There is no Installer.  Yowza.
	if [ -f /boot/$APPS/Terminal ]
	then
		/boot/$APPS/Terminal
	else
		echo There is no Terminal.  You are now in a bad spot.
		echo You have our condolences.
	fi
fi

#
# Make sure that everything is flushed.
# 
sync


# 
# reboot in 5 seconds...
#
shutdown -r -q -d 5 &

# ...pop out the cd so we don't boot off of it again.
# Figuring out which device we booted off of is kind of interesting
#
eject  `df | grep ^/boot | awk '{ print $NF }'`
