20120221 apache tomcat init script - plembo/onemoretech GitHub Wiki

title: Apache Tomcat init script link: https://onemoretech.wordpress.com/2012/02/21/apache-tomcat-init-script/ author: lembobro description: post_id: 2216 created: 2012/02/21 01:15:39 created_gmt: 2012/02/21 05:15:39 comment_status: closed post_name: apache-tomcat-init-script status: publish post_type: post

Apache Tomcat init script

Just the code, and only the code. Here's the script. For Red Hat Enterprise and downstream distributions running a .tar.gz binary package downloaded from Apache Tomcat site (not the shipping RHEL version of Tomcat). Tested with versions of Tomcat from version 5 to 7 (latest as of this writing).

#!/bin/bash
# Apache Tomcat init script
# /etc/rc.d/init.d/tomcat
#
# chkconfig: 345 99 28
# description: Starts/Stops Apache Tomcat
#
JAVA_HOME=/usr/java/default
CATALINA_HOME=/opt/apache/tomcat
CATALINA_BASE=$CATALINA_HOME
PATH=$JAVA_HOME/bin:$CATALINA_HOME/bin:$PATH
APPUSR=tomcat

case "$1" in
'start')
        echo "Apache Tomcat starting..."
        su - $APPUSR <<EOS
        $CATALINA_HOME/bin/startup.sh
EOS
        ;;
'stop')
        echo "Apache Tomcat stopping..."
        su - $APPUSR <<EOS
        $CATALINA_HOME/bin/shutdown.sh
EOS
        ;;
*)
        echo "Usage: $0 { start | stop }"
        exit 1
        ;;
esac

Copyright 2004-2019 Phil Lembo