source: josm/trunk/native/linux/tested/usr/bin/josm @ 18160

Last change on this file since 18160 was 18160, checked in by Don-vip, 11 months ago

see #17858 - make Debian/Ubuntu package depend on openjfx and add following JavaFX modules: controls,media,swing,web

  • Property svn:executable set to *
File size: 3.2 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-16-openjdk/bin/java /usr/lib/jvm/java-16-openjdk-$ARCH/bin/java"
22        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-15-openjdk/bin/java /usr/lib/jvm/java-15-openjdk-$ARCH/bin/java"
23        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-14-openjdk/bin/java /usr/lib/jvm/java-14-openjdk-$ARCH/bin/java"
24        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-13-openjdk/bin/java /usr/lib/jvm/java-13-openjdk-$ARCH/bin/java"
25        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-12-openjdk/bin/java /usr/lib/jvm/java-12-openjdk-$ARCH/bin/java"
26        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-10-openjdk/bin/java /usr/lib/jvm/java-10-openjdk-$ARCH/bin/java"
27        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-9-openjdk/bin/java /usr/lib/jvm/java-9-openjdk-$ARCH/bin/java"
28        # Development version(s)
29        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-17-openjdk/bin/java /usr/lib/jvm/java-17-openjdk-$ARCH/bin/java"
30        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-18-openjdk/bin/java /usr/lib/jvm/java-18-openjdk-$ARCH/bin/java"
31fi
32# Undetermined version
33JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/default-java/bin/java /usr/bin/java"
34
35if [ -f /etc/default/josm ]; then
36    . /etc/default/josm
37fi
38
39JAVA_OPTS="-Djosm.restart=true -Djava.net.useSystemProxies=true $JAVA_OPTS"
40
41if [ -z "${JAVACMD}" ]; then
42    for jcmd in $JAVA_CMDS; do
43        if [ "z$ALTERNATIVE_JDK" = "z$(readlink -n -f "$jcmd")" ] && [ -z "${JAVACMD}" ]; then
44            JAVACMD="$jcmd"
45            break
46        fi
47    done
48fi
49
50if [ -z "${JAVACMD}" ]; then
51    for jcmd in $JAVA_CMDS; do
52        if [ -x "$jcmd" ] && [ -z "${JAVACMD}" ]; then
53            JAVACMD="$jcmd"
54            break
55        fi
56    done
57fi
58
59if [ "$JAVACMD" ]; then
60    echo "Using $JAVACMD to execute josm." || true
61    if [[ "${JAVACMD}" =~ 'java-9' ]] || [[ "${JAVACMD}" =~ 'java-10' ]]; then
62        JAVA_OPTS="--add-modules java.activation,java.se.ee $JAVA_OPTS"
63    elif [[ "${JAVACMD}" =~ 'java-1' ]]; then
64        JAVA_OPTS="--add-modules java.scripting,java.sql,javafx.controls,javafx.media,javafx.swing,javafx.web $JAVA_OPTS"
65    fi
66    set +e
67    while true; do
68        $JAVACMD $JAVA_OPTS -jar /usr/share/josm/josm.jar "$@"
69        if [ "z$?" != "z9" ]; then
70            break
71        fi
72        echo ">> restarting josm..."
73    done
74else
75    echo "No valid JVM found to run JOSM." || true
76    exit 1
77fi
Note: See TracBrowser for help on using the repository browser.