#!/bin/sh
#
# $FreeBSD: ports/java/poseidon/files/poseidon.sh.in,v 1.4 2012/11/17 05:58:46 svnexp Exp $

JAVA_HOME=${JAVA_HOME:-"/usr/local/openjdk6"}
POSEIDON_HOME="$HOME/.poseidon"

if [ ! -d "$JAVA_HOME" ] ; then
    echo "Could not find a JDK."
    echo "Either you have to install a JDK (1.4 or up),"
    echo "or you have to set JAVA_HOME to your JDK installation directory."
    exit
fi

JAVACMD="$JAVA_HOME/bin/java"

ulimit -s 2048

cmd="`realpath "$0"`"
echo "Absolute path: $cmd"
instdir="`dirname "$cmd"`"
if [ -n "$1" ] ; then
    project="`realpath "$1"`"
    echo "Project to load: $project"
    loglevel=$2
else
    project=
    loglevel=
fi

cd "$instdir"

CLASSPATH="../lib/poseidon2.jar:../lib/uml14.jar:../lib/printing.jar:../lib/wmf_export.jar:../lib/councurrent_license_server.jar"
CLASSPATH="$CLASSPATH:$JAVA_HOME/jre/lib/rt.jar" # for compilation

export CLASSPATH

# increase memory here, if required (e. g. -Xmx256m)
POSEIDON_ADDITIONAL_JAVA_ARGS="-Xms64m -Xmx160m"
POSEIDON_PLATFORM_JAVA_ARGS=

exec "$JAVACMD" $POSEIDON_PLATFORM_JAVA_ARGS $POSEIDON_ADDITIONAL_JAVA_ARGS -Dposeidon.java.home="$JAVA_HOME" -Dposeidon.user.dir.CE="$POSEIDON_HOME" com.gentleware.poseidon.Poseidon "$project"
