-
-
Save willnet/4461426 to your computer and use it in GitHub Desktop.
tomcat init script for centos
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 | |
# description: Tomcat6 service | |
# processname: java | |
# chkconfig: - 99 1 | |
# Source function library. | |
. /etc/init.d/functions | |
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre | |
export TOMCAT_USER=solr | |
export CATALINA_HOME=/opt/tomcat6 | |
export CATALINA_PID=$CATALINA_HOME/bin/tomcat6.pid | |
[ -d "$CATALINA_HOME" ] || { echo "Tomcat requires $CATALINA_HOME."; exit 1; } | |
case $1 in | |
start|stop|run) | |
if su $TOMCAT_USER bash -c "$CATALINA_HOME/bin/catalina.sh $1"; then | |
echo -n "Tomcat $1 successful" | |
[ $1 == "stop" ] && rm -f $CATALINA_PID | |
else | |
echo -n "Error in Tomcat $1: $?" | |
fi | |
;; | |
restart) | |
$0 start | |
$0 stop | |
;; | |
status) | |
if [ -f "$CATALINA_PID" ]; then | |
read kpid < "$CATALINA_PID" | |
if ps --pid $kpid 2>&1 1>/dev/null; then | |
echo "$0 is already running at ${kpid}" | |
else | |
echo "$CATALINA_PID found, but $kpid is not running" | |
fi | |
unset kpid | |
else | |
echo "$0 is stopped" | |
fi | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks =]