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 | JAVA9_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"
|
---|
15 | JAVA8_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 | JAVA7_CMDS="$JAVA_HOME/bin/java /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"
|
---|
17 | else
|
---|
18 | JAVA9_CMDS="/usr/lib/jvm/java-9-oracle/bin/java"
|
---|
19 | JAVA8_CMDS="/usr/lib/jvm/java-8-oracle/bin/java"
|
---|
20 | JAVA7_CMDS="$JAVA_HOME/bin/java /usr/lib/jvm/java-7-oracle/bin/java /usr/bin/java"
|
---|
21 | fi
|
---|
22 |
|
---|
23 | JAVA_OPTS="-Djosm.restart=true -Djosm.home=$HOME/.josm-latest -Djava.net.useSystemProxies=true $JAVA_OPTS"
|
---|
24 |
|
---|
25 | for jcmd in $JAVA8_CMDS; do
|
---|
26 | if [ "z$ALTERNATIVE_JDK" = "z`readlink -n -f $jcmd`" ] && [ -z "${JAVACMD}" ]; then
|
---|
27 | JAVACMD="$jcmd"
|
---|
28 | fi
|
---|
29 | done
|
---|
30 |
|
---|
31 | for jcmd in $JAVA8_CMDS; do
|
---|
32 | if [ -x "$jcmd" -a -z "${JAVACMD}" ]; then
|
---|
33 | JAVACMD="$jcmd"
|
---|
34 | fi
|
---|
35 | done
|
---|
36 |
|
---|
37 | for jcmd in $JAVA7_CMDS; do
|
---|
38 | if [ "z$ALTERNATIVE_JDK" = "z`readlink -n -f $jcmd`" ] && [ -z "${JAVACMD}" ]; then
|
---|
39 | JAVACMD="$jcmd"
|
---|
40 | fi
|
---|
41 | done
|
---|
42 |
|
---|
43 | for jcmd in $JAVA7_CMDS; do
|
---|
44 | if [ -x "$jcmd" -a -z "${JAVACMD}" ]; then
|
---|
45 | JAVACMD="$jcmd"
|
---|
46 | fi
|
---|
47 | done
|
---|
48 |
|
---|
49 | for jcmd in $JAVA9_CMDS; do
|
---|
50 | if [ "z$ALTERNATIVE_JDK" = "z`readlink -n -f $jcmd`" ] && [ -z "${JAVACMD}" ]; then
|
---|
51 | JAVACMD="$jcmd"
|
---|
52 | fi
|
---|
53 | done
|
---|
54 |
|
---|
55 | for jcmd in $JAVA9_CMDS; do
|
---|
56 | if [ -x "$jcmd" -a -z "${JAVACMD}" ]; then
|
---|
57 | JAVACMD="$jcmd"
|
---|
58 | fi
|
---|
59 | done
|
---|
60 |
|
---|
61 | if [ "$JAVACMD" ]; then
|
---|
62 | echo "Using $JAVACMD to execute josm-latest." || true
|
---|
63 | set +e
|
---|
64 | while true; do
|
---|
65 | $JAVACMD $JAVA_OPTS -jar /usr/share/josm-latest/josm-latest.jar "$@"
|
---|
66 | if [ "z$?" != "z9" ]; then
|
---|
67 | break
|
---|
68 | fi
|
---|
69 | echo ">> restarting josm..."
|
---|
70 | done
|
---|
71 | else
|
---|
72 | echo "No valid JVM found to run JOSM." || true
|
---|
73 | exit 1
|
---|
74 | fi
|
---|