#!/bin/csh -f
#
# Network Installation Kit
#
# check.srvss: make a generic systems support server
#
# Tom Coppeto
# MIT Network Group
# 17 September 1994
#
# Last Modified 28 January 1996 by jyp
#

source $util/aliases

vclear
vecho ""
vecho ""
vecho "                      Check configuration (SS)"
vecho $bar
vecho ""
vecho ""
vecho "Possible modified files:"
vecho "                 /etc/inetd.conf             /etc/rc{.local}"
vecho "                 /etc/athena/update_server"
vecho ""
vecho "Renamed files:"
vecho "			/usr/lib/lpd                /usr/etc/keyserv"
vecho "			/usr/etc/rpc.statd          /usr/etc/rpc.lockd"
vecho ""
vecho ""
vecho ""

if ($interactive == true) then
	vecho "If you would like the modifications to take place automatically,"
	vecho "please select the 'yes' option."
	vecho ""
	vecho "If you do not want any modifications to take place,"
	vecho "please select the 'no' option."
	vecho ""
	vecho "If you only wish to see the list of modifications without"
	vecho "making any changes, use the 'list' option."
	vecho ""
	get_response "continue? (yes/no/list) " "yes" "no" "list" 
        set choice = $status
        if ($choice == 2) then
                exit -1
        else 
                if ($choice == 3) then
                        setenv listonly true
                endif
        endif
endif

vlog "**  running ss server check:"

if (! -d /usr/local/bin) then
	if ($listonly == true) then
		vecho "     The directory /usr/local/bin is not present."
		vecho "        Proposed Change: Create /usr/local/bin"
	else
		mkdir /usr/local/bin
	endif
endif

if ( -f /usr/lib/lpd) then
	if ($listonly == true) then
		vecho "     The file /usr/lib/lpd has been found. Print services must be disabled."	
		vecho "        Proposed Change: Rename /usr/lib/lpd to /usr/lib/lpd.norun"
	else
		vecho "     disabling print services..."
		mv /usr/lib/lpd /usr/lib/lpd.norun
		vlog "     srvss: renamed lpd"
	endif
endif

if ( -f /usr/etc/keyserv) then
	if ($listonly == true) then
		vecho "     The file /usr/etc/keyserv has been found. Keyserv must be disabled." 
		vecho "        Proposed Change: Rename usr/etc/keyserv to /usr/etc/keyserv.norun."
	else
		vecho "     disabling keyserv..."
		mv /usr/etc/keyserv /usr/etc/keyserv.norun
		vlog "     srvss: renamed keyserv"
	endif
endif

if ( -f /usr/etc/rpc.statd || -f /usr/etc/rpc.lockd) then
	if ($listonly == true) then
		vecho "     The file(s) usr/etc/rpc.statd and/or -f /usr/etc/rpc.lockd have been found. Rpc services must be disabled."	
		vecho "        Proposed Change: Rename the above file(s) with the .norun extension."
	else
		vecho "     disabling rpc services..."
		mv -f /usr/etc/rpc.statd /usr/etc/rpc.statd.norun
		mv -f /usr/etc/rpc.lockd /usr/etc/rpc.lockd.norun
		vlog "     srvss: renamed rpc.statd and rpc.lockd"
	endif
endif


#
# sendmail 
#

grep "/usr/lib/sendmail -bd" /etc/rc.local | grep -v \# > /dev/null

if ($status) then
	if ($listonly == true) then
		vecho "     Sendmail needs editing out of rc.local."
	else
		vecho "     sendmail..."
		sed "s:/usr/lib/sendmail -bd:\#       /usr/lib/sendmail  -bd:" /etc/rc.local > /tmp/rc.local
		mv /tmp/rc.local /etc/rc.local
		vlog "     srvss: edited sendmail out of rc.local"
	endif
endif

#
# tcsh
#

if (! -f /bin/athena/tcsh) then 
	if ($listonly == true) then
		vecho "     The file /bin/athena/tcsh is not present."
		vecho "        Proposed Change: Create /bin/athena/tcsh"
	else
		touch /bin/athena/tcsh
	endif
endif

diff /bin/athena/tcsh /usr/athena/bin/tcsh > /dev/null

if ($status) then
	if ($listonly == true) then
		vecho "     A revised tcsh needs to be installed."
		vecho "        Proposed Change: Copy /usr/athena/bin/tsch to /bin/athena/"
	else
		vecho "     installing tcsh..."
		install -c -m 555 /usr/athena/bin/tcsh /bin/athena
		vlog "     srvss: installed tcsh"	
	endif
endif

#
# /tmp
#

fgrep swap /etc/fstab | fgrep tmp > /dev/null
if ($status) then
	if ($listonly == true) then
		vecho "     /tmp needs to be configured as swap."
	else
        	vecho "     /tmp..."
        	echo "swap    /tmp    tmp rw 0 0" >> /etc/fstab
        	vlog "     srvss: configured /tmp/as swap"
	endif
endif

#
# update_server
#
if ($listonly == true) then
	vecho "     Server needs to be updated."
else
	vecho "     update_server..."
	install -c -m 755 /usr/athena/etc/update_server /etc/athena
	vlog "     srvss: installed update_server"
endif


#
# configure version
#

if ($listonly == true) then
	vecho "     Version needs to be updated."
else
	vecho "     updating version..."
	version add SSServer $srvssversion
	echo $srvnetversstr > /etc/athena/version.txt
endif

vlog "srvss: done"

vecho ""


if ($interactive == true) then
	if ($listonly == true) then
		vecho "done with the srvss configuration check. "
		vecho ""
		get_response "Press <return> to go back to the Check menu..." "<return>"
		setenv listonly false
		$generic/check.srvss
	else 
		touch $misc/reboot_flag
		vecho "srvss configuration complete..."
		vecho ""
		get_response "Press <return> to continue..." "<return>"
	endif
else
	touch $misc/reboot_flag
	vecho "done."
endif	
exit 0
















