#!/bin/csh -f
# Script to update private workstations in the IC
#
#	MIT Interactive Classroom
#
# 	Timothy Wall 8/22/89  v1.0 for system 6.3B
# 	type '/mit/icsys/update_ws' (as root)
#
#       updated 1/19/90 for system 6.4R

set myname = `/bin/hostname`
set VERSION = 7.0F
set OLD_VERSION = 6.4R
echo $myname

if ( `whoami` != root )  then
        echo "You are not root.  This update script must be run as root."
        echo
        exit(1)
endif

if (-r /etc/updated{$VERSION} ) then 
	echo "it appears you already have this update -- icsys"	 
	echo
	exit(1)
endif

/srvd/update_ws

if (-r /etc/updated{$OLD_VERSION} ) then
	rm /etc/updated{$OLD_VERSION}
endif


cp /mit/icsys/motd /etc/motd
switch ($myname)
#######################
# nonstandard adjustments for print daemon in 3-470
#######################
case pl3-470-1:
	echo "setting up pl3-470-1..."			 
	echo "altering rc.conf"				 
	sed -e "s/LPD=false/LPD=true/" /etc/rc.conf > /tmp/rc.conf
	mv /tmp/rc.conf /etc/rc.conf
	echo "copying printcap"				 
	cp /mit/icsys/pl3-470-1/printcap /etc/printcap
	echo "copying ttys"				 
	cp /mit/icsys/pl3-470-1/ttys /etc/ttys
	echo "changing protections on ttyS*"		 
	chmod 666 /dev/ttyS* 
	if (-r /bin/pr) rm /bin/pr
	echo "copying pr"		 
	cp -p /srvd/bin/pr /bin/pr
	echo "running lpd"		 
	/usr/lib/lpd
	echo "done"			 
	breaksw
#######################
# nonstandard adjustments for print daemon in 3-462
#######################
case ic3-462-p:
	echo "setting up ic3-462-p..."		 
	echo "altering rc.conf"		 
	sed -e "s/LPD=false/LPD=true/" /etc/rc.conf > /tmp/rc.conf
	rm /etc/rc.conf
	sed -e "s/TOEHOLD=true/TOEHOLD=false/" /tmp/rc.conf > /etc/rc.conf
	echo "copying passwd.local"		 
	cp /mit/icsys/ic3-462-p/passwd.local /etc/passwd.local
	echo "copying printcap"		 
	cp /mit/icsys/ic3-462-p/printcap /etc/printcap
	echo "copying ttys"		 
	cp /mit/icsys/ic3-462-p/ttys /etc/ttys
	if( -r /bin/pr) rm /bin/pr
	echo "copying pr"		 
	cp -p /srvd/bin/pr /bin/pr
	echo "running lpd"		 
	/usr/lib/lpd
	breaksw
#######################
# nonstandard adjustments for machine no. 6
#######################
case ic3-462-6:
	echo "setting up ic3-462-6..."		 
	echo -n "copying ttys..."		 
	cp /mit/icsys/ic3-462-6and7/ic3-462-6_ttys /etc/ttys
	echo "done"			 
	breaksw
#######################
# nonstandard adjustments for machine no. 7 
#######################
case ic3-462-7:
	echo "setting up ic3-462-7..."		 
	echo -n "copying ttys..."		 
	cp /mit/icsys/ic3-462-6and7/ic3-462-7_ttys /etc/ttys
	echo "done"			 
	breaksw	
#######################
# nonstandard adjustments for machines 2,3,4,5,8,9 and 10
# notice the names are NOT consistently capitalized...
#######################
case IC3-462-2:
case IC3-462-3:
case ic3-462-4:
case ic3-462-5:
case ic3-462-8:
case IC3-462-9:
case IC3-462-10:
	echo "setting up one of ic3-462-2 through 10"	 
	breaksw
	
default:
	echo "no changes to be made to this machine"
	exit(1)
	breaksw
endsw

#######################
# adjustments for rlogins-- all machines
#######################
echo -n "making workstation private..."		 
if (-r /tmp/rc.conf) then
	rm /tmp/rc.conf
endif
sed -e "s/PUBLIC=true/PUBLIC=false/" /etc/rc.conf > /tmp/rc.conf
mv /tmp/rc.conf /etc/rc.conf
echo "done"						 
	
echo -n "turning on access..."				 
echo "altering inetd.conf"		 
if(-r /tmp/inetd.conf) rm /tmp/inetd.conf

###TELNET
sed -e "s/telnet	stream	tcp	nowait	s/telnet	stream	tcp	nowait	uns/" /etc/inetd.conf > /tmp/inetd.conf
rm /etc/inetd.conf

###LOGIN
sed -e "s/login	stream	tcp	nowait	s/login	stream	tcp	nowait	uns/" /tmp/inetd.conf > /etc/inetd.conf
rm /tmp/inetd.conf

###KLOGIN
sed -e "s/klogin	stream	tcp	nowait	s/klogin	stream	tcp	nowait	uns/" /etc/inetd.conf > /tmp/inetd.conf
rm /tmp/inetd.conf

###EKLOGIN
sed -e "s/eklogin	stream	tcp	nowait	s/eklogin	stream	tcp	nowait	uns/" /etc/inetd.conf > /tmp/inetd.conf
rm /tmp/inetd.conf

###ERLOGIN
sed -e "s/erlogin stream  tcp	nowait	s/erlogin stream  tcp	nowait	uns/" /etc/inetd.conf > /tmp/inetd.conf
mv /tmp/inetd.conf /etc/inetd.conf

echo "done"						 
touch /etc/updated{$VERSION}
echo "update complete"					 
