GUI=0
HELP=0
DEBUG=0
+UPDATE=0
for RAWARG in "${@}"; do
ARG="${RAWARG%%=*}"
case "${ARG}" in
--debug)
DEBUG=1
;;
+ --update)
+ UPDATE=1
+ ;;
esac
-
- if [ "${HELP}" = 1 ]; then
- # --help takes precedence
- HEADLESS=1
- GUI=0
- elif [ "${GUI}" = 1 ]; then
- # --gui takes precedence over --headless
- HEADLESS=0
- fi
done
+if [ "${HELP}" = 1 ]; then
+ # --help takes precedence
+ HEADLESS=1
+ GUI=0
+elif [ "${UPDATE}" = 1 ]; then
+ # --update takes precedence over everything else, we don't run jalview!
+ HEADLESS=1
+ GUI=0
+elif [ "${GUI}" = 1 ]; then
+ # --gui takes precedence over --headless
+ HEADLESS=0
+fi
declare -a JVMARGS=()
# set vars for being inside the macos App Bundle
if [ "${ISMACOS}" = 1 ]; then
# MACOS ONLY
- DIR="$(dirname "$(readlinkf "$0")")"
+ SCRIPT="$(readlinkf "$0")"
+ DIR="$(dirname "${SCRIPT}")"
APPDIR="${DIR%/bin}"
JAVA="${APPDIR}/jre/Contents/Home/bin/java"
- JVMARGS=( "${JVMARGS[@]}" "-Xdock:icon=${APPDIR}/resource/jalview_logo.png" )
+ if [ "${HEADLESS}" != 1 ]; then
+ JVMARGS=( "${JVMARGS[@]}" "-Xdock:icon=${APPDIR}/resource/jalview_logo.png" )
+ fi
else
# NOT MACOS
- DIR="$(dirname "$(readlink -f "$0")")"
+ SCRIPT="$(readlink -f "$0")"
+ DIR="$(dirname "${SCRIPT}")"
APPDIR="${DIR%/bin}"
JAVA="${APPDIR}/jre/bin/java"
fi
SYSJAVA=java
GETDOWNTXT="${APPDIR}/getdown.txt"
+GETDOWNJAR="${APPDIR}/getdown-launcher.jar"
CLASSPATH=""
# save an array of JAR paths in case we're in WSL (see later)
declare -a JARPATHS=()
-if [ -e "${GETDOWNTXT}" ]; then
- # always check grep and sed regexes on macos -- they're not the same
-for JAR in $(grep -e '^code[[:space:]]*=[[:space:]]*' "${GETDOWNTXT}" | while read -r line; do echo $line | sed -E -e 's/code[[:space:]]*=[[:space:]]*//;'; done);
- do
- [ -n "${CLASSPATH}" ] && CLASSPATH="${CLASSPATH}:"
- CLASSPATH="${CLASSPATH}${APPDIR}/${JAR}"
- JARPATHS=( "${JARPATHS[@]}" "${APPDIR}/${JAR}" )
- done
+
+CLASS="jalview.bin.Launcher" # set as default Just In Case
+if [ "${UPDATE}" = 1 ]; then
+
+ # JUST RUNNING A GETDOWN INSTALLATION UPDATE, not launching Jalview
+ CLASS="com.threerings.getdown.launcher.GetdownApp"
+ if [ -e "${GETDOWNJAR}" ]; then
+ CLASSPATH="${APPDIR}/${GETDOWNJAR}"
+ JARPATHS=( "${JARPATHS[@]}" "${APPDIR}/${GETDOWNJAR}" )
+ else
+ echo "Cannot find getdown-launcher.jar to run update" >&2
+ exit 13
+ fi
+
+ JVMARGS=( "${JVMARGS[@]}" "-Dsilent=true" )
+ JVMARGS=( "${JVMARGS[@]}" "-Dnouserdefaultappdir=true" )
+ JVMARGS=( "${JVMARGS[@]}" "-Dappid=jalview" )
+ JVMARGS=( "${JVMARGS[@]}" "-Dinstaller.appdir=${APPDIR}" )
+
+ # resetting ARGS to just these two values
+ ARGS=( "${APPDIR}" "jalview" )
+
else
- echo "Cannot find getdown.txt" >&2
- exit 3
+
+ # LAUNCHING JALVIEW without getdown-launcher
+ CLASS="jalview.bin.Launcher"
+ if [ -e "${GETDOWNTXT}" ]; then
+ # always check grep and sed regexes on macos -- they're not the same
+ for JAR in $(grep -e '^code[[:space:]]*=[[:space:]]*' "${GETDOWNTXT}" | while read -r line; do echo $line | sed -E -e 's/code[[:space:]]*=[[:space:]]*//;'; done);
+ do
+ [ -n "${CLASSPATH}" ] && CLASSPATH="${CLASSPATH}:"
+ CLASSPATH="${CLASSPATH}${APPDIR}/${JAR}"
+ JARPATHS=( "${JARPATHS[@]}" "${APPDIR}/${JAR}" )
+ done
+ else
+ echo "Cannot find getdown.txt" >&2
+ exit 3
+ fi
+
+ COLUMNS=80
+ # get console width -- three ways to try, just in case (not needed for update)
+ if command -v tput 2>&1 >/dev/null; then
+ COLUMNS=$(tput cols) 2>/dev/null
+ elif command -v stty 2>&1 >/dev/null; then
+ COLUMNS=$(stty size | cut -d" " -f2) 2>/dev/null
+ elif command -v resize 2>&1 >/dev/null; then
+ COLUMNS=$(resize -u | grep COLUMNS= | sed -e 's/.*=//;s/;//') 2>/dev/null
+ fi
+
+ JVMARGS=( "${JVMARGS[@]}" "-DCONSOLEWIDTH=${COLUMNS}" )
+ JVMARGS=( "${JVMARGS[@]}" "-Dgetdownappdir=${APPDIR}" )
+ JVMARGS=( "${JVMARGS[@]}" "-Dinstaller.appdir=${APPDIR}" )
+ JVMARGS=( "${JVMARGS[@]}" "-Dlauncher.appdir=${APPDIR}" )
+ JVMARGS=( "${JVMARGS[@]}" "-Dlauncher.script=${SCRIPT}" )
+
fi
# WINDOWS ONLY (Cygwin or WSL)
fi
fi
-# get console width -- three ways to try, just in case
-if command -v tput 2>&1 >/dev/null; then
- COLUMNS=$(tput cols) 2>/dev/null
-elif command -v stty 2>&1 >/dev/null; then
- COLUMNS=$(stty size | cut -d" " -f2) 2>/dev/null
-elif command -v resize 2>&1 >/dev/null; then
- COLUMNS=$(resize -u | grep COLUMNS= | sed -e 's/.*=//;s/;//') 2>/dev/null
-fi
-JVMARGS=( "${JVMARGS[@]}" "-DCONSOLEWIDTH=${COLUMNS}" )
-JVMARGS=( "${JVMARGS[@]}" "-Dgetdownappdir=${APPDIR}" )
-
# Is there a bundled Java? If not just try one in the PATH (do need .exe in WSL)
if [ \! -e "${JAVA}" ]; then
JAVA=$SYSJAVA
echo "Cannot find bundled java, using system ${JAVA} and hoping for the best!" >&2
fi
+# This is just needed for display purposes
function quotearray() {
QUOTEDVALS=""
for VAL in "${@}"; do
ARGSSTR=$(quotearray "${ARGS[@]}")
if [ "${DEBUG}" = 1 ]; then
- echo Shell running: \""${JAVA}"\" ${JVMARGSSTR} -cp \""${CLASSPATH}"\" jalview.bin.Launcher ${ARGSSTR}
+ echo Shell running: \""${JAVA}"\" ${JVMARGSSTR} -cp \""${CLASSPATH}"\" "${CLASS}" ${ARGSSTR}
fi
-"${JAVA}" "${JVMARGS[@]}" -cp "${CLASSPATH}" jalview.bin.Launcher "${ARGS[@]}"
+"${JAVA}" "${JVMARGS[@]}" -cp "${CLASSPATH}" "${CLASS}" "${ARGS[@]}"