#!/bin/csh
#***********************************************************
# runPIXConsumer.csh                               R Moulton
# start PIX Consumer actor using default params in 
# runDirectory. Command line arguments:
# 1 = runDirectory path (default is std)
#     NOTE: value 'run' will use std run directory
# 2 = backDirectory path (default is no back Directory)
#     NOTE: value 'back' will use std back directory
#-----------------------------------------------------------
# 12/17/2009 - R Moulton - Original write
#***********************************************************

set SHAKESPEARE_HOME = "/home/rmoult01/workspace/testShakespeare/release"
set APP = "PIXConsumer"
set CLASS = "net.ihe.gazelle.shakespeare.$APP.$APP"
set URL = "http://localhost:6165/PIXConsumer"

#------------------------ must have defined SHAKESPEARE_HOME
if ($?SHAKESPEARE_HOME == 0) then
   echo "variable SHAKESPEARE_HOME not defined"
   exit 1
endif
set ROOT = $SHAKESPEARE_HOME

#---------------------------------------------- runDirectory
set RUNDIR = "run" 
if ("$1" != "") set RUNDIR = "$1"
if ($RUNDIR == run) set RUNDIR = "$ROOT/$APP/runDirectory"

if (-d $RUNDIR == 0) then
   echo "$RUNDIR does not exist or is not a directory"
   exit 1
endif

if (-f "$RUNDIR/${APP}.Directory" == 0) then
   echo "RUNDIR is not a $APP run directory"
   exit 1
endif

#--------------------------------------------- backDirectory
if ("$2" != "") then 
   set BACKDIR = "$2"
   if ($BACKDIR == back) set BACKDIR = "/$ROOT/$APP/backDirectory"

   if ((-d $BACKDIR) == 0) then
      echo "$BACKDIR does not exist or is not a directory"
      exit 1
   endif

   if ((-f "$BACKDIR/${APP}.Directory" == 0) then
      echo "BACKDIR is not a $APP run directory"
      exit 1
   endif
endif

set CP = "."
#----------------------------- validate software directories
set COMMON = $ROOT/common
if ((-d $COMMON) == 0) then
   echo "common library directory $COMMON not found"
   exit 1
endif
foreach jar ($COMMON/*.jar)
   set CP = "${CP}:$jar"
end

set LIB = $ROOT/lib
if ((-d $LIB) == 0) then
   echo "library directory $LIB not found"
   exit 1
endif
foreach jar ($LIB/*.jar)
   set CP = "${CP}:$jar"
end

set BIN = $ROOT/$APP/bin
if (-e $BIN/$APP.jar == 0) then
   echo "$BIN/$APP.jar not found"
   exit 1
endif
set CP = "${BIN}/$APP.jar:$CP"

#------------------------------------------- run application
cd $RUNDIR
java -cp $CP $CLASS -run $RUNDIR -url $URL



   

