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 [...]
37 fail "couldn't find the right jre: $*
38 perhaps you should make ypp's java symlink (normally yohoho/java)
39 point to your jre, eg to /usr/lib/jvm/java-6-sun"
46 while [ $# -ge 1 ]; do
52 shift || badusage "--jpctb needs a value"
54 -*) badusage "unknown option \`$1'"
61 if [ $# -lt 1 ]; then usage; badusage "need path to yohoho"; exit 127; fi
65 #---------- find ourselves ----------
68 jpctbdir="${jpctbdir%/*}"
72 *) jpctbdir="$PWD/$jpctbdir" ;;
75 if [ x"$srcjardir" = x ]; then
79 #---------- find YPP client and the Java installation it uses ----------
83 # this replicates the java-searching logic from yohoho/yohoho:
84 if [ -x "$yohoho/java/bin/java" ]; then
85 yppjava="$yohoho/java/bin/java"
86 elif [ -x "$JAVA_HOME/bin/java" ]; then
87 yppjava="$JAVA_HOME/bin/java"
90 yppjava=`type -p java 2>&1`
96 jpctb tree: "$jpctbdir"
101 if ! [ -x "$yppjava" ]; then
105 javadir="${yppjava#/bin/java}"
106 if [ -x "$javadir/jre/bin/java" ]; then
107 echo " java/ points to the jre, good"
109 echo " java/ has just the executable bin/java, trying readlink"
110 absjava=`readlink -f "$yppjava"`
111 echo " abs. java: \"$absjava\""
114 echo " found jre directory, good"
115 javadir="${absjava%/jre/bin/java}"
118 nojre "java binary not in jre dir"
124 ''|/|/usr) nojre "javadir is $javadir (and even found $javadir/jre!)" ;;
126 *) javadir="$PWD/$javadir" ;;
130 linkfarm="$jtmp/linkfarm"
133 export JPCTB_JRE="$javadir/jre"
135 #---------- confirm for the user which paths we're using ----------
140 PCTB jars: "$srcjardir"
141 jpctb tmpdir: "$jtmp"
144 #---------- run the control panel ----------
146 "$javadir/bin/java" -jar "$srcjardir/PCTB-ControlPanel.jar"
148 #---------- create the temporary are and link farm ----------
151 mkdir -- "$jtmp" "$extdir" "$linkfarm"
152 cp "$srcjardir"/PCTB*.jar "$extdir"
154 cp -Rs "$javadir"/. "$linkfarm"/.
156 #---------- edit the linkfarm to have our jvm wrapper ----------
158 wrapper="$linkfarm"/jre/bin/java
161 export JPCTB_EXTDIR="$extdir"
163 cat <<'END' >"$wrapper"
168 lh=`date +'%Y/%m/%d %H:%M:%S jpctb'`
169 printf >&2 "%s: %s |\f\n" "$lh" "$*"
174 #echo >&2 "$djava-wrap
179 yppclass=com.threerings.yohoho.client.YoApp
180 atclass=com.tedpearson.ypp.market.MarketUploader
184 lastarg="${args[$(( $nargs - 1 ))]}"
186 fail () { echo >&2 "jpctb-java: $*"; exit 127; }
188 if [ x"$lastarg" = x"$yppclass" ]; then
190 [ x"$JPCTB_EXTDIR" != x ] || fail 'JPCTB_EXTDIR not set'
192 set -e$JPCTB_JWRAP_X -- \
193 -Djavax.accessibility.assistive_technologies=$atclass \
194 -Djava.ext.dirs="$JPCTB_EXTDIR:$JPCTB_JRE/lib/ext" \
198 real="$JPCTB_JRE/bin/java"
199 log "running $real $*"
203 chmod +x -- "$wrapper"
205 #---------- now run it ----------
207 exec "$yohoho" -Djava.home="$linkfarm/jre"