Last active
September 21, 2015 11:05
-
-
Save alces/f701adbd5a6138227e21 to your computer and use it in GitHub Desktop.
RHEL 5/6-compliant init script for Apache Tomcat
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 | |
# chkconfig: 345 98 02 | |
export CATALINA_BASE=/opt/tomcat | |
export CATALINA_HOME=/opt/apache-tomcat-8.0.22 | |
export CATALINA_OPTS="-server -Xms512m -Xmx512m -XX:MaxPermSize=128m -XX:PermSize=128m" | |
export CATALINA_PID=$CATALINA_BASE/work/tomcat.pid | |
export JAVA_HOME=/opt/jdk1.8.0_51 | |
PATH=/usr/bin:/bin:/usr/sbin:/sbin | |
catalina() { | |
[ "$1" = "stop" ] && args="stop 30 -force" || args="$*" | |
su -c "$CATALINA_HOME/bin/catalina.sh $args" tomcat | |
} | |
if [ "$1" = "status" ] | |
then | |
if [ -f $CATALINA_PID ] | |
then | |
pid="`cat $CATALINA_PID`" | |
[ "`ps -p $pid ho comm`" = "java" ] && echo "tomcat (pid $pid) is running" || (echo "tomcat is dead but pid file exists"; exit 1) | |
else | |
echo "tomcat is stopped" | |
exit 3 | |
fi | |
elif [ "$1" = "restart" ] | |
then | |
catalina stop | |
catalina start | |
else | |
catalina $* | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment