#!/bin/csh -f
#
# Network Installation Kit
#
# main.srvss: main program for systems support servers
#
# Tom Coppeto
# MIT Network Group
# 17 September 1994
#
# $Header: /afs/net.mit.edu/project/netconf/sun4/7.7tom/src/toplevels/RCS/main.srvss,v 1.2 94/09/18 15:56:09 testuser Exp Locker: nocuser $
#

source install.conf
source $util/aliases


#
# fudge variables for server installs
#

setenv preset_notify   $srvssnotify
setenv preset_auto     $srvssauto
setenv preset_contact  $srvsscontact
setenv preset_zinstall $srvsszinstall

setenv preset_afspart $srvsspart
setenv preset_afssize $srvsssize

#
# this if for the second stage of the installation (post-afs)
#

if (-f /etc/mit-stage2) then
	setenv stage2 `awk '{print $2}' /etc/mit-stage2`
	setenv interactive `awk '{print $3}' /etc/mit-stage2`
	rm -f /etc/mit-stage2
	install.srvss
	goto menu
endif


if($sing == true) then
	($play $sounds/tonight.au &)
endif

clear

echo ""
echo ""
echo "               Systems Support Server Software Installation"
echo $bar
echo ""
echo ""
echo "Welcome to the Sun network installation kit. This package will"
echo "bash your machine and make it look like one of our servers."
echo "If you are not installing a server, quit now."
echo ""
echo "It is expected that you have just completed installation of SunOS"
echo "and changed nothing up to this point."
echo ""
get_response "or press <return> to continue... " "<return>" "quit"
if($status == 2) exit 0

clear
echo ""
echo ""
echo "                             Requirements"
echo $bar
echo ""
echo ""
echo "This installation supports the following: "
echo ""
echo "		* Sun 4c (sparcstation) version 4.1.2"
echo "		* Sun 4m (sparcstation) version 4.1.2"
echo "		* Sun 4c (sparcstation) version 4.1.3"
echo "		* Sun 4c (sparcstation) version 4.1.3C"
echo "		* Sun 4c (sparcstation) version 4.1.3_U1"
echo "		* Sun 4m (sparcstation) version 4.1.3"
echo "		* Sun 4m (sparcstation) version 4.1.3C"
echo "		* Sun 4m (sparcstation) version 4.1.3_U1"
echo ""
echo " ** This installation does not work with Solaris 2.0 or later."
echo ""
echo "If you are not running one of these, enter 'q' now"

get_response "or press <return> to continue... " "<return>" "quit"
if($status == 2) exit 0

echo ""
setenv machine SUN4C
setenv host `/bin/hostname`
setenv address `grep $host /etc/hosts | head -1 | awk '{print $1}'`
setenv network `grep $host /etc/hosts | head -1 | awk '{print $1}' | awk '{FS=".";print $1"."$2}'`
# + means do the sun default
setenv broadcast +
setenv router ""

# is this MIT?
if(`echo $network | awk '{FS=".";print $1}'` == 18) then
	switch($network)
		case 18.58:
		case 18.62:
		case 18.63:
		case 18.70:
		case 18.71:
		case 18.72:
		case 18.74:
		case 18.75:
		case 18.78:
		case 18.80:
		case 18.82:
		case 18.83:
		case 18.84:
		case 18.87:
		case 18.88:
		case 18.92:
			setenv broadcast $network.0.0
			breaksw
		default:
			setenv broadcast $network.255.255
			breaksw
	endsw

	setenv router $network.0.1
endif

setenv arch `arch -k`
if($arch != "sun4c" && $arch != "sun4m") then
	echo "Your machine doesn't claim to be a sun 4c."
	exit 1
endif

echo ""
echo -n "* You are $address running SunOS version "
set release = `dmesg | grep "SunOS Release" | tail -1 | awk '{print $3}'`
setenv osversion "SUNOS"$release
echo $release

if($release != 4.1.2 && $release != 4.1.3 && $release != 4.1.3C && $release != 4.1.3_U1) then
	echo "This program does not support your version of the operating system."
	exit 1
endif

echo ""
echo  "If this is not true, type 'q' now to exit this installation program."
get_response "or press <return> to continue... " "<return>" "quit"
if($status == 2) then
	$sounds/kill_song
	$play $sounds/gomer.au
	exit 1
endif


menu:

clear
echo ""
echo ""
echo "                               Main Menu"
echo $bar
echo ""
echo ""
if($interactive == false) then
	echo "                      t.   Step through installation procedure (will automate)"
else
	echo "                      t.   Automate installation procedure (will step)"
endif
echo "                      i.   Installation Menu"
echo "                      q    Quit"
echo ""
echo ""
get_response "Menu choice: " "t" "v" "i" "quit"

switch ($status)
 case 1:
	if($interactive == true) then
		setenv interactive false
	else
		setenv interactive true
	endif
	if($verbose == false && $interactive == true) then
		echo "cannot have a quiet interaction".
		sleep 5
		setenv verbose true
	endif
	breaksw

 case 2:
	if($verbose == true) then
		setenv verbose false
	else
		setenv verbose true
	endif
	if($verbose == false && $interactive == true) then
		echo "cannot have a quiet interaction".
		sleep 5
		setenv verbose true
	endif
	breaksw

 case 3: 
	install.srvss
	breaksw

 case 4:
	if($sing == true) $sounds/kill_song
	sleep 5
	if($sing == true) then
		($play $sounds/happy_trails.au &)	
	endif
	echo ""

	echo "I hope you had a pleasant flight."
	exit 0
	breaksw
endsw

goto menu





