#!/bin/sh

#BASEDIR=`dirname $0`
#BASEDIR=`cd $BASEDIR; pwd`
#
#. $BASEDIR/run_util.sh
#
#JVM_ARGS=""
#JVM_ARGS="$JVM_ARGS -cp build/classes"
#JVM_ARGS="$JVM_ARGS -Djava.util.logging.config.file=util/logging.properties"
#
#url="bootstrap://${SGE_ROOT}@${SGE_CELL}:${SGE_QMASTER_PORT}"
#
#run -d $JVM_ARGS com.sun.grid.jgdi.configuration.xml.XMLDump $url $*
#
################
BASEDIR=`dirname $0`
BASEDIR=`cd $BASEDIR; pwd`

. $BASEDIR/run_util.sh

PRE_ARGS=""
POST_ARGS=""
CSP=0

while [ $# -gt 0 ]; do
  case $1 in
    -v) PRE_ARGS="$PRE_ARGS -v";;
    -d) PRE_ARGS="$PRE_ARGS -d";;
    -j) PRE_ARGS="$PRE_ARGS -j";;
    -csp) CSP=1;;
    *) POST_ARGS="$POST_ARGS $1";;
  esac
  shift
done

if [ $CSP -eq 1 ]; then
   PRE_ARGS="$PRE_ARGS -Djava.security.policy=util/jgdi.policy"
   PRE_ARGS="$PRE_ARGS -Djava.security.auth.login.config==util/jaas.config"
   PRE_ARGS="$PRE_ARGS -Djava.security.manager"
fi


PRE_ARGS="$PRE_ARGS -Djava.util.logging.config.file=util/logging.properties"

#if [ "$SGE_ROOT" != "" ]; then
#   CP=$SGE_ROOT/lib/jgdi.jar
#else
   CP=build/classes
#fi

if [ "$READLINE_JAVA_JAR" != "" ]; then
   CP="$CP:$READLINE_JAVA_JAR"
fi

if [ "$READLINE_LIB_PATH" ]; then
   if [ "$LD_LIBRARY_PATH" = "" ]; then
        LD_LIBRARY_PATH=$READLINE_LIB_PATH 
   else
        LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$READLINE_LIB_PATH"
   fi
fi

POST_ARGS="bootstrap://${SGE_ROOT}@${SGE_CELL}:${SGE_QMASTER_PORT} $POST_ARGS "

echo PRE_ARGS $PRE_ARGS
echo POST_ARGS $POST_ARGS
run $PRE_ARGS -cp $CP -- com.sun.grid.jgdi.configuration.xml.XMLDump $POST_ARGS

