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.
|
---|
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-11-openjdk/bin/java /usr/lib/jvm/java-11-openjdk-$ARCH/bin/java"
|
---|
16 | JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-8-openjdk/bin/java /usr/lib/jvm/java-8-openjdk-$ARCH/bin/java"
|
---|
17 | JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-12-openjdk/bin/java /usr/lib/jvm/java-12-openjdk-$ARCH/bin/java"
|
---|
18 | JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-10-openjdk/bin/java /usr/lib/jvm/java-10-openjdk-$ARCH/bin/java"
|
---|
19 | JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-9-openjdk/bin/java /usr/lib/jvm/java-9-openjdk-$ARCH/bin/java"
|
---|
20 | JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-13-openjdk/bin/java /usr/lib/jvm/java-13-openjdk-$ARCH/bin/java"
|
---|
21 | else
|
---|
22 | JAVA_CMDS="$JAVA_HOME/bin/java /usr/bin/java"
|
---|
23 | fi
|
---|
24 |
|
---|
25 | if [ -f /etc/default/josm-latest ]; then
|
---|
26 | . /etc/default/josm-latest
|
---|
27 | fi
|
---|
28 |
|
---|
29 | JAVA_OPTS="-Djosm.restart=true -Djosm.dir.name=JOSM-latest -Djava.net.useSystemProxies=true $JAVA_OPTS"
|
---|
30 |
|
---|
31 | if [ -z "${JAVACMD}" ]; then
|
---|
32 | for jcmd in $JAVA_CMDS; do
|
---|
33 | if [ "z$ALTERNATIVE_JDK" = "z`readlink -n -f $jcmd`" ] && [ -z "${JAVACMD}" ]; then
|
---|
34 | JAVACMD="$jcmd"
|
---|
35 | break
|
---|
36 | fi
|
---|
37 | done
|
---|
38 | fi
|
---|
39 |
|
---|
40 | if [ -z "${JAVACMD}" ]; then
|
---|
41 | for jcmd in $JAVA_CMDS; do
|
---|
42 | if [ -x "$jcmd" -a -z "${JAVACMD}" ]; then
|
---|
43 | JAVACMD="$jcmd"
|
---|
44 | break
|
---|
45 | fi
|
---|
46 | done
|
---|
47 | fi
|
---|
48 |
|
---|
49 | if [ "$JAVACMD" ]; then
|
---|
50 | echo "Using $JAVACMD to execute josm-latest." || true
|
---|
51 | if [ "`expr match \"${JAVACMD}\" 'java-9'`" != "0" ] || [ "`expr match \"${JAVACMD}\" 'java-10'`" != "0" ]; then
|
---|
52 | JAVA_OPTS="--add-modules java.activation,java.se.ee $JAVA_OPTS"
|
---|
53 | elif [ "`expr match \"${JAVACMD}\" 'java-1'`" != "0" ]; then
|
---|
54 | JAVA_OPTS="--add-modules java.scripting,java.sql $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
|
---|