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

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

fix #15233 - Fix bashism in josm launcher (patch by sebastic)

  • Property svn:executable set to *
File size: 2.0 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-9-openjdk/bin/java /usr/lib/jvm/java-9-openjdk-$ARCH/bin/java /usr/lib/jvm/java-9-oracle/bin/java"
17else
18        JAVA_CMDS="$JAVA_HOME/bin/java /usr/bin/java"
19        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-8-oracle/bin/java"
20        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-9-oracle/bin/java"
21fi
22
23if [ -f /etc/default/josm ]; then
24    . /etc/default/josm
25fi
26
27JAVA_OPTS="-Djosm.restart=true -Djava.net.useSystemProxies=true $JAVA_OPTS"
28
29if [ -z "${JAVACMD}" ]; then
30    for jcmd in $JAVA_CMDS; do
31        if [ "z$ALTERNATIVE_JDK" = "z`readlink -n -f $jcmd`" ] && [ -z "${JAVACMD}" ]; then
32            JAVACMD="$jcmd"
33            break
34        fi
35    done
36fi
37
38if [ -z "${JAVACMD}" ]; then
39    for jcmd in $JAVA_CMDS; do
40        if [ -x "$jcmd" -a -z "${JAVACMD}" ]; then
41            JAVACMD="$jcmd"
42            break
43        fi
44    done
45fi
46
47if [ "$JAVACMD" ]; then
48    echo "Using $JAVACMD to execute josm." || true
49    if [ "`expr match \"${JAVACMD}\" 'java-9'`" != "0" ]; then
50        JAVA_OPTS="--add-modules java.se.ee $JAVA_OPTS"
51    fi
52    set +e
53    while true; do
54        $JAVACMD $JAVA_OPTS -jar /usr/share/josm/josm.jar "$@"
55        if [ "z$?" != "z9" ]; then
56            break
57        fi
58        echo ">> restarting josm..."
59    done
60else
61    echo "No valid JVM found to run JOSM." || true
62    exit 1
63fi
Note: See TracBrowser for help on using the repository browser.