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

STATE=$1
SRCDIR=$2

if [ ! -d /usr/vice ]; then
	mv -f /usr/vice /usr/vice.old
	ln -s /var/athena/usr/vice /usr/vice
fi

test -d /usr/vice/cache || mkdir /usr/vice/cache

if [ ! -d /usr/vice/etc/modload ]; then
	mkdir /usr/vice/etc/modload
	cp -p /afs/athena.mit.edu/system/layer/sun4bin/modload/* /usr/vice/etc/modload
fi

rm -f /usr/vice/etc/afsd
cp -p /afs/athena.mit.edu/system/layer/sun4bin/afsd /usr/vice/etc/afsd

if [ ! -f /usr/vice/etc/cacheinfo ]; then
	(  /bin/df /usr/vice/cache/ ; /bin/du -s /usr/vice/cache/ ) | \
	 /bin/awk ' \
		(NR == 2) { free = $4 + ($3 * y); } \
		(NR == 3) { x = int((free+$1*(1-y)-3000)*3/4); \
			if (x < 2000) { x = 2000 } ; \
			if (x > 100000) { x = 100000 } ; \
			printf("/afs:/usr/vice/cache:%d\n",x);}' \
	 > /usr/vice/etc/cacheinfo
fi

if [ ! -d /afs ]; then
	mkdir /afs
fi
if grep afs /etc/name_to_sysnum >/dev/null; then
  echo "name_to_sysnum is OK " >/dev/console
else
	cat >> /etc/name_to_sysnum << EOF
afs     105
EOF
fi
exit 0
