#!/bin/sh # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # $Id$ # ----------------------------------------------------------------------------- # Xindice Unix Shell Script # ----------------------------------------------------------------------------- # Configuration variables # # XINDICE_HOME # Home of Xindice program and data. # # JAVA_HOME # Home of Java installation. # # JAVA_OPTIONS # Extra options to pass to the JVM # # JETTY_PORT # Override the default port for Jetty usage() { echo "Xindice Server Startup Script" echo "Usage:" echo " $0 " echo "Actions:" echo " start Start Xindice server" echo " stop Stop Xindice server" echo " debug Start Xindice server with remote debugging on" exit 1 } [ $# -gt 0 ] || usage ACTION=$1 shift ARGS="$*" # ----- OS specific support ---------------------------------------------------- cygwin=false; darwin=false; case "`uname`" in CYGWIN*) cygwin=true ;; Darwin*) darwin=true if [ -z "$JAVA_HOME" ] ; then JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home fi ;; esac # ----- Verify and Set Required Environment Variables ------------------------- if [ "$JAVA_HOME" = "" ] ; then echo You must set JAVA_HOME to point at your Java Development Kit installation exit 1 fi if [ "$JAVA_OPTIONS" = "" ] ; then JAVA_OPTIONS="-Xms64m -Xmx128m" fi if [ "$XINDICE_HOME" = "" ] ; then XINDICE_HOME=`pwd` if [ ! -f $XINDICE_HOME/xindice-1*.jar ] ; then echo ERROR: You must set XINDICE_HOME to point at your echo Xindice installation directory. exit 2 fi fi if [ "$XINDICE_DB_HOME" = "" ] ; then XINDICE_DB_HOME=$XINDICE_HOME ; fi if [ "$XINDICE_CONFIG" = "" ] ; then XINDICE_CONFIG=$XINDICE_HOME/config/system.xml ; fi if [ "$LOGGER" = "" ] ; then LOGGER=org.apache.commons.logging.impl.SimpleLog ; fi if [ "$LOGLEVEL" = "" ] ; then LOGLEVEL=INFO ; fi if [ "$JETTY_PORT" = "" ] ; then JETTY_PORT=8888 fi if [ "$JETTY_WEBAPP" = "" ] ; then JETTY_WEBAPP=`ls $XINDICE_HOME/xindice-*.war | head -n 1` fi if [ "$JAVA_DEBUG_PORT" = "" ] ; then JAVA_DEBUG_PORT=8000 fi if [ "$XINDICE_PID" = "" ] ; then XINDICE_PID=$XINDICE_HOME/logs/xindice.pid if [ ! -d $XINDICE_HOME/logs ] then echo echo Creating the logs directory under $XINDICE_HOME echo mkdir -p $XINDICE_HOME/logs fi fi # ----- Set Classpath ---------------------------------------------------------- CP=`ls $XINDICE_HOME/lib/servlet*.jar` for i in `ls $XINDICE_HOME/lib/endorsed/*.jar` ; do CP=$CP:$i ; done for i in `ls $XINDICE_HOME/tools/jetty/*.jar` ; do CP=$CP:$i ; done for i in `ls $XINDICE_HOME/tools/jetty/lib/*.jar` ; do CP=$CP:$i ; done # ----- Do the action ---------------------------------------------------------- JAVACMD=$JAVA_HOME/bin/java JETTY_CONFIG="$XINDICE_HOME/tools/jetty/conf/main.xml" # For Cygwin, switch paths to Windows format before running java if $cygwin; then JAVACMD=`cygpath "$JAVACMD"` CP=`cygpath --path --windows "$CP"` JETTY_CONFIG=`cygpath --path --windows "$JETTY_CONFIG"` JETTY_WEBAPP=`cygpath --path --windows "$JETTY_WEBAPP"` XINDICE_HOME=`cygpath --path --windows "$XINDICE_HOME"` XINDICE_DB_HOME=`cygpath --path --windows "$XINDICE_DB_HOME"` XINDICE_CONFIG=`cygpath --path --windows "$XINDICE_CONFIG"` fi JAVAARGS="-classpath $CP -Djava.endorsed.dirs=lib/endorsed \ -Dxindice.home=$XINDICE_HOME -Dxindice.db.home=$XINDICE_DB_HOME -Dxindice.configuration=$XINDICE_CONFIG \ -Dorg.apache.commons.logging.Log=$LOGGER -Dorg.apache.commons.logging.simplelog.defaultlog=$LOGLEVEL \ -Dorg.xml.sax.parser=org.apache.xerces.parsers.SAXParser \ -Djetty.home=$XINDICE_HOME/tools/jetty -Djetty.port=$JETTY_PORT \ -Dwebapp=$JETTY_WEBAPP" case "$ACTION" in start) if [ -f $XINDICE_PID ] then echo echo "Seems like an instance of Xindice is already running with PID `cat $XINDICE_PID`." echo echo "If that's not the case, please delete $XINDICE_PID and try again" echo exit 1 fi echo echo "Starting Xindice. Log files are under $XINDICE_HOME/logs" echo nohup "$JAVACMD" $JAVA_OPTIONS $JAVAARGS org.mortbay.start.Main "$JETTY_CONFIG" >> $XINDICE_HOME/logs/xindice.out 2>&1 & echo $! > $XINDICE_PID echo "Xindice is running with PID `cat $XINDICE_PID`" ;; run) "$JAVACMD" $JAVA_OPTIONS $JAVAARGS org.mortbay.start.Main "$JETTY_CONFIG" ;; debug) "$JAVACMD" $JAVA_OPTIONS -Xdebug -Xrunjdwp:transport=dt_socket,address=$JAVA_DEBUG_PORT,server=y,suspend=n $JAVAARGS org.mortbay.start.Main "$JETTY_CONFIG" >> $XINDICE_HOME/logs/xindice.out 2>&1 ;; stop) if [ -f $XINDICE_PID ] then echo echo "Shutting down Xindice running with PID `cat $XINDICE_PID`" echo kill `cat $XINDICE_PID` rm $XINDICE_PID else echo echo "Unable to find a running Xindice instance" echo fi ;; *) usage ;; esac exit 0