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

Last change on this file since 15916 was 15916, checked in by simon04, 3 months ago

fix #18756 - Fix shellcheck warnings of shellscripts

  • Property svn:executable set to *
File size: 2.9 KB
Line 
1#!/bin/bash
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-latest ]; then
33    . /etc/default/josm-latest
34fi
35
36JAVA_OPTS="-Djosm.restart=true -Djosm.dir.name=JOSM-latest -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" ] && [ -z "${JAVACMD}" ]; then
50            JAVACMD="$jcmd"
51            break
52        fi
53    done
54fi
55
56if [ "$JAVACMD" ]; then
57    echo "Using $JAVACMD to execute josm-latest." || true
58    if [[ "${JAVACMD}" =~ 'java-9' ]] || [[ "${JAVACMD}" =~ 'java-10' ]]; then
59        JAVA_OPTS="--add-modules java.activation,java.se.ee $JAVA_OPTS"
60    elif [[ "${JAVACMD}" =~ 'java-1' ]]; 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-latest/josm-latest.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.