-
-
Save artynet/d43f26d030f0cb613c471ca31c64d724 to your computer and use it in GitHub Desktop.
Tomcat Init Script (Centos/RHEL/Fedora)
This file contains hidden or 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 | |
# | |
# tomcatd Start Tomcat server | |
# | |
# chkconfig: - 80 20 | |
# description: Tomcat Web Application Server | |
# | |
# processname: tomcat | |
# pidfile: /var/run/tomcat.pid | |
### BEGIN INIT INFO | |
# Provides: tomcat | |
# Required-Start: $network $syslog | |
# Required-Stop: $network $syslog | |
# Default-Start: | |
# Default-Stop: | |
# Short-Description: Start tomcat server | |
### END INIT INFO | |
# Source function library. | |
. /etc/rc.d/init.d/functions | |
prog=tomcat | |
RETVAL=$? | |
lockfile=/var/lock/subsys/$prog | |
# Tomcat init Variables | |
# for additional tomcat config please use setenv | |
#CATALINA_HOME is the location of the bin files of Tomcat | |
export CATALINA_HOME="/opt/tomcat" | |
#CATALINA_PID is the location of the PID file | |
export CATALINA_PID="/var/run/$prog.pid" | |
#TOMCAT_USER is the default user of tomcat | |
TOMCAT_USER=tomcat | |
#SHUTDOWN_VERBOSE Whether to annoy the user with "attempting to shut down" messages or not | |
SHUTDOWN_VERBOSE="false" | |
#SHUTDOWN_WAIT Time to wait in seconds, before killing process | |
SHUTDOWN_WAIT="20" | |
# Start of the script | |
start() { | |
echo -n $"Starting $prog: " | |
touch $CATALINA_PID | |
chown $TOMCAT_USER $CATALINA_PID | |
daemon --user $TOMCAT_USER "$CATALINA_HOME/bin/catalina.sh" start | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && touch $lockfile | |
return $RETVAL | |
} | |
stop() { | |
echo -n $"Shutting down $prog: " | |
daemon --user $TOMCAT_USER "$CATALINA_HOME/bin/catalina.sh" stop | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && rm -f $lockfile | |
return $RETVAL | |
} | |
rhstatus(){ | |
status -p "$CATALINA_PID" $prog | |
} | |
case $1 in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
stop | |
start | |
;; | |
status) | |
rhstatus | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart|status}" | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment