Last active
August 29, 2015 14:22
-
-
Save agorman/e81cef9c5adc38ec1439 to your computer and use it in GitHub Desktop.
Tomcat init script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# Apache Tomcat init script | |
# | |
# description: Runs Apache Tomcat | |
# | |
# chkconfig: 345 80 20 | |
###### EDIT THE FOLLOWING LINES ###### | |
APPNAME=tomcat | |
SCRIPT=/opt/apache-tomcat-6.0.18/bin/startup.sh | |
PROCESS=org.apache.catalina.startup.Bootstrap | |
PIDFILE=/var/run/$APPNAME.pid | |
###### STOP EDITING ###### | |
# Source function library | |
. /etc/rc.d/init.d/functions | |
start() { | |
echo -n "Starting $APPNAME: " | |
PID=`ps -eaf|grep ${PROCESS}|grep -v grep|awk '{print $2}'` | |
if [ $PID ]; then | |
echo $APPNAME already running: $PID | |
exit 2; | |
fi | |
$SCRIPT $OPTIONS >/dev/null | |
RETVAL=$? | |
if [ $RETVAL ]; then | |
echo_success | |
echo $PID > $PIDFILE | |
else | |
echo_failure | |
fi | |
echo | |
} | |
stop() { | |
echo -n "Stopping $APPNAME: " | |
killproc -p $PIDFILE | |
echo | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
stop | |
start | |
;; | |
status) | |
status -p $PIDFILE | |
RETVAL=$? | |
;; | |
*) | |
echo "Usage: {start|stop|restart|status}" | |
exit 1 | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment