[7481] | 1 | #!/bin/sh
|
---|
| 2 | # Simple wrapper script used to start JOSM in Debian
|
---|
| 3 | set -e
|
---|
| 4 |
|
---|
| 5 | # First, the alternative (if known to work) or users preference as defined by $JAVA_HOME. Next, use OpenJDK or Oracle's proprietary JDK.
|
---|
| 6 | # Override to a specific one using $JAVACMD
|
---|
| 7 | ALTERNATIVE_JDK="`readlink -n -f /etc/alternatives/java`"
|
---|
| 8 |
|
---|
| 9 | # Let's get the current architecture -- needed for multiarchified Java
|
---|
| 10 | ARCH="`dpkg --print-architecture 2> /dev/null || true`"
|
---|
| 11 |
|
---|
| 12 | # If OpenJDK is only available headless, do not try it
|
---|
| 13 | if dpkg --get-selections 'openjdk-*-jre' | grep install$ > /dev/null ; then
|
---|
[8333] | 14 | JAVA8_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"
|
---|
| 15 | JAVA7_CMDS="$JAVA_HOME/bin/java /usr/lib/jvm/java-7-openjdk/bin/java /usr/lib/jvm/java-7-openjdk-$ARCH/bin/java /usr/lib/jvm/java-7-oracle/bin/java"
|
---|
[7481] | 16 | else
|
---|
[8333] | 17 | JAVA8_CMDS="/usr/lib/jvm/java-8-oracle/bin/java"
|
---|
| 18 | JAVA7_CMDS="$JAVA_HOME/bin/java /usr/lib/jvm/java-7-oracle/bin/java /usr/bin/java"
|
---|
[7481] | 19 | fi
|
---|
| 20 |
|
---|
| 21 | JAVA_OPTS="-Djosm.restart=true -Djosm.home=$HOME/.josm-latest -Djava.net.useSystemProxies=true $JAVA_OPTS"
|
---|
| 22 |
|
---|
[8333] | 23 | for jcmd in $JAVA8_CMDS; do
|
---|
[7481] | 24 | if [ "z$ALTERNATIVE_JDK" = "z`readlink -n -f $jcmd`" ] && [ -z "${JAVACMD}" ]; then
|
---|
| 25 | JAVACMD="$jcmd"
|
---|
| 26 | fi
|
---|
| 27 | done
|
---|
| 28 |
|
---|
[8333] | 29 | for jcmd in $JAVA8_CMDS; do
|
---|
[7481] | 30 | if [ -x "$jcmd" -a -z "${JAVACMD}" ]; then
|
---|
| 31 | JAVACMD="$jcmd"
|
---|
| 32 | fi
|
---|
| 33 | done
|
---|
| 34 |
|
---|
[8333] | 35 | for jcmd in $JAVA7_CMDS; do
|
---|
| 36 | if [ "z$ALTERNATIVE_JDK" = "z`readlink -n -f $jcmd`" ] && [ -z "${JAVACMD}" ]; then
|
---|
| 37 | JAVACMD="$jcmd"
|
---|
| 38 | fi
|
---|
| 39 | done
|
---|
| 40 |
|
---|
| 41 | for jcmd in $JAVA7_CMDS; do
|
---|
| 42 | if [ -x "$jcmd" -a -z "${JAVACMD}" ]; then
|
---|
| 43 | JAVACMD="$jcmd"
|
---|
| 44 | fi
|
---|
| 45 | done
|
---|
| 46 |
|
---|
[7481] | 47 | if [ "$JAVACMD" ]; then
|
---|
| 48 | echo "Using $JAVACMD to execute josm-latest." || true
|
---|
| 49 | set +e
|
---|
| 50 | while true; do
|
---|
| 51 | $JAVACMD $JAVA_OPTS -jar /usr/share/josm-latest/josm-latest.jar "$@"
|
---|
| 52 | if [ "z$?" != "z9" ]; then
|
---|
| 53 | break
|
---|
| 54 | fi
|
---|
| 55 | echo ">> restarting josm..."
|
---|
| 56 | done
|
---|
| 57 | else
|
---|
| 58 | echo "No valid JVM found to run JOSM." || true
|
---|
| 59 | exit 1
|
---|
| 60 | fi
|
---|