#!/bin/sh

DBXML_HOME=%%DBXML_HOME%%

echo "dbXML Server Bootstrap"
echo "======================"
echo
echo "Environment"
echo "-----------"
echo "DBXML_HOME = " $DBXML_HOME
echo 

if test -f $DBXML_HOME/config/dbxml.pid; then
   echo "ERROR"
   echo "-----"
   echo "A dbXML instance is already running with PID" `cat $DBXML_HOME/config/dbxml.pid`
   echo
   echo "If this is not the case, then simply delete the following"
   echo "file and retry:"
   echo
   echo "   $DBXML_HOME/config/dbxml.pid"
   echo
   exit
fi

# Read in the list of dbXML Jars to include in the BOOTPATH
BOOTPATH=""
JARS=`ls -1 $DBXML_HOME/java/lib/*.jar`
for jar in $JARS
do
   BOOTPATH=$jar:$BOOTPATH ;
done

# Read in the extra VM paramters for starting the program
VMPROPS=""
if test -f $DBXML_HOME/config/vm.cfg; then
   PROPS="`cat $DBXML_HOME/config/vm.cfg`"
   for prop in $PROPS
   do
      VMPROPS="$VMPROPS $prop"
   done
fi

echo "CLASSPATH = " $CLASSPATH
echo "BOOTPATH = " $BOOTPATH
echo
echo "Starting dbXML"
echo "--------------"

cd $DBXML_HOME

echo $$ > $DBXML_HOME/config/dbxml.pid

%%LOCALBASE%%/bin/java -Xbootclasspath/p:"$BOOTPATH" -classpath "$CLASSPATH" -Xms64m -Xmx384m -Ddbxml.home="$DBXML_HOME" $VMPROPS com.dbxml.db.server.ServerBootstrap $*

rm $DBXML_HOME/config/dbxml.pid
