Skip to content

Instantly share code, notes, and snippets.

@agorman
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agorman/e81cef9c5adc38ec1439 to your computer and use it in GitHub Desktop.
Save agorman/e81cef9c5adc38ec1439 to your computer and use it in GitHub Desktop.
Tomcat init script
#! /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