Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.