#!/bin/sh
# $Header: /afs/athena.mit.edu/astaff/project/layerdev/src/conf/RCS/afs.add,v 1.2 93/07/26 17:56:40 mar Exp $

STATE=$1
SRCDIR=$2

mv /usr/vice /usr/vice.old
ln -s /var/athena/usr/vice /usr/vice

if [ ! -d /usr/vice/cache ]; then
	mkdir /usr/vice/cache
fi

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

rm -f /etc/athena/afsd
cp -p /afs/athena.mit.edu/system/layer/decmipsbin/afsd /etc/athena/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 > 40000) { x = 40000 } ; \
			printf("/afs:/usr/vice/cache:%d\n",x);}' \
	 > /usr/vice/etc/cacheinfo
fi

if [ ! -d /afs ]; then
	mkdir /afs
fi

exit 0
