HELP=0
DEBUG=0
UPDATE=0
+UPDATEUSER=0
+UPDATEINSTALLATION=0
for RAWARG in "${@}"; do
ARG="${RAWARG%%=*}"
case "${ARG}" in
;;
--help|--help-*|--version|-h)
HELP=1
+ HEADLESS=1
;;
--gui)
GUI=1
--debug)
DEBUG=1
;;
- --update)
+ --updateinstallation)
UPDATE=1
+ UPDATEINSTALLATION=1
+ HEADLESS=1
+ ;;
+ --updateuser)
+ UPDATE=1
+ UPDATEUSER=1
+ HEADLESS=1
;;
esac
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
+# args for the JVM
declare -a JVMARGS=()
# set vars for being inside the macos App Bundle
if [ "${HEADLESS}" != 1 ]; then
JVMARGS=( "${JVMARGS[@]}" "-Xdock:icon=${APPDIR}/resource/jalview_logo.png" )
fi
+ # e.g. APPFOLDER=/Applications/Jalview.app
+ APPFOLDER="${APPDIR%%.app/*}.app"
+ VMOPTIONS="${APPFOLDER}/Contents/vmoptions.txt"
else
# NOT MACOS
SCRIPT="$(readlink -f "$0")"
DIR="$(dirname "${SCRIPT}")"
APPDIR="${DIR%/bin}"
JAVA="${APPDIR}/jre/bin/java"
+ # e.g. APPFOLDER=/opt/jalview
+ APPFOLDER="${APPDIR}"
+ VMOPTIONS="${APPDIR}/jalviewg.vmoptions"
fi
+# headless java arguments
if [ "${HEADLESS}" = 1 ]; then
# not setting java.awt.headless in java invocation of running jalview due to problem with Jmol
if [ "${HELP}" = 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}" )
+ CLASSPATH="${GETDOWNJAR}"
+ JARPATHS=( "${JARPATHS[@]}" "${GETDOWNJAR}" )
else
echo "Cannot find getdown-launcher.jar to run update" >&2
exit 13
fi
+ # user-space update
+ if [ "${UPDATEUSER}" = 1 ]; then
+ if [ -e "${VMOPTIONS}" ]; then
+ LINENUM=0
+ while IFS= read -r line; do
+ # remove comments
+ line=${line%%#*}
+ # remove trailing whitespace
+ line="${line%"${line##*[![:space:]]}"}"
+ LINENUM=$((LINENUM+1))
+
+ # add settings for user appdir
+ if [ "${line}" != "${line#-Dsetuserappdirpath=}" ]; then # starts with -Dsetuserappdirpath=
+ JVMARGS=( "${JVMARGS[@]}" "${line}" )
+ fi
+ if [ "${line}" != "${line#-Dnouserdefaultappdir=}" ]; then # starts with -Dnouserdefaultappdir=
+ # don't perform user update if user updates are disabled
+ NOUSERUPDATEVALUE="$(echo "${line#-Dnouserdefaultappdir=}" | tr '[:upper:]' '[:lower:]')"
+ if [ "${NOUSERUPDATEVALUE}" = "true" ]; then
+ echo "Cannot perform manual user-space update when user-space updates are disabled." >&2
+ echo "See line ${LINENUM} (${line}) in file '${VMOPTIONS}'." >&2
+ exit 14
+ fi
+ JVMARGS=( "${JVMARGS[@]}" "${line}" )
+ fi
+ done < "${VMOPTIONS}"
+ fi
+ JVMARGS=( "${JVMARGS[@]}" "-Duserdefaultappdir=true" )
+ fi
+
+ # installation update
+ if [ "${UPDATEINSTALLATION}" = 1 ]; then
+ JVMARGS=( "${JVMARGS[@]}" "-Dnouserdefaultappdir=true" )
+ fi
+
+ # tell getdown to update jalview withouth launching
JVMARGS=( "${JVMARGS[@]}" "-Dsilent=true" )
- JVMARGS=( "${JVMARGS[@]}" "-Dnouserdefaultappdir=true" )
+ JVMARGS=( "${JVMARGS[@]}" "-Dlauncher.script=${SCRIPT}" )
+ JVMARGS=( "${JVMARGS[@]}" "-Dlauncher.update=true" )
JVMARGS=( "${JVMARGS[@]}" "-Dappid=jalview" )
JVMARGS=( "${JVMARGS[@]}" "-Dinstaller.appdir=${APPDIR}" )
# resetting ARGS to just these two values
ARGS=( "${APPDIR}" "jalview" )
-
+ # add these Just In Case although jalview shouldn't be launched
+ ARGS=( "${ARGS[@]}" "--headless" "--quit" "--nojavaconsole" "--nosplash" "--nonews" )
else
# LAUNCHING JALVIEW without getdown-launcher
JVMARGS=( "${JVMARGS[@]}" "-Dinstaller.appdir=${APPDIR}" )
JVMARGS=( "${JVMARGS[@]}" "-Dlauncher.appdir=${APPDIR}" )
JVMARGS=( "${JVMARGS[@]}" "-Dlauncher.script=${SCRIPT}" )
-
fi
# WINDOWS ONLY (Cygwin or WSL)
# change paths for Cygwin or Windows Subsystem for Linux (WSL)
if [ "${ISMACOS}" != 1 ]; then # older macos doesn't like uname -o, best to avoid
- if [ "$(uname -o)" = "Cygwin" ]; then
+ if [ "$(uname -o)" = "Cygwin" ]; then # Cygwin
# CYGWIN
CLASSPATH=$(cygpath -pw "${CLASSPATH}")
# now for some arg paths fun. only translating paths starting with './', '../', '/' or '~'
ARGS=( "${ARGS[@]}" "${ARG}" )
fi
done
- elif uname -r | grep -i microsoft | grep -i wsl >/dev/null; then
+ elif uname -r | grep -i microsoft | grep -i wsl >/dev/null; then # Windows Subsystem for Linux (WSL)
# WSL
CLASSPATH=""
for JARPATH in "${JARPATHS[@]}"; do
fi
fi
-# Is there a bundled Java? If not just try one in the PATH (do need .exe in WSL)
+# Is there a bundled Java? If not just try one in the PATH (we need .exe in WSL, added above)
if [ \! -e "${JAVA}" ]; then
JAVA=$SYSJAVA
- echo "Cannot find bundled java, using system ${JAVA} and hoping for the best!" >&2
+ echo "Cannot find bundled ${JAVA}, using system ${SYSJAVA} and hoping for the best!" >&2
fi
# This is just needed for display purposes
ARGSSTR=$(quotearray "${ARGS[@]}")
if [ "${DEBUG}" = 1 ]; then
- echo Shell running: \""${JAVA}"\" ${JVMARGSSTR} -cp \""${CLASSPATH}"\" "${CLASS}" ${ARGSSTR}
+ echo Shell running: \""${JAVA}"\" ${JVMARGSSTR} -cp \""${CLASSPATH}"\" \""${CLASS}"\" ${ARGSSTR} >&2
fi
"${JAVA}" "${JVMARGS[@]}" -cp "${CLASSPATH}" "${CLASS}" "${ARGS[@]}"