#!/bin/csh -f
#
# Network Installation Kit
#
# main.client: main program for clients
#
# Tom Coppeto
# MIT Network Group
# 17 September 1994
#
# Last Modified 21 January 1996 by jyp
#

set pltfrm = `/usr/bin/uname`

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

if ($pltfrm == "SunOS") then
	echo "Welcome to the Sun network installation kit. This package will"
else
	echo "Welcome to the SGI network installation kit. This package will"
endif

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

if ($pltfrm == "SunOS") then
	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 ""
else 
	echo "          * SGI Indy version 5.2"
	echo ""
endif
echo ""
echo ""
echo "If you are not running one of these, enter 'q' now"
echo "or press <return> to continue... " 
echo ""
get_response "continue? (<return>/q) " "<return>" "q"
if ($status == 2) exit 0

echo ""


if ($pltfrm == "SunOS") then
	setenv machine SUN4C
else
	setenv machine SGI
endif

setenv host `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}'`

if ($pltfrm == "SunOS") then      # + means do the sun default
	setenv broadcast +
	setenv router ""
endif

# 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

if ($pltfrm == "SunOS") then
	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
endif


echo ""

if ($pltfrm == "SunOS") then
	echo "If this is not true, type 'q' now to exit this installation program."
	echo "or press <return> to continue... "
	echo "" 
	get_response "continue? (<return>/q) " "<return>" "q"
	if ($status == 2) then
		$sounds/kill_song
		$play $sounds/gomer.au
		exit 1
	endif
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:
	if ($pltfrm == "SunOS") then
		$generic/check.client-sunos
	else if ($pltfrm == "IRIX") then
		$generic/check.client-sgi
	endif
	breaksw
 case 2: 
	$toplevel/install.client
	breaksw
 case 3: 
	update.menu
	breaksw
 case 4: 
	if ($pltfrm == "SunOS") then 
		deinstall.client
	else 
		deinstall.menu
	endif
	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 "Additional customizations may be performed in /etc/athena/rc.conf."
	echo "I hope you had a pleasant flight."
	echo ""
	echo "Press 'r' to reboot the machine so that the installation will take effect,"
	echo "or press 'q' to quit from the installation program..."
	echo "" 
	get_response "reboot or quit? (r/q) "  "r" "q"
	if ($status == 1) then
		$util/rebootme
	else 
		if ($status == 2) then
			exit 1
		endif
	endif
	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
























































