#!/usr/bin/env bash

# HACK: Next 3 lines needed for seaspray.
# export PATH=$PATH:/opt/groovy/bin
# export JAVA_HOME=/usr/java/latest
# export JAVACMD=$JAVA_HOME/bin/java
# IMPORTANT!! Under the groovy installation verify that startGroovy passes -Duser.timezone="UTC" flag

export JAVA_OPTS="$JAVA_OPTS -Duser.timezone=UTC"
if [ -z $(which groovy) ]
then
  echo "You must install groovy first! Either via homebrew or from http://groovy.codehaus.org/"
else
  APP_HOME=`dirname "$0"`/..

  GSH_CLASSPATH=$APP_HOME/conf:${APP_HOME}/scripts/groovy:$APP_HOME/lib/*

  if [ $# -eq 0 ]
  then
    groovysh -cp "$GSH_CLASSPATH" \
             -Djava.library.path="${APP_HOME}/native" \
             -Duser.timezone="UTC" \
             -Dfile.encoding=UTF8
  else
    groovy -cp "$GSH_CLASSPATH" \
           -Djava.library.path="${APP_HOME}/native" \
           -Duser.timezone="UTC" \
           -Dfile.encoding=UTF8 \
           "$@"
  fi
fi


