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/yohoho/yohoho [...]
39 while [ $# -ge 1 ]; do
45 shift || badusage "--jpctb needs a value"
47 -*) badusage "unknown option \`$1'"
54 if [ $# -lt 1 ]; then usage; badusage "need path to yohoho"; exit 127; fi
58 #---------- find ourselves ----------
61 jpctbdir="${jpctbdir%/*}"
65 *) jpctbdir="$PWD/$jpctbdir" ;;
68 if [ x"$srcjardir" = x ]; then
72 #---------- find YPP client and the Java installation it uses ----------
78 jpctb tree: "$jpctbdir"
82 if [ -x "$yppdir/java/bin/java" ]; then
83 if [ test -d "$yppdir/java/jre" ]; then
84 echo " yohoho/java/bin and yohoho/java/jre exist, good"
85 javadir="$yppdir/java"
87 absjava=`readlink -f "$javadir/bin/java"`
89 yohoho/java/bin exists but yohoho/java/jre does not
94 echo " found jre directory, good"
95 javadir="${absjava%/jre/bin/java}"
98 echo " java binary not in jre dir as expected, hmm."
104 if [ "x$javadir" = x ] && [ x"$JAVA_HOME" != x ] && \
105 [ -x "$JAVA_HOME/bin/java" ]; then
107 yohoho/java/bin/java nonexistent or unsuitable, trying JAVA_HOME"
108 JAVA_HOME: "$JAVA_HOME"
110 if [ -d "$JAVA_HOME/jre" ]; then
113 echo " JAVA_HOME has no jre subdirectory, hmm."
117 openjdk=/usr/lib/jvm/java-6-openjdk
119 if [ "x$javadir" = x ] && [ -x $openjdk/bin/java ]; then
120 echo " using openjdk, hopefully it will work with YPP!"
124 if [ "x$javadir" = x ]; then
125 fail "could not find java runtime system
126 please check that $yppdir/java points to your Java installation"
130 /usr) fail "javadir is still /usr (and even found /usr/jre!)
131 please make $yppdir/java point somewhere more sensible and/or
132 reinstall YPP not telling it your java is in /usr. sorry." ;;
134 *) javadir="$PWD/$javadir" ;;
138 linkfarm="$jtmp/linkfarm"
141 export JPCTB_JRE="$javadir/jre"
143 #---------- confirm for the user which paths we're using ----------
148 PCTB jars: "$srcjardir"
149 jpctb tmpdir: "$jtmp"
152 #---------- run the control panel ----------
154 "$javadir/bin/java" -jar "$srcjardir/PCTB-ControlPanel.jar"
156 #---------- create the temporary are and link farm ----------
159 mkdir -- "$jtmp" "$extdir" "$linkfarm"
160 cp "$srcjardir"/PCTB*.jar "$extdir"
162 cp -Rs "$javadir"/. "$linkfarm"/.
164 #---------- edit the linkfarm to have our jvm wrapper ----------
166 wrapper="$linkfarm"/jre/bin/java
169 export JPCTB_EXTDIR="$extdir"
171 cat <<'END' >"$wrapper"
176 lh=`date +'%Y/%m/%d %H:%M:%S jpctb'`
177 printf >&2 "%s: %s |\f\n" "$lh" "$*"
182 #echo >&2 "$djava-wrap
187 yppclass=com.threerings.yohoho.client.YoApp
188 atclass=com.tedpearson.ypp.market.MarketUploader
192 lastarg="${args[$(( $nargs - 1 ))]}"
194 fail () { echo >&2 "jpctb-java: $*"; exit 127; }
196 if [ x"$lastarg" = x"$yppclass" ]; then
198 [ x"$JPCTB_EXTDIR" != x ] || fail 'JPCTB_EXTDIR not set'
200 set -e$JPCTB_JWRAP_X -- \
201 -Djavax.accessibility.assistive_technologies=$atclass \
202 -Djava.ext.dirs="$JPCTB_EXTDIR:$JPCTB_JRE/lib/ext" \
206 real="$JPCTB_JRE/bin/java"
207 log "running $real $*"
211 chmod +x -- "$wrapper"
213 #---------- now run it ----------
215 exec "$yohoho" -Djava.home="$linkfarm/jre"