#!/bin/sh
#
# Coda client installation script
# Made for Linux coda-client rpm distribution 
# Peter J. Braam, Dec 1996
# included suggestions from Elliot Lee, may 1997.
#
# Usage: venus-setup comma,separated,list,of,servers [cachesize in kb]
#
# the script will verify that the necessary directories and /etc/services
# are present.
#


CODAETC=/usr/coda/etc
CACHEDIR=/usr/coda/venus.cache
TMPDIR=/usr/coda/tmp
CACHESIZE=40000
# SERVERS=testserver.coda.cs.cmu.edu


if [ x$RPM_BUILD_ROOT = x ]; then
  CODAROOT=/coda
else
  CODAROOT=$RPM_BUILD_ROOT/coda
fi

if [ $# != 2 ]; then
	echo "Usage: $0 comma,separated,list,of,servers cachesize-in-kb"
	exit 1
else
	SERVERS=$1
	CACHESIZE=$2
fi


# set up the /coda root if it isn't there yet
if [ ! -d $CODAROOT ]; then mkdir -p $CODAROOT; fi
if [ ! -f $CODAROOT/NOT_REALLY_CODA ]; then 
 echo 'If you can see this file, venus is not running.' > \
	$CODAROOT/NOT_REALLY_CODA
fi

# set up a cache directory
if [ ! -d $CACHEDIR ]; then mkdir -p $CACHEDIR; chmod 700 $CACHEDIR; fi
# this tempdir currently must have 755 permissions for hoard verify
if [ ! -d $TMPDIR ]; then mkdir -p $TMPDIR; chmod 755 $TMPDIR; fi

# next run will always initialize
touch $CACHEDIR/INIT

# set up the etc directory with the vstab
if [ ! -d $CODAETC ]; then mkdir -p $CODAETC; fi

if [ -f $CODAETC/vstab ] ; then
    echo "You might want to remove $CODAETC/vstab as we are switching to"
    echo "the @sysconfdir@/venus.conf file for configuring the client."
fi

codaconfedit venus.conf rootservers "$SERVERS"
codaconfedit venus.conf cacheblocks "$CACHESIZE"

# make the psdev
if [ ! -c /dev/coda0 -a ! -c /dev/cfs0 -a ! -c /dev/coda/0 ] ; then
    /dev/MAKEDEV cfs0
fi

# tell the kernel about the new module 
if [ X`uname` = XLinux ]; then 
   if ! grep coda /etc/conf.modules > /dev/null; then
	echo 'alias char-major-67 coda' >> /etc/conf.modules
   fi
   /sbin/depmod -a
fi

# Setup the ports
coda-setup-ports


