#!/bin/csh -f

set net = $rsp/net

clear
echo ""
echo ""
echo "                        Network Utilities"
echo $bar
echo ""
echo ""
echo "New files:"
echo "                /etc/named"
echo "                /etc/named.boot"
echo "                /etc/named.root"
echo "                /etc/named.local"
echo "                /etc/named.mit"
echo "                /etc/resolv.conf"
echo "                /etc/timed"
echo "                /etc/timedc"
echo "                /etc/gettime"
echo "                /etc/snmpd"
echo "                /etc/snmpd.conf"
echo "                /etc/rc.net"
echo "Modified files:"
echo "                /etc/rc.local"
echo "                /etc/services"
echo "                /usr/lib/libc.so.,"
echo "Renamed files:"
echo "                /usr/etc/in.routed -> /usr/etc/in.routed.sun"
echo "                /usr/etc/in.named -> /usr/etc/in.named.sun"
echo "Disk consumed:"
echo "                /usr          540Kb"
echo ""
df /usr
echo ""
get_response "continue? (yes/no) " "yes" "no"
if($status == 2) exit 0

if($sing2 == true) then
	$play $sounds/grooving.au
	sleep 5
	($play $sounds/get_around.au &)
endif

echo ""
echo "Installing... "
install -c -m 555 $net/etc/named /etc/named
install -c -m 444 $net/etc/conf/named.boot /etc/named.boot
install -c -m 444 $net/etc/conf/named.root /etc/named.root
install -c -m 444 $net/etc/conf/named.mit /etc/named.mit
install -c -m 444 $net/etc/conf/resolv.conf /etc/resolv.conf
cp /dev/null /etc/named.local

install -c -m 555 $net/etc/timed /etc/timed
install -c -m 555 $net/etc/timedc /etc/timedc
install -c -m 555 $net/etc/gettime /etc/gettime

install -c -m 555 $net/etc/snmpd /etc/snmpd
install -c -m 444 $net/etc/conf/snmpd.conf /etc/snmpd.conf
if(-f /etc/hosts.equiv) then
	mv /etc/hosts.equiv /etc/hosts.equiv.evil
endif

echo "Making shared library..."
if(! -d /usr/lib/shlib.etc) then
	echo "                Do not have shlib installed!!"
	exit 1
endif

grep res_query /usr/lib/shlib.etc/lorder-sparc > /dev/null
if ($status == 1) then
cd /usr/lib/shlib.etc
mkdir tmp
cd tmp
ar x ../libc_pic.a
rm __.SYMDEF
mv rpc_dtablesize. rpc_dtablesize.o
mv rpc_commondata. rpc_commondata.o
ar x /usr/lib/libresolv.a 
rm gethostent.o
rm strcasecmp.o
cd ..
cp lorder-sparc lorder-sparc.orig
sed "s/gethostent.o/gethostnamadr.o/g" < lorder-sparc.orig > lorder-sparc
ex - lorder-sparc << EOF
	/gethostnamadr.o
	a
	sethostent.o
	res_query.o
	res_mkquery.o
	res_send.o
	res_debug.o
	res_comp.o
	res_init.o
	.
	w
	q
	
EOF

make libc.so
cp libc.so.* /usr/lib
/usr/etc/ldconfig
else
	echo "Looks like you already have dns... good boy."
endif

echo "Renaming..."
if( -f /usr/etc/in.named)  mv /usr/etc/in.named /usr/etc/in.named.sun
if( -f /usr/etc/in.routed) mv /usr/etc/in.routed /usr/etc/in.routed.sun

echo "Updating /etc/services..."
set se = `grep athena-timed /etc/services`
if($status) then
	cat $net/etc/conf/services.add >> /etc/services
endif

echo "Setting up rc..."
sed "s/MITADDR/$network/g" $net/etc/conf/rc.mit.conf | sed "s/MITHOST/`hostname`/g" | sed "s/MACHTYPE/$machine/g" | sed "s/OSTYPE/$os/g"  > /etc/rc.mit.conf

grep "/etc/rc.mit" /etc/rc.local > /dev/null
if($status) cat $net/etc/conf/rc.add >> /etc/rc.local

if( ! -f /etc/rc.local) then
	cp /dev/null /etc/rc.local
endif
cp $net/etc/conf/rc.mit /etc/rc.mit
chmod 755 /etc/rc.mit

grep "MIT Default Netmask" /etc/netmasks > /dev/null
if($status) then
	echo "Default network netmask..."
	cat $net/etc/conf/netmasks.add >> /etc/netmasks
endif

echo "Additional options:"
echo ""
get_response "Replace sendmail config with mit.edu sendmail config? (y/n) " "yes" "no"
if($status == 1) then
	if( -f /etc/sendmail.cf) mv /etc/sendmail.cf /etc/sendmail.cf.old
	cp $net/etc/conf/sendmail.cf /usr/lib/sendmail.cf
	mv /etc/sendmail.cf /etc/sendmail.cf.sun
	mv /usr/lib/aliases /usr/lib/aliases.sun
	cp /dev/null /usr/lib/aliases
	/usr/ucb/newaliases
	/usr/lib/sendmail -bz
endif

get_response "Disable printer daemon? (y/n) " "yes" "no"
if($status  == 1) then
	if( -f /usr/lib/lpd) mv /usr/lib/lpd /usr/lib/lpd.sun
endif

echo ""
echo "These changes will take effect after the next reboot."
get_response "Press <return> to continue..." "<return>"

if($sing == true) then
 	$sounds/kill_song
	$play $sounds/why_am_i_here.au
endif
exit 0



