source: josm/trunk/linux/tested/usr/bin/josm @ 15914

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

fix #17827 - see #18755 - use Java 14/15 in Linux start script

  • Property svn:executable set to *
File size: 2.9 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.
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
12JAVA_CMDS="$JAVA_HOME/bin/java"
13
14# If OpenJDK is only available headless, do not try it
15if dpkg --get-selections 'openjdk-*-jre' | grep install$ > /dev/null \
16|| dpkg --get-selections 'openjdk-*-jre:$ARCH' | grep install$ > /dev/null ; then
17        # LTS versions in decreased order
18        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-11-openjdk/bin/java /usr/lib/jvm/java-11-openjdk-$ARCH/bin/java"
19        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-8-openjdk/bin/java /usr/lib/jvm/java-8-openjdk-$ARCH/bin/java"
20        # Released versions in decreased order
21        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-14-openjdk/bin/java /usr/lib/jvm/java-14-openjdk-$ARCH/bin/java"
22        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-13-openjdk/bin/java /usr/lib/jvm/java-13-openjdk-$ARCH/bin/java"
23        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-12-openjdk/bin/java /usr/lib/jvm/java-12-openjdk-$ARCH/bin/java"
24        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-10-openjdk/bin/java /usr/lib/jvm/java-10-openjdk-$ARCH/bin/java"
25        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-9-openjdk/bin/java /usr/lib/jvm/java-9-openjdk-$ARCH/bin/java"
26        # Development version
27        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-15-openjdk/bin/java /usr/lib/jvm/java-15-openjdk-$ARCH/bin/java"
28fi
29# Undetermined version
30JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/default-java/bin/java /usr/bin/java"
31
32if [ -f /etc/default/josm ]; then
33    . /etc/default/josm
34fi
35
36JAVA_OPTS="-Djosm.restart=true -Djava.net.useSystemProxies=true $JAVA_OPTS"
37
38if [ -z "${JAVACMD}" ]; then
39    for jcmd in $JAVA_CMDS; do
40        if [ "z$ALTERNATIVE_JDK" = "z`readlink -n -f $jcmd`" ] && [ -z "${JAVACMD}" ]; then
41            JAVACMD="$jcmd"
42            break
43        fi
44    done
45fi
46
47if [ -z "${JAVACMD}" ]; then
48    for jcmd in $JAVA_CMDS; do
49        if [ -x "$jcmd" -a -z "${JAVACMD}" ]; then
50            JAVACMD="$jcmd"
51            break
52        fi
53    done
54fi
55
56if [ "$JAVACMD" ]; then
57    echo "Using $JAVACMD to execute josm." || true
58    if [ "`expr match \"${JAVACMD}\" 'java-9'`" != "0" ] || [ "`expr match \"${JAVACMD}\" 'java-10'`" != "0" ]; then
59        JAVA_OPTS="--add-modules java.activation,java.se.ee $JAVA_OPTS"
60    elif [ "`expr match \"${JAVACMD}\" 'java-1'`" != "0" ]; then
61        JAVA_OPTS="--add-modules java.scripting,java.sql $JAVA_OPTS"
62    fi
63    set +e
64    while true; do
65        $JAVACMD $JAVA_OPTS -jar /usr/share/josm/josm.jar "$@"
66        if [ "z$?" != "z9" ]; then
67            break
68        fi
69        echo ">> restarting josm..."
70    done
71else
72    echo "No valid JVM found to run JOSM." || true
73    exit 1
74fi
Note: See TracBrowser for help on using the repository browser.