1 | #!/bin/sh
|
---|
2 | # Simple wrapper script used to start JOSM in Debian
|
---|
3 | set -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
|
---|
7 | ALTERNATIVE_JDK="`readlink -n -f /etc/alternatives/java`"
|
---|
8 |
|
---|
9 | # Let's get the current architecture -- needed for multiarchified Java
|
---|
10 | ARCH="`dpkg --print-architecture 2> /dev/null || true`"
|
---|
11 |
|
---|
12 | # If OpenJDK is only available headless, do not try it
|
---|
13 | if 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-10-openjdk/bin/java /usr/lib/jvm/java-10-openjdk-$ARCH/bin/java /usr/lib/jvm/java-10-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"
|
---|
18 | JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-11-openjdk/bin/java /usr/lib/jvm/java-11-openjdk-$ARCH/bin/java /usr/lib/jvm/java-11-oracle/bin/java"
|
---|
19 | else
|
---|
20 | JAVA_CMDS="$JAVA_HOME/bin/java /usr/bin/java"
|
---|
21 | JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-8-oracle/bin/java"
|
---|
22 | JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-10-oracle/bin/java"
|
---|
23 | JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-9-oracle/bin/java"
|
---|
24 | JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-11-oracle/bin/java"
|
---|
25 | fi
|
---|
26 |
|
---|
27 | if [ -f /etc/default/josm-latest ]; then
|
---|
28 | . /etc/default/josm-latest
|
---|
29 | fi
|
---|
30 |
|
---|
31 | JAVA_OPTS="-Djosm.restart=true -Djosm.dir.name=JOSM-latest -Djava.net.useSystemProxies=true $JAVA_OPTS"
|
---|
32 |
|
---|
33 | if [ -z "${JAVACMD}" ]; then
|
---|
34 | for jcmd in $JAVA_CMDS; do
|
---|
35 | if [ "z$ALTERNATIVE_JDK" = "z`readlink -n -f $jcmd`" ] && [ -z "${JAVACMD}" ]; then
|
---|
36 | JAVACMD="$jcmd"
|
---|
37 | break
|
---|
38 | fi
|
---|
39 | done
|
---|
40 | fi
|
---|
41 |
|
---|
42 | if [ -z "${JAVACMD}" ]; then
|
---|
43 | for jcmd in $JAVA_CMDS; do
|
---|
44 | if [ -x "$jcmd" -a -z "${JAVACMD}" ]; then
|
---|
45 | JAVACMD="$jcmd"
|
---|
46 | break
|
---|
47 | fi
|
---|
48 | done
|
---|
49 | fi
|
---|
50 |
|
---|
51 | if [ "$JAVACMD" ]; then
|
---|
52 | echo "Using $JAVACMD to execute josm-latest." || true
|
---|
53 | if [ "`expr match \"${JAVACMD}\" 'java-9'`" != "0" ] || [ "`expr match \"${JAVACMD}\" 'java-10'`" != "0" ]; then
|
---|
54 | JAVA_OPTS="--add-modules java.activation,java.se.ee $JAVA_OPTS"
|
---|
55 | fi
|
---|
56 | set +e
|
---|
57 | while true; do
|
---|
58 | $JAVACMD $JAVA_OPTS -jar /usr/share/josm-latest/josm-latest.jar "$@"
|
---|
59 | if [ "z$?" != "z9" ]; then
|
---|
60 | break
|
---|
61 | fi
|
---|
62 | echo ">> restarting josm..."
|
---|
63 | done
|
---|
64 | else
|
---|
65 | echo "No valid JVM found to run JOSM." || true
|
---|
66 | exit 1
|
---|
67 | fi
|
---|