prism 2.43 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
#!/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