Revision 8492f7ccdde00f73fe3e49a0c6a58f6e5abf6858 authored by Fabien Campagne on 06 April 2013, 19:47:05 UTC, committed by Fabien Campagne on 06 April 2013, 19:47:05 UTC
1 parent 36d2bb8
Raw File
goby
#!/bin/bash

# This script runs Goby with the specified amount of memory.
# The script will find the Goby jar if it is located in the same directory as this script

# Usage: goby mem-requirement mode-name [param]+
# Where mem-requirement indicates how much memory Goby should be given (e.g., 1g, 500m).
# Mode-name should specify a Goby mode.
# For instance, the following command will display the Goby version number:

#     goby 40m version
 
memory_requirement=$1
shift
other_parameters=$*

WORKING_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [[ $OSTYPE == "cygwin" ]]; then
    WORKING_DIR=`cygpath -m "${WORKING_DIR}"`
fi

GOBY_HOME=${WORKING_DIR}
GOBY_JAR=${GOBY_HOME}/goby.jar
LOG4J_PROPS=file://${GOBY_HOME}/config/log4j-sample.properties
 
if [ "${RJAVA_HOME:-notset}" == "notset" ]; then
  echo "Trying to set RJAVA_HOME environment variable"
  cat >/tmp/r-cmd.txt <<EOT
system.file("jri",package="rJava")
EOT
  tmpWithQuotes=`R --no-save </tmp/r-cmd.txt|grep [1]|tail -1 |awk '{print $2}'`
  temp="${tmpWithQuotes%\"}"
  temp="${temp#\"}"
  echo "$temp"
  export RJAVA_HOME=${temp}
  rm -f /tmp/r-cmd.txt
  echo "RJAVA_HOME=${RJAVA_HOME}"
fi

echo java -ea -Xmx${memory_requirement} -Dlog4j.configuration=${LOG4J_PROPS} -Djava.library.path=${RJAVA_HOME} -jar ${GOBY_JAR} --mode ${other_parameters}
java -ea -Xmx${memory_requirement} -Dlog4j.configuration=${LOG4J_PROPS} -Djava.library.path=${RJAVA_HOME} -jar ${GOBY_JAR} --mode ${other_parameters}
back to top