#!/bin/bash -e # This is jpctb, a wrapper script for plumbing Ted Pearson's Java PCTB # client into a JVM on Linux. # This program is Free Software. Copyright (C) 2009 Ian Jackson. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is fur- # nished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- # NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- # NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. usage () { cat <&2 "jpctb: $*" exit 127 } badusage () { fail "bad usage: $*" } 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 yohoho="$1"; shift #---------- find ourselves ---------- jpctbdir="$0" jpctbdir="${jpctbdir%/*}" 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%/*}" if [ -x "$yppdir/java/bin/java" ]; then javadir="$yppdir/java" elif [ x"$JAVA_HOME" != x ] && [ -x "$JAVA_HOME/bin/java" ]; then javadir="$JAVA_HOME" else fail "could not find java runtime system" fi case "$javadir" in /*) ;; *) javadir="$PWD/$javadir" ;; esac jtmp="$jpctbdir/tmp" linkfarm="$jtmp/linkfarm" extdir="$jtmp/ext" #---------- confirm for the user which paths we're using ---------- cat <"$wrapper" #!/bin/bash set -e$JPCTB_JWRAP_X log () { lh=`date +'%Y/%m/%d %H:%M:%S jpctb'` printf >&2 "%s: %s |\f\n" "$lh" "$*" } log "invoked as $*" #echo >&2 "$djava-wrap #exec 4>>/home/ian/u #date >&4 #exec 4>&- yppclass=com.threerings.yohoho.client.YoApp atclass=com.tedpearson.ypp.market.MarketUploader args=( "$@" ) nargs=${#args[*]} lastarg="${args[$(( $nargs - 1 ))]}" fail () { echo >&2 "jpctb-java: $*"; exit 127; } if [ x"$lastarg" = x"$yppclass" ]; then [ x"$JPCTB_EXTDIR" != x ] || fail 'JPCTB_EXTDIR not set' set -e$JPCTB_JWRAP_X -- \ -Djavax.accessibility.assistive_technologies=$atclass \ -Djava.ext.dirs="$JPCTB_EXTDIR:$JPCTB_JRE/lib/ext" \ "$@" fi real="$JPCTB_JRE/bin/java" log "running $real $*" exec "$real" "$@" END chmod +x -- "$wrapper" #---------- now run it ---------- exec "$yohoho" -Djava.home="$linkfarm/jre"