📄 tomcat4.init
字号:
#!/bin/bash## Startup script for Tomcat, the Apache Servlet Engine## chkconfig: 345 85 15# description: Tomcat is the Apache Servlet Engine# processname: tomcat# pidfile: /var/run/tomcat.pid# config: /etc/tomcat.conf## Gomez Henri <hgomez@slib.fr># Keith Irwin <keith_irwin@non.hp.com># Nicolas Mailhot <nicolas.mailhot@one2team.com>## version 1.02 - Removed initlog support# version 1.03 - Removed config:# version 1.04 - tomcat will start before httpd and stop after httpd# version 1.05 - jdk hardcoded to link /usr/java/jdk and tomcat runs as "nobody"# version 1.06 - split up into script and config file# version 1.07 - Rework from Nicolas ideas # version 1.08 - Fix work dir permission at start time, switch to use tomcat4# version 1.09 - Fixed finding functions for init, changed to delete $TOMCAT_HOME/work# on startupFUNCTIONS_LOADED=0# Source function library.for dir in /etc /etc/rc.d; do if [ -f "$dir/init.d/functions" ] && [ "$FUNCTIONS_LOADED" = "0" ]; then source "$dir/init.d/functions" FUNCTIONS_LOADED=1 fidoneif [ "$FUNCTIONS_LOADED" = "0" ]; then echo "$0: unable to find init.d functions!" exit 1fi# Get Tomcat configTOMCAT_CFG="@@@TCCONF@@@/tomcat4.conf"[ -r "$TOMCAT_CFG" ] && . "${TOMCAT_CFG}"# find the JDK if JAVA_HOME is not properly setif [ ! -x "$JAVA_HOME/bin/java" ]; then unset JAVA_HOME MINIMUM_JAVA=1.3.0-00 if [ -z "$JAVA_HOME" ]; then for jdk in /Library/Java/Home /usr/java/jdk1.4* /usr/java/j2sdk1.4* /opt/IBMJava2-13 /usr/java/jdk1.3.1_* /usr/java/jdk1.3.1* /usr/java/j2sdk1.3.1* /usr/lib/j2sdk1.3*; do if [ -x "$jdk/bin/java" ]; then export JAVA_HOME="$jdk"; break fi done fi if [ -z "$JAVA_HOME" ]; then JAVA_PATH=`which java 2>&1 | grep -v "no java"` if [ ! -z "$JAVA_PATH" ]; then JAVA_PATH=`echo $JAVA_PATH | sed -e 's#/bin/java##'` if [ "$?" -eq "0" ]; then export JAVA_HOME="$JAVA_PATH" fi fi fi if [ -f "$JAVA_HOME/lib/tools.jar" ] || [ "`uname`" = "Darwin" ]; then if [ -z "$CLASSPATH" ] ; then CLASSPATH="$JAVA_HOME/lib/tools.jar" export CLASSPATH else CLASSPATH="$CLASSPATH:$JAVA_HOME/lib/tools.jar" export CLASSPATH fi fi export JAVA_HOMEfiif [ -d /opt/OpenNMS/lib ]; then export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/OpenNMS/lib"fi# Path to the tomcat launch script (direct don't use wrapper)TOMCAT_SCRIPT=/usr/bin/dtomcat4# Tomcat name :)TOMCAT_PROG=tomcat4 # if TOMCAT_USER is not set, use tomcat4 like Apache HTTP serverif [ -z "$TOMCAT_USER" ]; then TOMCAT_USER="tomcat4"fi# Since the daemon function will sandbox $tomcat# no environment stuff should be defined here anymore.# Please use the /etc/tomcat.conf file instead ; it will# be read by the $tomcat scriptRETVAL=0# See how we were called.start() { echo -n "Starting $TOMCAT_PROG: " chown -R $TOMCAT_USER:$TOMCAT_USER @@@TCHOME@@@/logs chown -R $TOMCAT_USER:$TOMCAT_USER @@@TCHOME@@@/work chown -R $TOMCAT_USER:$TOMCAT_USER @@@TCHOME@@@/webapps/* daemon --user $TOMCAT_USER JAVA_HOME="$JAVA_HOME" PATH="$JAVA_HOME/bin:$PATH" $TOMCAT_SCRIPT start 2>>/var/log/tomcat4.stderr RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/tomcat4 return $RETVAL}stop() { echo -n "Stopping $TOMCAT_PROG: " daemon --user $TOMCAT_USER JAVA_HOME="$JAVA_HOME" PATH="$JAVA_HOME/bin:$PATH" $TOMCAT_SCRIPT stop 2>>/var/log/tomcat4.stderr RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/tomcat4 /var/run/tomcat4.pid}tcproccount() { ps -auxwww | grep TOMCATLAUNCH | grep -v grep | wc -l}# See how we were called.case "$1" in start) start ;; stop) stop ;; restart|condrestart) stop TCDONE=0 for i in 1 2 3 4 5 6 7 8 9 10; do if [ "`tcproccount`" -ge 1 ]; then sleep 2 else TCDONE=1 break fi done if [ "$TCDONE" = "1" ]; then start else echo "" echo "Tomcat is not shutting down properly. Please check" echo "your logs and try again." echo "" exit 1 fi ;; *) echo "Usage: $TOMCAT_PROG {start|stop|restart|condrestart}" exit 1esacexit $RETVAL
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -