Created
April 25, 2013 09:31
-
-
Save vmi/5458611 to your computer and use it in GitHub Desktop.
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/sh | |
# | |
# chkconfig: - 80 20 | |
# description: tomcat | |
# merged scripts on following pages: | |
# http://www.atmarkit.co.jp/ait/articles/0710/11/news121_2.html | |
# http://d.hatena.ne.jp/marmotte/20110910/1315660564 | |
# Source function library. | |
. /etc/init.d/functions | |
TOMCAT=tomcat | |
JAVA_HOME=/opt/java | |
CATALINA_HOME=/opt/$TOMCAT | |
TOMCAT_USER=tomcat | |
# for multi instances adapt those lines. | |
TMP_DIR=/var/tmp | |
PID_FILE=/var/run/$TOMCAT/$TOMCAT.pid | |
LOCK_FILE=/var/lock/subsys/$TOMCAT | |
CATALINA_OPTS= | |
if [ -f /etc/sysconfig/$TOMCAT ]; then | |
. /etc/sysconfig/$TOMCAT | |
fi | |
if [ -n "$CATALINA_BASE" ]; then | |
: | |
else | |
CATALINA_BASE=$CATALINA_HOME | |
fi | |
DAEMON=$CATALINA_HOME/bin/jsvc | |
CLASSPATH=\ | |
$JAVA_HOME/lib/tools.jar:\ | |
$CATALINA_HOME/bin/commons-daemon.jar:\ | |
$CATALINA_HOME/bin/bootstrap.jar | |
start() { | |
# | |
# Start Tomcat | |
# | |
echo -n "Starting $TOMCAT: " | |
$DAEMON $JSVC_OPTS \ | |
-user $TOMCAT_USER \ | |
-home $JAVA_HOME \ | |
-Dcatalina.home=$CATALINA_HOME \ | |
-Dcatalina.base=$CATALINA_BASE \ | |
-Djava.io.tmpdir=$TMP_DIR \ | |
-wait 10 \ | |
-pidfile $PID_FILE \ | |
-outfile $CATALINA_HOME/logs/catalina.out \ | |
-errfile '&1' \ | |
$CATALINA_OPTS \ | |
-cp $CLASSPATH \ | |
org.apache.catalina.startup.Bootstrap | |
# | |
# To get a verbose JVM | |
#-verbose \ | |
# To get a debug of jsvc. | |
#-debug \ | |
RETVAL=$? | |
if [ $RETVAL = 0 ]; then | |
echo_success | |
touch $LOCK_FILE | |
else | |
echo_failure | |
fi | |
echo | |
} | |
stop() { | |
# | |
# Stop Tomcat | |
# | |
echo -n "Shutting down $TOMCAT: " | |
$DAEMON $JSVC_OPTS \ | |
-stop \ | |
-pidfile $PID_FILE \ | |
org.apache.catalina.startup.Bootstrap | |
RETVAL=$? | |
if [ $RETVAL = 0 ]; then | |
echo_success | |
rm -f $PID_FILE $LOCK_FILE | |
else | |
echo_failure | |
fi | |
echo | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
stop | |
start | |
;; | |
status) | |
status $DAEMON | |
RETVAL=$? | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|restart|status}" | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment