#!/bin/sh ### ### JSpawn -- Baykit software startup script ### ### Copyright (C) 2000 Yokohama Baykit, ALL RIGHTS RESERVED ### $Id: xi,v 1.10 2002/12/20 08:28:19 ryo Exp $ ### ### Copyright (C) 2003 Yuuki ### ## ## Detect script directory (jspawnDir) ## curDir=`pwd` jspawnDir=`dirname $0` if [ "$jspawnDir" = '.' -a ! -f $0 ] ; then ## script is in PATH scriptPath=`which $0` jspawnDir=`dirname $scriptPath` fi cd $jspawnDir jspawnDir=`pwd` cd $curDir ## ## script file name (jspawnName) ## jspawnName=`basename $0` ## ## find property file (propertyFile) ## propertyFile=${jspawnDir}/${jspawnName}.conf if [ ! -f "$propertyFile" ] ; then echo "*** Error: property file '$propertyFile': not found." 1>&2 exit 1 fi ## ## get property values ## pvalue () { sed -n "s/^$1=//p" $propertyFile } libDir=`pvalue libdir` mainClass=`pvalue main` javaOptions=`pvalue javaopts` debug=`pvalue debug` envNames=`pvalue env` tools=`pvalue tools` execDir=`pvalue execdir` ## ## Set Java Options ## if [ "$JAVA_OPTS" != "" ]; then javaOptions="$JAVA_OPTS $javaOptions" fi ## Cygwin support. (isCygwin) ## isCygwin=false; case "`uname`" in CYGWIN*) isCygwin=true ;; esac ## ## Create classpath (CLASSPATH) ## classpath= for j in ${libDir} ; do if [ -d ${jspawnDir}/$j ] ; then jarFiles=`ls ${jspawnDir}/$j/*.jar ${jspawnDir}/$j/*.zip 2>/dev/null` if [ "$jarFiles" != "" ] ; then for jarFile in $jarFiles ; do classpath=${classpath}:${jarFile} done fi fi done classpath=${classpath}:${CLASSPATH} ## ## Create env system property (-Djspanw.env.{ENV-NAME}={ENV-VALUE}) ## for envName in $envNames; do envValue=`echo 'echo $'${envName} | sh` javaOptions="-Djspawn.env.$env=${envValue} "${javaOptions} done ## ## Handling tools property ## (add tools.jar to CLASSPATH) ## if [ "$tools" = "true" ] ; then if [ -z "$JAVA_HOME" ] ; then javaCommand=`which java 2>/dev/null` if [ -z "$javaCommand" ] ; then echo "Cannot find java. Please set your PATH." exit 1 fi javaBinDir=`dirname $javaCommand` JAVA_HOME=`dirname $javaBinDir` fi toolsJar=${JAVA_HOME}/lib/tools.jar if [ ! -f $toolsJar ] ; then echo "Warning!: $toolsJar not found" fi classpath=${toolsJar}:${classpath} fi ## ## For Cygwin, switch paths to Windows format before running java ## (translate path separator ':' to ';') if $isCygwin ; then classpath=`cygpath --path --windows "$classpath"` param=`/etc/args_to_win.sh $*` fi ## ## Create command (command) ## if $isCygwin ; then command="exec java $javaOptions -classpath $classpath \ -Djspawn.dir=`cygpath -ws ${jspawnDir}` \ -Djspawn.name=${jspawnName} $mainClass $param" else command="exec java $javaOptions -classpath $classpath \ -Djspawn.dir=${jspawnDir} -Djspawn.name=${jspawnName} \ $mainClass $*" fi ## ## debug print ## if [ "$debug" = "true" ] ; then echo "RunCommand:: " $command fi ## ## Change directory ## if [ -n "$execDir" ] ; then cd $jspawnDir/$execDir fi $command