#!/bin/sh
# $Header: /afs/athena.mit.edu/astaff/project/layerdev/src/conf/hp/RCS/rc.athena,v 1.6 94/11/01 16:51:22 brlewis Exp $

/var/athena/layer_athena status subsets > /tmp/subsets
if [ -s /tmp/subsets ]; then
	. /tmp/subsets
fi

# Do any post-install steps as necessary
if [ -f /var/athena/rc.install ]; then
	. /var/athena/rc.install
	rm /var/athena/rc.install
fi

if [ -f /etc/athena/rc.conf ]; then
	. /etc/athena/rc.conf
fi

# Reset time with the time hub
if [ "${TIMECLIENT}" = "true" ]; then
	echo ""							>/dev/console
	echo "Setting time: "\\c				>/dev/console
	if [ -f /etc/athena/gettime ]; then
		/etc/athena/gettime -s ${TIMEHUB}		>/dev/console
	else
		echo "Can't set time! gettime not found!"	>/dev/console
	fi
fi

if [ "$afs" ]; then
	sh /usr/vice/etc/dkload/rc.dkload.client

	echo "afsd..."\\c					>/dev/console

        if [ "${TIMESRV}" = "true" -o "${TIMECLIENT}" != "true" ]; then
                AFSOPTS="-nosettime"
        fi
	if [ "${AFSCLIENT}" = "true" ]; then AFSCLIENT=4; fi
	AFSOPTS="${AFSOPTS} -daemons ${AFSCLIENT-4}"

	/usr/vice/etc/afsd ${AFSOPTS}
	cp -p /afs/athena.mit.edu/service/aklog /bin/athena/aklog

	echo "configuring AFS cells..."\\c			>/dev/console
	/etc/athena/config_afs
	echo "done"						>/dev/console
fi

if [ "$basic_services" ]; then
#	echo "setting time..."\\c				>/dev/console
#	/etc/athena/timed &

	echo "zhm..."\\c					>/dev/console
	rm -f /etc/athena/zhm.pid
	/etc/athena/zhm &

	if [ -f /etc/athena/snmpd ]; then
		echo "snmpd..."\\c				>/dev/console
		/etc/athena/snmpd &
	fi

	echo "Removing old attach mount points..."		>/dev/console
	/bin/athena/detach -O -n -h -a 
	echo "done."						>/dev/console
fi

if [ "$basic_services" -a "${RVDCLIENT}" = "true" ]; then
#	echo "Getting cluster information: "\\c			>/dev/console
#	/etc/athena/save_cluster_info
#	if [ -f /etc/athena/clusterinfo.bsh ]; then
#		. /etc/athena/clusterinfo.bsh
#	else
#		echo "no information available..."\\c		>/dev/console
#	fi
#	echo "done."						>/dev/console

#	echo "Attaching system libraries:"			>/dev/console
#	if [ "${USRLIB}" = "" ]; then
#		/bin/athena/attach	 -h -n -o hard $SYSLIB	>/dev/console
#	else
#		/bin/athena/attach	-h -n -o hard $SYSLIB \
#					-h -n -o hard $USRLIB	>/dev/console
#	fi
#	case $? in
#		0)  ;;
#		*)
#		  echo "Can't attach system libraries...continuing" >/dev/console
#		  ;;
#	esac
#	echo "done."						>/dev/console
fi

# # check for update
# NEWVERS=`cat /srvd/.rvdinfo | awk '{print $5}'`
# VERSION=`cat /var/athena/.rvdinfo | awk '{print $5}'`
# if [ "$NEWVERS" != "$VERSION" ]; then
# 	echo "Workstation undergoing Athena software update"	>/dev/console
# 	/var/athena/layer_athena autoupdate 			>&/dev/console
# fi

echo ""								>/dev/console
echo "Fixing noattach, nocreate, noremote, and nologin..."\\c	>/dev/console
if [ "${NOCREATE}" = "true" ]; then
	echo ""\\c >> /etc/nocreate
else
	rm -f /etc/nocreate
fi
if [ "${NOATTACH}" = "true" ]; then
	echo ""\\c >> /etc/noattach
else
	rm -f /etc/noattach
fi
if [ "${NOREMOTE}" = "true" ]; then
	echo ""\\c >> /etc/noremote
else
	rm -f /etc/noremote
fi
