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

source install.conf
source $util/aliases

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

clear

echo ""
echo ""
echo "                        MIT Software Installation"
echo $bar
echo ""
echo ""
echo "Welcome to the Sun network installation kit. This package will"
echo "help you install software recommended for use on the MIT campus "
echo "network. You will also have the option to install the Andrew File "
echo "System which will allow you to access many of the file resources"
echo "used by Athena."
echo ""
echo "This installation process presents a series of menus from which you"
echo "select each step. If you have questions or encounter problems, "
echo "call the network help desk, x3-4101."
echo ""
echo ""
echo "Now, on with the show..."
echo ""
echo ""
get_response "Press <return> to continue..." "<return>"

clear
echo ""
echo ""
echo "                             Requirements"
echo $bar
echo ""
echo ""
echo "This installation supports the following: "
echo ""
echo "		* Sun 4c (sparcstation) version 4.1"
echo "		* Sun 4c (sparcstation) version 4.1.1"
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 "		* Tadpole 4m (sparcbook) version 4.1.2"
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 && $release != 4.1.1 && $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



if ($sing == true) $sounds/kill_song

set reset = true

menu:
clear

if($reset == true) then
	if ($sing == true) ($sounds/pick_song &)
else
	set reset = true
endif



echo ""
echo ""
echo "                               Main Menu"
echo $bar
echo ""
echo ""
echo "                      1.   Check network configuration"
echo "                      2.   Installation Menu"
#if(-f $versionfile) then
#	echo "                      3.   Update Menu"
#	echo "                      4.   De-Installation Menu"
#endif
echo ""
echo "                      h    Help on menu choices"
echo "                      q    Quit"
echo ""
echo ""
get_response "Menu choice: " "1" "2" "3" "4"  "help" "quit"

switch ($status)
 case 1:
	$generic/check.client
	breaksw
 case 2: 
	install.client
	breaksw
 case 3: 
	update.menu
	breaksw
 case 4: 
	deinstall.client
	breaksw
 case 5:
	goto help
	breaksw
 case 6:
	if($sing == true) $sounds/kill_song
	sleep 5
	if($sing == true) then
		($play $sounds/happy_trails.au &)	
	endif
	echo ""
	echo "Remember to reboot your machine so any changes take effect."
        echo "Additional customizations may be performed in /etc/athena/rc.conf."
	echo "I hope you had a pleasant flight."
	exit 0
	breaksw
endsw

goto menu


help:

clear
echo ""
echo ""
echo "                          About the Menus"
echo $bar
echo ""
echo ""
echo "Check configuration"
echo ""
echo "This option sanity checks your workstation for proper network"
echo "configuration. Items checked include netmask and routing "
echo "configurations."
echo ""
echo ""
echo "Install Menu"
echo ""
echo "Choose among listed packages you wish to install."
echo ""
echo ""
echo "De-Install Menu"
echo ""
echo "Choose this menu if you wish to remove a package you have previously"
echo "installed."
echo ""
echo ""
echo ""
get_response "Press <return> to continue..." "<return>"

goto menu





