[7481] | 1 | #!/bin/sh
|
---|
| 2 | # Simple wrapper script used to start JOSM in Debian
|
---|
| 3 | set -e
|
---|
| 4 |
|
---|
[10580] | 5 | # First, the alternative (if known to work) or users preference as defined by $JAVA_HOME. Next, use OpenJDK or Oracle's proprietary JDK.
|
---|
[7481] | 6 | # Override to a specific one using $JAVACMD
|
---|
[10580] | 7 | ALTERNATIVE_JDK="`readlink -n -f /etc/alternatives/java`"
|
---|
| 8 |
|
---|
[7481] | 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
|
---|
[8970] | 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"
|
---|
[7481] | 17 | else
|
---|
[8970] | 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"
|
---|
[7481] | 21 | fi
|
---|
| 22 |
|
---|
[10430] | 23 | if [ -f /etc/default/josm-latest ]; then
|
---|
| 24 | . /etc/default/josm-latest
|
---|
| 25 | fi
|
---|
| 26 |
|
---|
[11162] | 27 | JAVA_OPTS="-Djosm.restart=true -Djosm.dir.name=JOSM-latest -Djava.net.useSystemProxies=true $JAVA_OPTS"
|
---|
[7481] | 28 |
|
---|
[8970] | 29 | if [ -z "${JAVACMD}" ]; then
|
---|
| 30 | for jcmd in $JAVA_CMDS; do
|
---|
[10580] | 31 | if [ "z$ALTERNATIVE_JDK" = "z`readlink -n -f $jcmd`" ] && [ -z "${JAVACMD}" ]; then
|
---|
| 32 | JAVACMD="$jcmd"
|
---|
| 33 | break
|
---|
| 34 | fi
|
---|
| 35 | done
|
---|
| 36 | fi
|
---|
| 37 |
|
---|
| 38 | if [ -z "${JAVACMD}" ]; then
|
---|
| 39 | for jcmd in $JAVA_CMDS; do
|
---|
[8970] | 40 | if [ -x "$jcmd" -a -z "${JAVACMD}" ]; then
|
---|
| 41 | JAVACMD="$jcmd"
|
---|
| 42 | break
|
---|
| 43 | fi
|
---|
| 44 | done
|
---|
| 45 | fi
|
---|
[7481] | 46 |
|
---|
| 47 | if [ "$JAVACMD" ]; then
|
---|
| 48 | echo "Using $JAVACMD to execute josm-latest." || true
|
---|
[12591] | 49 | if [[ $JAVACMD == *"java-9"* ]]; then
|
---|
| 50 | JAVA_OPTS="--add-modules java.se.ee $JAVA_OPTS"
|
---|
| 51 | fi
|
---|
[7481] | 52 | set +e
|
---|
| 53 | while true; do
|
---|
| 54 | $JAVACMD $JAVA_OPTS -jar /usr/share/josm-latest/josm-latest.jar "$@"
|
---|
| 55 | if [ "z$?" != "z9" ]; then
|
---|
| 56 | break
|
---|
| 57 | fi
|
---|
| 58 | echo ">> restarting josm..."
|
---|
| 59 | done
|
---|
| 60 | else
|
---|
| 61 | echo "No valid JVM found to run JOSM." || true
|
---|
| 62 | exit 1
|
---|
| 63 | fi
|
---|