#!/bin/sh
# BLURB gpl
# 
#                            Coda File System
#                               Release 5
# 
#           Copyright (c) 1987-1999 Carnegie Mellon University
#                   Additional copyrights listed below
# 
# This  code  is  distributed "AS IS" without warranty of any kind under
# the terms of the GNU General Public Licence Version 2, as shown in the
# file  LICENSE.  The  technical and financial  contributors to Coda are
# listed in the file CREDITS.
# 
#                         Additional copyrights
#                            none currently
# 
#*/

# ignore SIGHUP
trap "" 1

prefix=/usr
if [ -f /etc/coda/server.conf ] ; then
  . /etc/coda/server.conf
  serverconf=1
else
  serverconf=0
fi

if [ x${vicedir} = x ]; then
  vicedir=/vice
fi

if [ -f ${vicedir}/srv/pid ]; then
    echo "Can't start file server, one is already running!"
    exit 1 
fi 

# Remove outdated logfiles
mv ${vicedir}/srv/SrvErr ${vicedir}/srv/SrvErr.prev 2>/dev/null
rm -f ${vicedir}/srv/SrvLog-7
rm -f ${vicedir}/srv/CRASH

if [ -f ${vicedir}/srv/ZOMBIFY ]; then
    XFLAGS=-zombify
fi

# pass on arguments to srv
# The -rvm flag takes 3 arguments. The first is the log device/file,
# the second is the data segment device/file, and the third is the
# length of the file or device holding the RVM data segment.
# These parameters are taken from ${vicedir}/srv.conf

if [ ${serverconf} = 1 ] ; then
  codasrv $* $XFLAGS
else
  codasrv $* $XFLAGS `grep '^\-rvm ' ${vicedir}/srv.conf`
fi

rm -f ${vicedir}/srv/pid
