#!/bin/sh
# $Header: /mit/layerdev/src/conf/decmips/RCS/service.add,v 1.2 1995/08/26 14:28:31 brlewis Exp $

CONFDIR=$1
SRCDIR=$2

if [ ! -d /etc/athena ]; then
	mv -f /etc/athena /etc/athena.old
	ln -s $CONFDIR/etc/athena /etc/athena
fi

if [ ! -d /bin/athena ]; then
	mv -f /bin/athena /bin/athena.old
	ln -s $CONFDIR/bin/athena /bin/athena
fi

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

if [ ! -d /usr/andrew ]; then
	mv -f /usr/andrew /usr/andrew.old
	ln -s $CONFDIR/usr/andrew /usr/andrew
fi

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

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

if [ ! -f /etc/athena/rc.conf ]; then
	cp -p $SRCDIR/rc.conf /etc/athena/rc.conf
fi

cp -p $SRCDIR/rc.athena $CONFDIR
ln -s $CONFDIR/rc.athena /etc/athena
if grep "^	sh $CONFDIR/rc.athena" /etc/rc.local > /dev/null; then
	: echo no
else
	echo "if [ -f $CONFDIR/rc.athena ]; then" >> /etc/rc.local
	echo "	sh $CONFDIR/rc.athena" >> /etc/rc.local
	echo "fi" >> /etc/rc.local
fi

cp -p $SRCDIR/reactivate $CONFDIR
ln -s $CONFDIR/reactivate /etc/athena
if grep reactivate /usr/lib/crontab > /dev/null; then
	: echo no
else
	echo -n '17 * * * * ' >> /usr/lib/crontab
	echo " sh $CONFDIR/reactivate" >> /usr/lib/crontab
fi

if [ -f $CONFDIR/layer_athena ]; then
	mv $CONFDIR/layer_athena $CONFDIR/layer_athena.old
fi
cp -p $SRCDIR/layer_athena $CONFDIR
rm -f $CONFDIR/layer_athena.old

cp -p $SRCDIR/login_athena $CONFDIR

arch=`awk '{print $3}' < $CONFDIR/.rvdinfo`
ver=`awk '{print $5}' < $CONFDIR/.rvdinfo`
echo "Layered Athena $arch Version $ver `date`" >> /etc/athena/version

exit 0
