JAL-3830 unix and macos wrappers. Symbolic link to jalviewc-macos in Contents/MacOS...
[jalview.git] / utils / getdown / jalviewc
diff --git a/utils/getdown/jalviewc b/utils/getdown/jalviewc
new file mode 100755 (executable)
index 0000000..a3fa66b
--- /dev/null
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+
+ARG1=$1
+WDIR="$( pwd )"
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
+
+# check to see if $1 is set and is not start of other cli set args
+OPEN=""
+if [ -n "$ARG1" -a "$ARG1" = "${ARG1#-}" -a \! "$ARG1" = "open" ]; then
+ # first argument exists and does not start with a "-" and is not "open"
+ OPEN="-open"
+fi
+
+APPDIR="${DIR}"
+JAVA="${APPDIR}/jre/bin/java"
+GETDOWNTXT="${APPDIR}/getdown.txt"
+if [ -e "$GETDOWNTXT" ]; then
+  CLASSPATH=""
+  for x in $(grep -e 'code = ' "${GETDOWNTXT}" | sed -e 's/^code\s*=\s*//;'); do
+    [ -n "$CLASSPATH" ] && CLASSPATH="${CLASSPATH}:"
+    CLASSPATH="${CLASSPATH}${APPDIR}/${x}"
+  done
+else
+  echo "Cannot find getdown.txt" >&2
+  exit 1
+fi
+
+"$JAVA" -cp "$CLASSPATH" jalview.bin.Launcher $OPEN "$@"