source: josm/trunk/linux/latest/usr/bin/josm-latest @ 8970

Last change on this file since 8970 was 8970, checked in by Don-vip, 5 years ago

fix #12033 - Linux: Simplify java alternatives testing in startup scripts (patch by sebastic)

  • Property svn:executable set to *
File size: 2.1 KB
Line 
1#!/bin/sh
2# Simple wrapper script used to start JOSM in Debian
3set -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
7ALTERNATIVE_JDK="`readlink -n -f /etc/alternatives/java`"
8
9# Let's get the current architecture -- needed for multiarchified Java
10ARCH="`dpkg --print-architecture 2> /dev/null || true`"
11
12# If OpenJDK is only available headless, do not try it
13if dpkg --get-selections 'openjdk-*-jre' | grep install$ > /dev/null ; then
14        JAVA_CMDS="$JAVA_HOME/bin/java"
15        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"
16        JAVA_CMDS="${JAVA_CMDS} /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"
17        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"
18else
19        JAVA_CMDS="$JAVA_HOME/bin/java /usr/bin/java"
20        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-8-oracle/bin/java"
21        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-7-oracle/bin/java"
22        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-9-oracle/bin/java"
23fi
24
25JAVA_OPTS="-Djosm.restart=true -Djosm.home=$HOME/.josm-latest -Djava.net.useSystemProxies=true $JAVA_OPTS"
26
27if [ -z "${JAVACMD}" ]; then
28    for jcmd in $JAVA_CMDS; do
29        if [ "z$ALTERNATIVE_JDK" = "z`readlink -n -f $jcmd`" ] && [ -z "${JAVACMD}" ]; then
30            JAVACMD="$jcmd"
31            break
32        fi
33    done
34fi
35
36if [ -z "${JAVACMD}" ]; then
37    for jcmd in $JAVA_CMDS; do
38        if [ -x "$jcmd" -a -z "${JAVACMD}" ]; then
39            JAVACMD="$jcmd"
40            break
41        fi
42    done
43fi
44
45if [ "$JAVACMD" ]; then
46    echo "Using $JAVACMD to execute josm-latest." || true
47    set +e
48    while true; do
49        $JAVACMD $JAVA_OPTS -jar /usr/share/josm-latest/josm-latest.jar "$@"
50        if [ "z$?" != "z9" ]; then
51            break
52        fi
53        echo ">> restarting josm..."
54    done
55else
56    echo "No valid JVM found to run JOSM." || true
57    exit 1
58fi
Note: See TracBrowser for help on using the repository browser.