#!/bin/sh
#
# description: DeepMatrix server for VRML multi-user worlds.
#       a future version of this srcript should be able to
#       start and stop a number of servers with different configurations

# some environment variables
# change them according to your requirements.

MATRIXDIR=/projects/dm/dev/DeepMatrix/matrix12
RUNDIR=/var/tmp
JAVA_HOME=/apps/java2/usr/java
RCFILE=matrixrc
export CLASSPATH=.:/apps/java2/usr/java/lib/rt.jar

# See how we were called.
case "$1" in
  start)
        echo -n "Starting DeepMatrix: "
        if test -r $RUNDIR/dm.pid && kill -0 `cat $RUNDIR/dm.pid`
        then echo "already running according to $RUNDIR/dm.pid. Not started."
        else    cd $MATRIXDIR 
                $JAVA_HOME/bin/java matrix.server.MatrixD -rcfile $RCFILE  &
                echo $! > $RUNDIR/dm.pid
                echo "DeepMatrix V1.2"
        fi
        ;;
  stop)
        echo -n "Stopping DeepMatrix: "
        [ -f $RUNDIR/dm.pid ] || exit 0
        kill -TERM `cat $RUNDIR/dm.pid`
        rm -f $RUNDIR/dm.pid
        echo "DeepMatrix"
        ;;
  restart)
        $0 stop
        $0 start
        ;;
  *)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
esac

exit 0

