#!/bin/sh # Simple wrapper script used to start JOSM in Debian set -e # First, the alternative (if known to work) or users preference as defined by $JAVA_HOME. Next, use OpenJDK or Oracle's proprietary JDK. # Override to a specific one using $JAVACMD ALTERNATIVE_JDK="`readlink -n -f /etc/alternatives/java`" # Let's get the current architecture -- needed for multiarchified Java ARCH="`dpkg --print-architecture 2> /dev/null || true`" # If OpenJDK is only available headless, do not try it if dpkg --get-selections 'openjdk-*-jre' | grep install$ > /dev/null ; then JAVA_CMDS="$JAVA_HOME/bin/java" JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-8-openjdk/bin/java /usr/lib/jvm/java-8-openjdk-$ARCH/bin/java /usr/lib/jvm/java-8-oracle/bin/java" JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-9-openjdk/bin/java /usr/lib/jvm/java-9-openjdk-$ARCH/bin/java /usr/lib/jvm/java-9-oracle/bin/java" else JAVA_CMDS="$JAVA_HOME/bin/java /usr/bin/java" JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-8-oracle/bin/java" JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-9-oracle/bin/java" fi if [ -f /etc/default/josm-latest ]; then . /etc/default/josm-latest fi JAVA_OPTS="-Djosm.restart=true -Djosm.dir.name=JOSM-latest -Djava.net.useSystemProxies=true $JAVA_OPTS" if [ -z "${JAVACMD}" ]; then for jcmd in $JAVA_CMDS; do if [ "z$ALTERNATIVE_JDK" = "z`readlink -n -f $jcmd`" ] && [ -z "${JAVACMD}" ]; then JAVACMD="$jcmd" break fi done fi if [ -z "${JAVACMD}" ]; then for jcmd in $JAVA_CMDS; do if [ -x "$jcmd" -a -z "${JAVACMD}" ]; then JAVACMD="$jcmd" break fi done fi if [ "$JAVACMD" ]; then echo "Using $JAVACMD to execute josm-latest." || true if [[ $JAVACMD == *"java-9"* ]]; then JAVA_OPTS="--add-modules java.se.ee $JAVA_OPTS" fi set +e while true; do $JAVACMD $JAVA_OPTS -jar /usr/share/josm-latest/josm-latest.jar "$@" if [ "z$?" != "z9" ]; then break fi echo ">> restarting josm..." done else echo "No valid JVM found to run JOSM." || true exit 1 fi