771d15ba9e734d74ce76499527727fc2dfb87d17
[jalview.git] / utils / install4j / macos_jalview
1 #!/usr/bin/env bash
2
3 ARG1=$1
4 WDIR="$( pwd )"
5 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
6 APP=${DIR%/Contents/MacOS}
7
8 if [ "${APP}" = "${APP%.app}" ]; then
9   echo "Could not find .app dir" >&2
10   exit 1
11 fi
12
13 # check to see if $1 is set and is not start of other cli set args
14 OPEN=""
15 if [ -n "$ARG1" -a "$ARG1" = "${ARG1#-}" ]; then
16  # first argument exists and does not start with a "-"
17  OPEN="-open"
18 fi
19
20 # This would open the Jalview application as if double clicking, with the supplied args
21 # open -a ${APP} --args $OPEN "$@"
22 ### or...
23
24 APPDIR=${APP}/Contents/Resources/app
25 JAVA=${APPDIR}/jre/Contents/Home/bin/java
26 CLASSPATH=""; for x in $(grep -e 'code = ' ${APP}/Contents/Resources/app/getdown.txt | sed -e 's/^code = //;'); do [ -n "$CLASSPATH" ] && CLASSPATH="${CLASSPATH}:"; CLASSPATH="${CLASSPATH}${APPDIR}/${x}"; done
27
28 #TODO add a -workingdir DIR argument for jalview.bin.Jalview to set user.dir. This will fix JAL-3523
29 echo $JAVA -cp "$CLASSPATH" jalview.bin.Launcher $OPEN "$@"
30 $JAVA -cp "$CLASSPATH" jalview.bin.Launcher $OPEN "$@"
31 # -workingdir "$WDIR"