#!/bin/sh
# $Header: /afs/athena.mit.edu/astaff/project/layerdev/src/conf/rsaix/RCS/rc.athena,v 1.2 94/07/18 17:53:13 probe Exp Locker: probe $

/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

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

	echo -n "afsd..."					>/dev/console

	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 -n "configuring AFS cells..."			>/dev/console
	/etc/athena/config_afs
	echo "done"						>/dev/console
fi

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

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

	if [ -f /etc/athena/snmpd ]; then
		echo -n "snmpd..."				>/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 -n "Getting cluster information: "			>/dev/console
	/etc/athena/save_cluster_info
	if [ -f /etc/athena/clusterinfo.bsh ]; then
		. /etc/athena/clusterinfo.bsh
	else
		echo -n "no information available..."		>/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 -n "Fixing noattach, nocreate, noremote, and nologin..."	>/dev/console
if [ "${NOCREATE}" = "true" ]; then
	echo -n "" >> /etc/nocreate
else
	rm -f /etc/nocreate
fi
if [ "${NOATTACH}" = "true" ]; then
	echo -n "" >> /etc/noattach
else
	rm -f /etc/noattach
fi
if [ "${NOREMOTE}" = "true" ]; then
	echo -n "" >> /etc/noremote
else
	rm -f /etc/noremote
fi
