58 lines
1011 B
Bash
58 lines
1011 B
Bash
#!/bin/bash
|
|
### BEGIN INIT INFO
|
|
# Provides: tomcat
|
|
# Required-Start: $network
|
|
# Required-Stop: $network
|
|
# Default-Start: 2 3 4 5
|
|
# Default-Stop: 0 1 6
|
|
# Short-Description: Start/Stop Tomcat server
|
|
### END INIT INFO
|
|
|
|
# Source function library.
|
|
. /etc/environment; #Catalina variables
|
|
. $CATALINA_HOME/bin/setenv.sh
|
|
|
|
RETVAL=$?
|
|
|
|
function start(){
|
|
echo "Starting Tomcat"
|
|
/bin/su - tomcat $CATALINA_HOME/bin/startup.sh
|
|
RETVAL=$?
|
|
}
|
|
|
|
function stop(){
|
|
echo "Stopping Tomcat"
|
|
/bin/su - tomcat -c "$CATALINA_HOME/bin/shutdown.sh 60 -force"
|
|
RETVAL=$?
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
start;
|
|
;;
|
|
stop)
|
|
stop;
|
|
;;
|
|
restart)
|
|
echo "Restarting Tomcat"
|
|
stop;
|
|
start;
|
|
;;
|
|
status)
|
|
|
|
if [ -f "${CATALINA_PID}" ]; then
|
|
TOMCAT_PID=$(cat "${CATALINA_PID}")
|
|
echo "Tomcat is running with PID ${TOMCAT_PID}";
|
|
RETVAL=1
|
|
else
|
|
echo "Tomcat is not running";
|
|
RETVAL=0
|
|
fi
|
|
;;
|
|
*)
|
|
echo $"Usage: $0 {start|stop|restart|status}"
|
|
exit 1
|
|
;;
|
|
esac
|
|
exit $RETVAL
|