3 # This is jpctb, a wrapper script for plumbing Ted Pearson's Java PCTB
4 # client into a JVM on Linux.
6 # This program is Free Software. Copyright (C) 2009 Ian Jackson.
8 # Permission is hereby granted, free of charge, to any person obtaining a copy
9 # of this software and associated documentation files (the "Software"), to deal
10 # in the Software without restriction, including without limitation the rights
11 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 # copies of the Software, and to permit persons to whom the Software is fur-
13 # nished to do so, subject to the following conditions:
15 # The above copyright notice and this permission notice shall be included in
16 # all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
20 # NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 # XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22 # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
23 # NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 usage: .../jpctb /path/to/dir/with/PCTB*.jar /path/to/yohoho/yohoho [...]
36 if [ $# -lt 2 ]; then usage; fail 'bad usage'; exit 127; fi
41 #---------- find ourselves ----------
44 jpctbdir="${jpctbdir%/*}"
48 *) jpctbdir="$PWD/$jpctbdir" ;;
51 #---------- find YPP client and the Java installation it uses ----------
55 if [ -x "$yppdir/java/bin/java" ]; then
56 javadir="$yppdir/java"
57 elif [ x"$JAVA_HOME" != x ] && [ -x "$JAVA_HOME/bin/java" ]; then
60 fail "could not find java runtime system"
65 *) javadir="$PWD/$javadir" ;;
69 linkfarm="$jtmp/linkfarm"
72 #---------- confirm for the user which paths we're using ----------
76 jpctb tree: "$jpctbdir"
79 PCTB jars: "$srcjardir"
83 #---------- run the control panel ----------
85 "$javadir/bin/java" -jar "$srcjardir/PCTB-ControlPanel.jar"
87 #---------- create the temporary are and link farm ----------
90 mkdir -- "$jtmp" "$extdir" "$linkfarm"
91 cp "$srcjardir"/PCTB*.jar "$extdir"
93 lndir -silent "$javadir" "$linkfarm"
95 #---------- edit the linkfarm to have our jvm wrapper ----------
97 wrapper="$linkfarm"/jre/bin/java
100 export JPCTB_EXTDIR="$extdir"
101 export JPCTB_JRE="$javadir/jre"
103 cat <<'END' >"$wrapper"
108 lh=`date +'%Y/%m/%d %H:%M:%S jpctb'`
109 printf >&2 "%s: %s |\f\n" "$lh" "$*"
114 #echo >&2 "$djava-wrap
119 yppclass=com.threerings.yohoho.client.YoApp
120 atclass=com.tedpearson.ypp.market.MarketUploader
124 lastarg="${args[$(( $nargs - 1 ))]}"
126 fail () { echo >&2 "jpctb-java: $*"; exit 127; }
128 if [ x"$lastarg" = x"$yppclass" ]; then
130 [ x"$JPCTB_EXTDIR" != x ] || fail 'JPCTB_EXTDIR not set'
132 set -e$JPCTB_JWRAP_X -- \
133 -Djavax.accessibility.assistive_technologies=$atclass \
134 -Djava.ext.dirs="$JPCTB_EXTDIR:$JPCTB_JRE/lib/ext" \
138 real="$JPCTB_JRE/bin/java"
139 log "running $real $*"
143 chmod +x -- "$wrapper"
145 #---------- now run it ----------
147 exec "$yohoho" -Djava.home="$linkfarm/jre"