#!/bin/bash
# Startup script for PRISM (Linux/Solaris)
# PRISM home directory
PRISM_DIR="/home/thanasis/Dropbox/elton/elton/prism-4.3-linux64"
# Default value for notification after the scipt has finished (yes/no)
NOTIFY_DEFAULT=no
# Set value for notification
if [ "$NOTIFY" = "" ]; then
NOTIFY=$NOTIFY_DEFAULT
fi;
# Command to launch Java
if [ "$PRISM_JAVA" = "" ]; then
PRISM_JAVA=java
fi
# If there is a -javamaxmem switch, use it for PRISM_JAVAMAXMEM
ARGS=( "$@" )
for ((i=0;i<${#ARGS[@]};i+=1)); do
if [ "${ARGS[$i]}" = "-javamaxmem" ]; then
PRISM_JAVAMAXMEM=${ARGS[$i+1]}
PRISM_JAVAMAXMEM=`echo "$PRISM_JAVAMAXMEM" | awk /^[0-9]+[kmg]?$/`
if [ "$PRISM_JAVAMAXMEM" = "" ]; then
echo; echo "Error: Invalid value for -javamaxmem switch."; exit
fi
fi
done
# Max memory for Java
if [ "$PRISM_JAVAMAXMEM" != "" ]; then
PRISM_JAVAMAXMEM=`echo "$PRISM_JAVAMAXMEM" | awk /^[0-9]+[kmg]?$/`
if [ "$PRISM_JAVAMAXMEM" = "" ]; then
echo; echo "Error: Environment variable PRISM_JAVAMAXMEM is invalid."; exit
fi
PRISM_JAVAMAXMEM="-Xmx$PRISM_JAVAMAXMEM"
else
# default
PRISM_JAVAMAXMEM="-Xmx1g"
fi
PRISM_JAVASTACKSIZE="-Xss4M"
# Set up CLASSPATH:
# - PRISM jar file (for binary versions) (gets priority)
# - classes directory (most PRISM classes)
# - top-level directory (for images, dtds)
# - lib/pepa.zip (PEPA stuff)
# - lib/*.jar (all other jars)
PRISM_CLASSPATH="$PRISM_DIR"/lib/prism.jar:"$PRISM_DIR"/classes:"$PRISM_DIR":"$PRISM_DIR"/lib/pepa.zip:"$PRISM_DIR"/lib/*
# Set up pointers to libraries
PRISM_LIB_PATH="$PRISM_DIR"/lib
# Copy library path to relevant vars
if [ "$LD_LIBRARY_PATH" = "" ]; then
LD_LIBRARY_PATH="$PRISM_LIB_PATH"
else
LD_LIBRARY_PATH="$PRISM_LIB_PATH":$LD_LIBRARY_PATH
fi
JAVA_LIBRARY_PATH="$PRISM_LIB_PATH"
# Export environment variables
export PRISM_DIR LD_LIBRARY_PATH
# Main Java class to launch
if [ "$PRISM_MAINCLASS" = "" ]; then
PRISM_MAINCLASS=prism.PrismCL
fi
# Do we run headless? (GUI overrides this)
if [ "$PRISM_HEADLESS" = "" ]; then
PRISM_HEADLESS=true
fi
# Run PRISM through Java
"$PRISM_JAVA" $PRISM_JAVA_DEBUG $PRISM_JAVAMAXMEM $PRISM_JAVASTACKSIZE -Djava.awt.headless=$PRISM_HEADLESS -Djava.library.path="$JAVA_LIBRARY_PATH" -classpath "$PRISM_CLASSPATH" $PRISM_MAINCLASS "$@"
PRISM_EXIT_CODE=$?
if [ "$NOTIFY" = "yes" ]; then
if [ -n "`which notify-send`" ]; then
notify-send --icon=$PRISM_DIR/etc/icons/prism.ico "PRISM has finished" > /dev/null 2> /dev/null
fi
fi;
exit $PRISM_EXIT_CODE