1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436
|
#!/bin/sh
##
## Files we write must be world readable so that httpd can get them
## and writeable so that whoever starts the server next can clean up.
##
umask 1
if [ "$DXROOT" = "" ]; then
DXROOT=@prefix@/dx
fi
export DXROOT
##
## both java and dx script need to be in the path
## we know where they are, so don't take any chances
## override by having PATH intercept your preferred "java" vm or
## custom dx script first.
##
PATH=$PATH:@prefix@/dx/bin
export PATH
if [ "$CLASSPATH" = "" ]; then
CLASSPATH=@DX_JAVA_CLASSPATH@:./:./server.jar
else
CLASSPATH=$CLASSPATH:@DX_JAVA_CLASSPATH@:./:./server.jar
fi
export CLASSPATH
##
## We're interested in the location of the script file so that
## we can make an attempt at avoiding the use of DXROOT for
## finding the location of our .class files. We'll assume
## that the script lives in installDir/java/server/bin
## and that our class directory is found relative to that
## via ../class. That will be a default value for serverdir.
## If it doesn't work, then we'll fall back to DXROOT/java/server/class
##
## ...so if the startserver script is copied outside of the install tree
## AND the install tree isn't part of DXROOT, then the startserver
## script won't work.
##
bindir=`dirname $0`
default_serverdir=""
if [ -r $bindir/../class/DXServer.class ]; then
default_serverdir=$bindir/../class
else
default_serverdir=$DXROOT/java/server/class
fi
##
## Parse cmd line args
##
aarg=""
webpage=""
help=""
morehelp=""
dbg_args=""
verbose=""
version=""
foreground=""
outdir=""
outloc=""
outurl=""
memory=""
dxroot=""
user=""
sessions=""
numargs="0"
shared_obj=""
while [ ! "$*" = "" ]; do
case $1 in
-debug) aarg="${aarg} -d"; dbg_args="-DDXServerThread.debug -DDXServer.debug";;
-d) aarg="${aarg} -d"; dbg_args="-DDXServerThread.debug -DDXServer.debug";;
-dxroot) aarg="${aarg} -dxroot $2"; dxroot=$2; shift ;;
-dxlib) shared_obj="${shared_obj} -Djx.lib=$2"; shift ;;
-foreground) aarg="${aarg} -fg"; foreground="1";;
-fg) aarg="${aarg} -fg"; foreground="1";;
-help) help="1";;
-h) help="1";;
-memory) aarg="${aarg} -m $2"; memory=$2; shift;;
-m) aarg="${aarg} -m $2"; memory=$2; shift;;
-morehelp) help="1"; morehelp="1";;
-outdir) aarg="${aarg} -od $2"; outdir=-DDXServer.outDir=$2 ; outloc=$2 ; shift ;;
-od) aarg="${aarg} -od $2"; outdir=-DDXServer.outDir=$2 ; outloc=$2 ; shift ;;
-outurl) aarg="${aarg} -outurl $2"; outurl=-DDXServer.outUrl=$2 ; shift ;;
-sessions) aarg="${aarg} -s $2"; sessions=-DDXServer.max_sessions=$2; shift ;;
-s) aarg="${aarg} -s $2"; sessions=-DDXServer.max_sessions=$2; shift ;;
-user) user=$2; shift ;;
-verbose) aarg="${aarg} -v"; verbose="1";;
-v) aarg="${aarg} -v"; verbose="1";;
-version) version="1";;
-webpage) aarg="${aarg} -w $2"; webpage="$2"; shift ;;
-w) aarg="${aarg} -w $2"; webpage="$2"; shift ;;
*) echo Unknown option $1; help="1" ;;
esac
numargs="nonzero"
shift
done
if [ "$user" != "" ]; then
su $user -c "$0 ${aarg}"
exit 0;
fi
if [ "$version" = "1" ]; then
echo Java Explorer startup script version 1.0.0
exit 0
fi
if [ "$help" = "1" ]; then
echo "Format: startserver [ -webpage htmlfile | [ -outdir dir -outurl url ]] [ -help ] [ -debug ] [ -verbose ] [ -memory Mbytes ] [ -dxroot dir ] [ -user user ]"
echo " -webpage.......complete path of a Java Explorer web page"
echo " -outdir........directory into which new images should be written"
echo " -outurl........url of the -outdir argument relative to the document base"
echo " -help..........this message"
echo " -debug.........print message traffic"
echo " -verbose.......print cmd line args passed to DXServer"
echo " -version.......the software version number of this script"
echo " -foreground....run in the foreground in order to satisfy init"
echo " -memory........set the amount of memory dxexec uses."
echo " -dxroot........use dir as DXROOT"
echo " -user..........run the script under a different user id"
echo " -sessions......max number of simultaneous Data Explorer sessions (default: 1)"
echo " -morehelp......examples"
echo ""
echo "Format: stopserver [ host ]"
echo " host..........the host machine of the DXServer. (default: localhost)"
echo ""
if [ "$morehelp" = "1" ]; then
echo ""
echo " Example 1)"
echo " You have just unpacked the Java Explorer software and "
echo " have no httpd. Point your browser at a url beginning "
echo " with file:/ and start DXServer like this:"
echo " $ startserver"
echo " "
echo " Example 2)"
echo " Your httpd program supplies files underneath /usr/http. "
echo " You unpacked Java Explorer on a machine named foobar in "
echo " /usr/http. Point your browser at "
echo " http://foobar/java/htmlpages/Status.html and start DXServer"
echo " like this:"
echo " $ startserver -webpage /usr/http/java/htmlpages/Status.html"
echo " "
echo " Example 3)"
echo " Your collection of web pages created with Java Explorer "
echo " is served by an http program. Your web site is rooted "
echo " at /usr/http/sitedir. You have created "
echo " /usr/http/sitedir/output as a location into which Data "
echo " Explorer can write image files. You point your browser at "
echo " http://foobar/sitedir/yourpage.html and start DXServer like "
echo " this:"
echo " $ startserver -webpage /usr/http/sitedir/yourpage.html"
echo " or"
echo " $ startserver -outdir /usr/http/sitedir/output -outurl output"
echo " The purpose of the -outdir and -outurl arguments is to accommodate"
echo " web pages on read-only file systems. They shouldn't be used"
echo " otherwise."
echo ""
echo " Example 4)"
echo " You created web pages using Java Explorer and want DXServer"
echo " available all the time. Your machine has an inittab entry"
echo " for an http daemon. Make a similar entry for startserver:"
echo " javadx:2:respawn:startserver -user guest -dxroot /usr/lpp/dx \ "
echo " -webpage /usr/http/java/htmlpages/Status.html -foreground"
echo " > /tmp/jx.log 2>&1"
echo ""
echo " Example 5)"
echo " You have several collections of web pages served by one DXServer."
echo " Your http daemon accesses files underneath the the directory"
echo " /usr/http. Start DXServer like this:"
echo " $ startserver -outdir /usr/http/output -outurl /output"
echo ""
echo ""
echo " Installation Tips"
echo " 1) The directory - java/htmlpages - within this distribution belongs"
echo " in an area accessible to an http daemon. Since these areas are "
echo " typically public, you probably will want the java/server directory "
echo " to reside somewhere else. This should be taken care of by the"
echo " Java Explorer installation script, however there is no such script"
echo " as of 6/98."
echo ""
echo " 2) You should be able to start the DXServer using startserver with no"
echo " arguments (as in Example 1) if you simply uncompress and untar the "
echo " distribution."
echo ""
echo " 3) The organizations which provide browsers, plug-ins and development"
echo " tools maintain sites from which you can download recent releases"
echo " of their products. See java/htmlapges/Status.html for pointers."
fi
exit 0
fi
##
## E R R O R C H E C K I N G
## E R R O R C H E C K I N G
## E R R O R C H E C K I N G
##
##
## Test for an executable java and dx commands
##
jcmd=`type java | sed -e 's/java is //g'`
if [ ! -x $jcmd ] ; then
echo Error: no java command in PATH
exit 1;
fi
jcmd=`type dx | sed -e 's/dx is //g'`
if [ ! -x "$jcmd" ] ; then
if [ "$dxroot" = "" ]; then
PATH=${PATH}:$DXROOT/bin
else
PATH=${PATH}:$dxroot/bin
fi
jcmd=`type dx | sed -e 's/dx is //g'`
fi
if [ ! -x "$jcmd" ] ; then
echo Error: no dx command in PATH
exit 1;
fi
##
##
## default case, startserver w/o args, use default samples installation for webpage option
##
if [ "$numargs" = "0" ] ; then
webpage=@prefix@/dx/java/htmlpages/Status.html
echo "no arguments to startserver, you may wish to use startserver -help for options"
echo "proceeding as if you invoked startserver with installation defaults"
echo "startserver -webpage $webpage "
fi
##
## If -webpage is specified, is it readable?
##
if [ "$webpage" != "" ]; then
if [ ! -r $webpage ]; then
echo Error: -webpage option $webpage is not readable.
exit 1;
fi
fi
##
## - You can't specify webpage if you specified outdir
## - You must specify outurl if you did specify outdir
##
if [ "$outdir" != "" ]; then
if [ "$webpage" != "" ]; then
echo Error: You can not specify both -outdir and -webpage.
exit 1;
fi
if [ "$outurl" = "" ]; then
echo Error: When you specify -outdir your must also specify -outurl
exit 1;
fi
else
if [ "$outurl" != "" ]; then
echo Error: When you specify -outurl your must also specify -outdir
exit 1;
fi
if [ "$webpage" = "" ]; then
outloc="${bindir}/../../output"
outurl="-DDXServer.outUrl=output"
fi
fi
##
## Require a DXROOT setting
##
if [ "$dxroot" != "" ]; then
DXROOT=$dxroot
fi
if [ "$DXROOT" = "" ]; then
echo "Error: You must set DXROOT in order to run startserver"
exit 1 ;
fi
if [ ! -d $DXROOT ]; then
echo Error: DXROOT: $DXROOT is not a directory.
exit 1;
fi
##
## E N D O F E R R O R C H E C K I N G
## E N D O F E R R O R C H E C K I N G
## E N D O F E R R O R C H E C K I N G
##
##
## At this point in the script we know we were handed either -webpage
## or -outdir && -outurl. If we have -webpage, then we'll compute
## outloc. If we have -outdir and -outurl, we're done.
##
if [ "$webpage" != "" ]; then
if [ -d $webpage ]; then
echo Error: -webpage $webpage should be a file.
exit 1;
fi
webdir=`dirname $webpage`
if [ -d $webdir/../output ]; then
outloc=$webdir/../output
outurl="-DDXServer.outUrl=output"
else
echo Error: startserver expects to find a directory named output beside $webpage.
exit 1
fi
fi
if [ "$outdir" = "" ] ; then
outdir=-DDXServer.outDir=$outloc
fi
##
## $outdir must be point to a writable directory.
##
if [ ! -d $outloc ]; then
echo Error: Output location: ${outloc} is not a directory.
exit 1;
else
if [ ! -w $outloc ]; then
echo Error: Output location: ${outloc} is not writable.
exit 1;
fi
fi
##
## Where is the DXServer directory? The .class files
## are cross platform. Starting java with jx.lib set, e.g.
## shared_obj="-Djx.lib=/usr/share/dx/java/server/lib_sgi/libAnyDX.so"
## tells java to use an arch specific method of loading shared
## objects where the complete file name including path must be
## specified.
##
## The use of SERVERDIR is intended to give developers (me) a
## way of using this script with a local build.
##
serverdir=
if [ "$SERVERDIR" = "" ]; then
serverdir=$default_serverdir
else
serverdir=$SERVERDIR
shared_obj=
fi
cd $serverdir
libarch=`dx -whicharch`
if test "$libarch" = "macos" ; then
if test -z $DYLD_LIBRARY_PATH ; then
DYLD_LIBRARY_PATH=$serverdir/../lib_$libarch
else
DYLD_LIBRARY_PATH=$serverdir/../lib_$libarch:$DYLD_LIBRARY_PATH
fi
export DYLD_LIBRARY_PATH
fi
if test "$libarch" != "macos" ; then
if [ "$LD_LIBRARY_PATH" = "" ]; then
LD_LIBRARY_PATH=$serverdir/../lib_$libarch
else
LD_LIBRARY_PATH=$serverdir/../lib_$libarch:$LD_LIBRARY_PATH
fi
export LD_LIBRARY_PATH
fi
##
## DXServer.class must be in the current working directory.
##
if [ ! -r ./DXServer.class ] && [ ! -r ./server.jar ]; then
echo "Error: Current working directory is" `pwd`
echo "startserver cannot run the server here."
exit 1;
fi
##
## set important DX environment variable
## DXMACROS must include ../dxmacros to get *mac.net
## DXARGS must not be -startup, -prompter, -tutor, etc.
##
if [ "$DXMACROS" = "" ]; then
DXMACROS=$DXROOT/samples/macros:../dxmacros:../usermacros
else
DXMACROS=$DXROOT/samples/macros:../dxmacros:../usermacros:$DXMACROS
fi
## dxexec doesn't use DXMACROS, it uses DXINCLUDES the same way
DXINCLUDES=$DXMACROS
if [ "$DXDATA" = "" ]; then
DXDATA=$DXROOT/samples/data:../userdata
else
DXDATA=$DXROOT/samples/data:../userdata:$DXDATA
fi
if [ "$memory" = "" ]; then
DXARGS="-optimize memory -highlight off -execonly -processors 1"
else
DXARGS="-optimize memory -memory $memory -highlight off -execonly -processors 1"
fi
export DXARGS
export DXMACROS
export DXDATA
export DXINCLUDES
if [ "$verbose" = "1" ]; then
echo "java $dbg_args $sessions $outdir $outurl $shared_obj DXServer"
echo ""
echo " DXROOT = "$DXROOT
echo " DXARGS = "$DXARGS
echo " DXMACROS = "$DXMACROS
echo " DXINCLUDES = "$DXINCLUDES
echo " DXDATA = "$DXDATA
echo ""
fi
if [ "$foreground" = "1" ]; then
java $dbg_args $sessions $outdir $outurl $shared_obj DXServer
else
java $dbg_args $sessions $outdir $outurl $shared_obj DXServer &
fi
exit 0
|