Last active
May 13, 2020 06:02
-
-
Save rodolfo42/5654188 to your computer and use it in GitHub Desktop.
Apache Tomcat 7 service 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/bash | |
### BEGIN INIT INFO | |
# Provides: tomcat | |
# Defalt-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Description: Apache Tomcat 7 | |
### END INIT INFO | |
# base dir of tomcat installation # | |
CATALINA_HOME=/opt/tomcat/ | |
# full path for file which will hold the PID # | |
# used by 'status' # | |
CATALINA_PID=/var/run/tomcat.pid | |
export CATALINA_PID | |
status=0 | |
case $1 in | |
start) | |
sh $CATALINA_HOME/bin/startup.sh | |
;; | |
stop) | |
sh $CATALINA_HOME/bin/shutdown.sh | |
;; | |
restart) | |
sh $CATALINA_HOME/bin/shutdown.sh | |
sh $CATALINA_HOME/bin/startup.sh | |
;; | |
status) | |
if ! [ -z "$CATALINA_PID" ]; then | |
if [ -r $CATALINA_PID ]; then | |
pid=`cat "$CATALINA_PID"` | |
if ! [ -z $pid ]; then | |
echo "tomcat (pid $pid) is running..." | |
else | |
echo "tomcat is stopped" | |
fi | |
else | |
echo "tomcat is stopped" | |
fi | |
else | |
echo "No PID file found for tomcat..." | |
echo "(variable \$CATALINA_PID is not defined)" | |
status=1 | |
fi | |
;; | |
esac | |
exit $status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!