#!/bin/sh
#
# MDSplus server daemon procedure
#
# This script is just a sample script. You should copy this to a site specific
# directory and modify it to include additional environment variables such as
# tree paths.
#
# Parameters:
#
#       $1 = service or portnumber
#       $2 = log directory (directory must exist)
#       $3 = optional alternate mdsip.hosts file
#       $4 = optional chroot directory
#
if (test "$MDSPLUS_DIR" = "")
then
  MDSPLUS_DIR=/usr/local/mdsplus
  if ( test -r /etc/.mdsplus_dir )
  then
    MDSPLUS_DIR=`/bin/cat /etc/.mdsplus_dir`
  fi
fi
. $MDSPLUS_DIR/setup.sh
$MDSPLUS_DIR/bin/mkdirhier $2
if (test "$4" = "")
then
  exec $MDSPLUS_DIR/bin/mdsip -p $1 -h ${3:-/etc/mdsip.hosts} -c 9 >> $2/access 2>> $2/errors
else
  /usr/sbin/chroot $4 $MDSPLUS_DIR/bin/mdsip -p $1 -h ${3:-/etc/mdsip.hosts} -c 9 >> $2/access 2>> $2/errors
fi
