1 | #!/bin/sh
|
---|
2 | # Simple wrapper script used to start JOSM in Debian
|
---|
3 | set -e
|
---|
4 |
|
---|
5 | # First, users preference as defined by $JAVA_HOME. Next, use OpenJDK or Oracle's proprietary JDK.
|
---|
6 | # Override to a specific one using $JAVACMD
|
---|
7 | # Let's get the current architecture -- needed for multiarchified Java
|
---|
8 | ARCH="`dpkg --print-architecture 2> /dev/null || true`"
|
---|
9 |
|
---|
10 | # If OpenJDK is only available headless, do not try it
|
---|
11 | if dpkg --get-selections 'openjdk-*-jre' | grep install$ > /dev/null ; then
|
---|
12 | JAVA_CMDS="$JAVA_HOME/bin/java"
|
---|
13 | 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"
|
---|
14 | JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-7-openjdk/bin/java /usr/lib/jvm/java-7-openjdk-$ARCH/bin/java /usr/lib/jvm/java-7-oracle/bin/java"
|
---|
15 | 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"
|
---|
16 | else
|
---|
17 | JAVA_CMDS="$JAVA_HOME/bin/java /usr/bin/java"
|
---|
18 | JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-8-oracle/bin/java"
|
---|
19 | JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-7-oracle/bin/java"
|
---|
20 | JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-9-oracle/bin/java"
|
---|
21 | fi
|
---|
22 |
|
---|
23 | if [ -f /etc/default/josm ]; then
|
---|
24 | . /etc/default/josm
|
---|
25 | fi
|
---|
26 |
|
---|
27 | JAVA_OPTS="-Djosm.restart=true -Djava.net.useSystemProxies=true $JAVA_OPTS"
|
---|
28 |
|
---|
29 | if [ -z "${JAVACMD}" ]; then
|
---|
30 | for jcmd in $JAVA_CMDS; do
|
---|
31 | if [ -x "$jcmd" -a -z "${JAVACMD}" ]; then
|
---|
32 | JAVACMD="$jcmd"
|
---|
33 | break
|
---|
34 | fi
|
---|
35 | done
|
---|
36 | fi
|
---|
37 |
|
---|
38 | if [ "$JAVACMD" ]; then
|
---|
39 | echo "Using $JAVACMD to execute josm." || true
|
---|
40 | set +e
|
---|
41 | while true; do
|
---|
42 | $JAVACMD $JAVA_OPTS -jar /usr/share/josm/josm.jar "$@"
|
---|
43 | if [ "z$?" != "z9" ]; then
|
---|
44 | break
|
---|
45 | fi
|
---|
46 | echo ">> restarting josm..."
|
---|
47 | done
|
---|
48 | else
|
---|
49 | echo "No valid JVM found to run JOSM." || true
|
---|
50 | exit 1
|
---|
51 | fi
|
---|