#!/bin/sh
##############################################################################
#
#   Copyright 2004 The Apache Software Foundation.
#
#   Licensed 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.
##############################################################################
#
# Small shell script to show how to start/stop Tomcat using jsvc
# If you want to have Tomcat running on port 80 please modify the server.xml
# file:
#
#    <!-- Define a non-SSL HTTP/1.1 Connector on port 80 -->
#    <Connector className="org.apache.catalina.connector.http.HttpConnector"
#               port="80" minProcessors="5" maxProcessors="75"
#               enableLookups="true" redirectPort="8443"
#               acceptCount="10" debug="0" connectionTimeout="60000"/>
#
# That is for Tomcat-5.0.x (Apache Tomcat/5.0)
#
# Adapt the following lines to your configuration
JAVA_HOME=/usr/java/jdk1.5.0_10
export JAVA_HOME
CATALINA_HOME=/usr/local/apache-tomcat-5.5.20
export CATALINA_HOME
DAEMON_HOME=$CATALINA_HOME/bin
TOMCAT_USER=root

# for multi instances adapt those lines.
TMP_DIR=/var/tmp
PID_FILE=/var/run/jsvc.pid
CATALINA_BASE=/home/tomcat5/tomcat5/jakarta-tomcat-5/build

CATALINA_OPTS="-Djava.library.path=/home/jfclere/jakarta-tomcat-connectors/jni/native/.libs"
CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$CATALINA_HOME/bin/bootstrap.jar

. /etc/rc.status

# First reset status of this service
rc_reset

case "$1" in
  start)
    echo $"Starting Tomcat..."
    #
    # Start Tomcat
    #
    sh $DAEMON_HOME/startup.sh
    checkproc /usr/java/jdk1.5.0_10/bin/java
    rc_status -v
    ;;

  stop)
    echo $"Stopping Tomcat..."
    #
    # Stop Tomcat
    #
    sh $DAEMON_HOME/shutdown.sh
    echo $"Tomcat stopped"
    ;;

    restart)
        sh $DAEMON_HOME/shutdown.sh
        sh $DAEMON_HOME/startup.sh
        ;;

    try-restart)
        sh $DAEMON_HOME/shutdown.sh
        sh $DAEMON_HOME/startup.sh
        ;;
	
    reload)
        sh $DAEMON_HOME/shutdown.sh
        sh $DAEMON_HOME/startup.sh
        ;;

    force-reload)
        sh $DAEMON_HOME/shutdown.sh
        sh $DAEMON_HOME/startup.sh
        ;;

    status)
                checkproc /usr/java/jdk1.5.0_10/bin/java
                rc_status -v
        ;;

    monitor)
                checkproc /usr/java/jdk1.5.0_10/bin/java
                rc_status -v
        ;;

  *)
        echo "Usage service tomcat [start|stop|restart|try-restart|reload|force-reload|status]"
	exit 1;;
esac
