2011-04-05 20:42:17 -07:00

72 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
#
# @PACKAGE@-management This shell script takes care of starting and stopping Tomcat
#
# chkconfig: - 80 20
#
### BEGIN INIT INFO
# Provides: tomcat6
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Default-Start:
# Default-Stop:
# Description: Release implementation for Servlet 2.5 and JSP 2.1
# Short-Description: start and stop tomcat
### END INIT INFO
#
# - originally written by Henri Gomez, Keith Irwin, and Nicolas Mailhot
# - heavily rewritten by Deepak Bhole and Jason Corley
#
if [ -r /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi
if [ -r /lib/lsb/init-functions ]; then
. /lib/lsb/init-functions
fi
NAME="$(basename $0)"
stop() {
SHUTDOWN_WAIT="30"
count="0"
if [ -f /var/run/cloud-management.pid ]; then
pid=`cat /var/run/cloud-management.pid`
kill $pid &>/dev/null
until [ "$(ps --pid $pid | grep -c $pid)" -eq "0" ] || \
[ "$count" -gt "$SHUTDOWN_WAIT" ]
do
sleep 1
let count="${count}+1"
done
if [ "$(ps --pid $pid | grep -c $pid)" -eq "0" ]; then
log_success_msg "Stopping Cloud-management"
else
log_failure_msg "Stopping Cloud-management"
fi
else
echo "Cannot find PID file of Cloud-management"
log_failure_msg "Stopping Cloud-management"
fi
}
# See how we were called.
case "$1" in
status)
status ${NAME}
RETVAL=$?
;;
stop)
stop
;;
restart)
stop
set start
. /etc/rc.d/init.d/tomcat6
;;
*)
. /etc/rc.d/init.d/tomcat6
esac
exit $RETVAL