chiark / gitweb /
Use OpenJDK if java symlink seems broken
[jarrg-ian.git] / jpctb
diff --git a/jpctb b/jpctb
index 4446b2d54d98321961f3f7d6d91ceac080d034a6..e04b95682e39124f03c11e7540da67341a9448bc 100755 (executable)
--- a/jpctb
+++ b/jpctb
@@ -24,7 +24,7 @@
 
 
 usage () { cat <<END
-usage: .../jpctb /path/to/dir/with/PCTB*.jar /path/to/yohoho/yohoho [...]
+usage: .../jpctb /path/to/yohoho/yohoho [...]
 END
 }
 
@@ -32,10 +32,27 @@ fail () {
        echo >&2 "jpctb: $*"
        exit 127
 }
+badusage () {
+       fail "bad usage: $*"
+}
 
-if [ $# -lt 2 ]; then usage; fail 'bad usage'; exit 127; fi
+while [ $# -ge 1 ]; do
+       case "$1" in
+       -)              shift; break;;
+       --jpctb)
+                       shift
+                       srcjardir="$1"
+                       shift || badusage "--jpctb needs a value"
+                       ;;
+       -*)             badusage "unknown option \`$1'"
+                       ;;
+       *)
+                       break
+       esac
+done
+
+if [ $# -lt 1 ]; then usage; badusage "need path to yohoho"; exit 127; fi
 
-srcjardir="$1"; shift
 yohoho="$1"; shift
 
 #---------- find ourselves ----------
@@ -48,16 +65,25 @@ case "$jpctbdir" in
 *)     jpctbdir="$PWD/$jpctbdir" ;;
 esac
 
+if [ x"$srcjardir" = x ]; then
+       srcjardir="$jpctbdir"
+fi
+
 #---------- find YPP client and the Java installation it uses ----------
 
 yppdir="${yohoho%/*}"
 
+openjdk=/usr/lib/jvm/java-6-openjdk
+
 if [ -x "$yppdir/java/bin/java" ]; then
        javadir="$yppdir/java"
 elif [ x"$JAVA_HOME" != x ] && [ -x "$JAVA_HOME/bin/java" ]; then
        javadir="$JAVA_HOME"
+elif [ -x $openjdk/bin/java ]; then
+       javadir=$openjdk
 else
-       fail "could not find java runtime system"
+       fail "could not find java runtime system
+ please check that $yppdir/java points to your Java installation"
 fi
 
 case "$javadir" in