/etc/init.d/tomcat5:
|
-
#!/bin/bash
-
#
-
# tomcat5 This shell script takes care of starting and stopping Tomcat
-
#
-
# chkconfig: - 80 20
-
#
-
### BEGIN INIT INFO
-
# Provides: tomcat5
-
# Required-Start: $network $syslog
-
# Required-Stop: $network $syslog
-
# Default-Start:
-
# Default-Stop:
-
# Description: Release implementation for Servlet 2.4 and JSP 2.0
-
# Short-Description: start and stop tomcat
-
### END INIT INFO
-
#
-
# - originally written by Henri Gomez, Keith Irwin, and Nicolas Mailhot
-
# - heavily rewritten by Deepak Bhole and Jason Corley
-
#
-
if [ -r /lib/lsb/init-functions ]; then
-
. /lib/lsb/init-functions
-
else
-
exit 1
-
fi
-
NAME="$(basename $0)"
-
unset ISBOOT
-
if [ "${NAME:0:1}" = "S" -o "${NAME:0:1}" = "K" ]; then
-
NAME="${NAME:3}"
-
ISBOOT="1"
-
fi
-
# For SELinux we need to use 'runuser' not 'su'
-
if [ -x "/sbin/runuser" ]; then
-
SU="/sbin/runuser"
-
else
-
SU="su"
-
fi
-
# Get the tomcat config (use this for environment specific settings)
-
TOMCAT_CFG="/etc/tomcat5/tomcat5.conf
"
-
-
if [ -r "$TOMCAT_CFG" ]; then
-
. ${TOMCAT_CFG}
-
fi
-
# Get instance specific config file
-
if [ -r "/etc/sysconfig/${NAME}" ]; then
-
. /etc/sysconfig/${NAME}
-
fi
-
if [ -z "${CATALINA_BASE}" ]; then
-
CATALINA_BASE="${CATALINA_HOME}"
-
fi
-
# Define which connector port to use
-
CONNECTOR_PORT="${CONNECTOR_PORT:-8080
-
}"
-
# Path to the tomcat launch script
-
TOMCAT_SCRIPT="/usr/bin/dtomcat5"
-
# Path to the script that will refresh jar symlinks on startup
-
TOMCAT_RELINK_SCRIPT="${CATALINA_HOME}/bin/relink"
-
# Tomcat program name
-
TOMCAT_PROG="$NAME"
-
-
# Define the tomcat username
-
TOMCAT_USER="${TOMCAT_USER:-tomcat}"
-
# Define the tomcat log file
-
TOMCAT_LOG="${TOMCAT_LOG:-/var/log/tomcat5/catalina.out}"
-
RETVAL="0"
-
function checkpid() {
-
local i
-
for i in $* ; do
-
if [ -d "/proc/${i}" ]; then
-
return 0
-
fi
-
done
-
return 1
-
}
-
# Look for open ports, as the function name might imply
-
function findFreePorts() {
-
local isSet1="false"
-
local isSet2="false"
-
local isSet3="false"
-
local lower="8000"
-
randomPort1="0"
-
randomPort2="0"
-
randomPort3="0"
-
local -a listeners="( $(
-
netstat -ntl | \
-
awk '/^tcp/ {gsub("(.)*:", "", $4); print $4}'
-
) )"
-
while [ "$isSet1" = "false" ] || \
-
[ "$isSet2" = "false" ] || \
-
[ "$isSet3" = "false" ]; do
-
let port="${lower}+${RANDOM:0:4}"
-
if [ -z `expr " ${listeners[*]} " : ".*\( $port \).*"` ]; then
-
if [ "$isSet1" = "false" ]; then
-
export randomPort1="$port"
-
isSet1="true"
-
elif [ "$isSet2" = "false" ]; then
-
export randomPort2="$port"
-
isSet2="true"
-
elif [ "$isSet3" = "false" ]; then
-
export randomPort3="$port"
-
isSet3="true"
-
fi
-
fi
-
done
-
}
-
function makeHomeDir() {
-
SAVE_UMASK=$(umask)
-
umask 022
-
if [ ! -d "${CATALINA_HOME}" ]; then
-
echo "${CATALINA_HOME} does not exist, creating"
-
if [ ! -d "/var/lib/${NAME}" ]; then
-
mkdir -p /var/lib/${NAME}
-
cp -pR /var/lib/tomcat5/* /var/lib/${NAME}
-
fi
-
mkdir -p ${CATALINA_HOME} ${CATALINA_HOME}/conf /var/cache/${NAME}/temp \
-
/var/cache/${NAME}/work /var/log/${NAME}
-
for i in temp work; do
-
ln -fs /var/cache/${NAME}/${i} ${CATALINA_HOME}/${i}
-
done
-
for i in common server shared webapps; do
-
ln -fs /var/lib/${NAME}/${i} ${CATALINA_HOME}/${i}
-
done
-
ln -fs /var/log/${NAME} ${CATALINA_HOME}/logs
-
cp -pLR /etc/tomcat5/* ${CATALINA_HOME}/conf/
-
cp -pLR /usr/share/tomcat5/bin ${CATALINA_HOME}
-
cp -pLR /var/cache/tomcat5/work/* ${CATALINA_HOME}/work/
-
chown ${TOMCAT_USER}:${TOMCAT_USER} /var/log/${NAME}
-
fi
-
umask ${SAVE_UMASK}
-
}
-
function parseOptions() {
-
options=""
-
options="$options $(
-
awk '!/^#/ && !/^$/ { ORS=" "; print "export ", $0, ";" }' \
-
$TOMCAT_CFG
-
)"
-
if [ -r "/etc/sysconfig/${NAME}" ]; then
-
options="$options $(
-
awk '!/^#/ && !/^$/ { ORS=" ";
-
print "export ", $0, ";" }' \
-
/etc/sysconfig/${NAME}
-
)"
-
fi
-
TOMCAT_SCRIPT="$options $TOMCAT_SCRIPT"
-
}
-
# See how we were called.
-
function start() {
-
echo -n "Starting ${TOMCAT_PROG}: "
-
if [ -f "/var/lock/subsys/${NAME}" ] ; then
-
if [ -f "/var/run/${NAME}.pid" ]; then
-
read kpid < /var/run/${NAME}.pid
-
if checkpid $kpid 2>&1; then
-
echo "$NAME process already running"
-
return -1
-
else
-
echo "lock file found but no process running for"
-
echo "pid $kpid, continuing"
-
fi
-
fi
-
fi
-
export CATALINA_PID="/var/run/${NAME}.pid"
-
touch $CATALINA_PID
-
chown ${TOMCAT_USER}:${TOMCAT_USER} $CATALINA_PID
-
if [ "$CATALINA_HOME" != "/usr/share/tomcat5" ]; then
-
# Create a tomcat directory if it doesn't exist
-
makeHomeDir
-
# If CATALINA_HOME doesn't exist modify port number so that
-
# multiple instances don't interfere with each other
-
findFreePorts
-
sed -i -e "s/8005/${randomPort1}/g" -e "s/8080/${CONNECTOR_PORT}/g" \
-
-e "s/8009/${randomPort2}/g" -e "s/8443/${randomPort3}/g" \
-
${CATALINA_HOME}/conf/server.xml
-
fi
-
touch $TOMCAT_LOG
-
chown ${TOMCAT_USER}:${TOMCAT_USER} $TOMCAT_LOG
-
if [ "$RELINK" = "yes" ]; then
-
$TOMCAT_RELINK_SCRIPT
-
fi
-
$SU - $TOMCAT_USER -c "$TOMCAT_SCRIPT start" >> $TOMCAT_LOG 2>&1
-
RETVAL="$?"
-
if [ "$RETVAL" -eq 0 ]; then
-
log_success_msg
-
touch /var/lock/subsys/${NAME}
-
else
-
log_failure_msg
-
fi
-
#echo
-
return $RETVAL
-
}
-
function status() {
-
RETVAL="1"
-
if [ -f "/var/run/${NAME}.pid" ]; then
-
read kpid < /var/run/${NAME}.pid
-
if checkpid $kpid 2>&1; then
-
echo "$0 is already running (${kpid})"
-
RETVAL="0"
-
else
-
echo "lock file found but no process running for pid $kpid"
-
fi
-
else
-
pid="$(pgrep -u ${TOMCAT_USER} -G ${TOMCAT_USER} java)"
-
if [ -n "$pid" ]; then
-
echo "$0 running (${pid}) but no PID file exists"
-
RETVAL="0"
-
else
-
echo "$0 is stopped"
-
fi
-
fi
-
return $RETVAL
-
}
-
function stop() {
-
local STOP_VERBOSE="false"
-
echo -n "Stopping $TOMCAT_PROG: "
-
if [ -f "/var/lock/subsys/${NAME}" ]; then
-
$SU - $TOMCAT_USER -c "$TOMCAT_SCRIPT stop" >> $TOMCAT_LOG 2>&1
-
RETVAL="$?"
-
if [ "$RETVAL" -eq "0" ]; then
-
count="0"
-
if [ -f "/var/run/${NAME}.pid" ]; then
-
read kpid < /var/run/${NAME}.pid
-
until [ "$(ps --pid $kpid | grep -c $kpid)" -eq "0" ] || \
-
[ "$count" -gt "$SHUTDOWN_WAIT" ]; do
-
if [ "$STOP_VERBOSE" = "true" ]; then
-
echo -n -e "\nwaiting for processes $kpid to exit"
-
fi
-
sleep 1
-
let count="${count}+1"
-
done
-
if [ "$count" -gt "$SHUTDOWN_WAIT" ]; then
-
if [ "$STOP_VERBOSE" = "true" ]; then
-
echo -n -e "\nkilling processes which didn't stop"
-
echo -n -e "after "
-
echo -n "$SHUTDOWN_WAIT seconds"
-
fi
-
kill -9 $kpid
-
fi
-
if [ "$STOP_VERBOSE" = "true" -a "$count" -gt "0" ]; then
-
echo -n -e "\n"
-
fi
-
log_success_msg
-
else
-
log_failure_msg
-
fi
-
rm -f /var/lock/subsys/$NAME /var/run/$NAME.pid
-
else
-
log_failure_msg
-
fi
-
else
-
log_failure_msg
-
fi
-
#echo
-
}
-
# See how we were called.
-
case "$1" in
-
start)
-
parseOptions
-
start
-
;;
-
stop)
-
parseOptions
-
stop
-
;;
-
restart)
-
parseOptions
-
stop
-
sleep 2
-
start
-
;;
-
condrestart|try-restart)
-
if [ -f "/var/run/${NAME}.pid" ]; then
-
parseOptions
-
stop
-
start
-
fi
-
;;
-
reload)
-
RETVAL="3"
-
;;
-
force-reload)
-
if [ -f "/var/run/${NAME}.pid" ]; then
-
stop
-
start
-
fi
-
;;
-
status)
-
status
-
;;
-
version)
-
parseOptions
-
"${JAVA_HOME}/bin/java" \
-
-classpath "${CATALINA_HOME}/server/lib/[tomcat5][catalina].jar" \
-
org.apache.catalina.util.ServerInfo
-
;;
-
*)
-
echo "Usage: $TOMCAT_PROG {start|stop|restart|condrestart|try-restart|reload|force-reload|status|version}"
-
exit 1
-
esac
-
exit $RETVAL
|
/etc/tomcat5/tomcat5.conf:
|
-
# System-wide
configuration file for tomcat5 services
-
# This will be sourced by tomcat5 and any secondary service
-
# Values will be overridden by service-specific configuration
-
# files in /etc/sysconfig
-
# Use this one to change default values for all services
-
# Change the service specific ones to affect only one service
-
# (see, for instance, /etc/sysconfig/tomcat5)
-
#
-
# tomcat5 service configuration file
-
# you could also override JAVA_HOME here
-
# Where your java installation lives
-
JAVA_HOME="/usr/lib/jvm/java-1.6.0"
-
# Where your tomcat installation lives
-
# That change from spanvious RPM where TOMCAT_HOME
-
# used to be /var/tomcat.
-
# Now /var/tomcat will be the base for webapps only
-
CATALINA_HOME="/usr/share/tomcat5"
-
JASPER_HOME="/usr/share/tomcat5"
-
CATALINA_TMPDIR="/usr/share/tomcat5/temp"
-
JAVA_ENDORSED_DIRS="/usr/share/tomcat5/common/endorsed"
-
# You can pass some parameters to java
-
# here if you wish to
-
#JAVA_OPTS="-Xminf0.1 -Xmaxf0.3"
-
# Use JAVA_OPTS to set java.library.path for libtcnative.so
-
#JAVA_OPTS="-Djava.library.path=/usr/lib64"
-
# Bug 190:
-
# https://www.jpackage.org/bugzilla/show_bug.cgi?id=190
-
# System property catalina.ext.dirs should be set to its default value
-
# for ExtensionValidator to be functional.
-
JAVA_OPTS="$JAVA_OPTS -Dcatalina.ext.dirs=$CATALINA_HOME/shared/lib:$CATALINA_HOME/common/lib"
-
# What user should run tomcat
-
TOMCAT_USER="tomcat"
-
# You can change your tomcat locale here
-
#LANG=en_US
-
# Time to wait in seconds, before killing process
-
SHUTDOWN_WAIT=30
-
# Set the TOMCAT_PID location
-
CATALINA_PID=/var/run/tomcat5.pid
-
# Connector port is 8080 for this tomcat5 instance
-
#CONNECTOR_PORT=8080
-
# Change to yes if you want the tomcat init script to run the relink script
-
RELINK="no"
-
# If you wish to further customize your tomcat environment,
-
# put your own definitions here
-
# (i.e. LD_LIBRARY_PATH for some jdbc drivers)
-
# Just do not forget to export them :)
|
/etc/tomcat5/tomcat5.conf:
|
-
# Service-specific
-
configuration file for tomcat5 services
-
# This will be sourced by the SysV service script after the global
-
# configuration file /etc/tomcat5/tomcat5.conf, thus allowing values
-
# to be overridden on a per-service way
-
#
-
# NEVER change the init script itself:
-
# To change values for all services make your changes in
-
# /etc/tomcat5/tomcat5.conf
-
# To change values
-
for a specific service, change it here
-
# To create a new service
-
, create a link
-
from /etc/init.d/ to
-
# /etc/init.d/tomcat5 (do not copy the init script) and make a copy
-
of the
-
# /etc/sysconfig/tomcat5 file to /etc/sysconfig/ and change
-
# the property values so the two services won't conflict
-
# Register the new service in the system as usual (see chkconfig and similars)
-
#
|
相关推荐
Fedora Core 5 新手指南 本指南由Latvia大学Linux中心和热心帮助的人们维护,文章内容遵守 GNU Free Documentation License 1.2. 本文是Fedora Core 5的上手指南,与Fedora项目和Redhat公司没有联系。
fedora 5 telnet配置fedora 5 telnet配置fedora 5 telnet配置fedora 5 telnet配置fedora 5 telnet配置fedora 5 telnet配置fedora 5 telnet配置
Fedora Core 5入门手册中文版
Red Hat Fedora 5 Unleashed By Andrew Hudson, Paul Hudson Pages: 1104
用快餐式的介绍法,来向即便没有任何Linux背景的您实用地介绍一些使用的操作步骤,主要有读写MSwindows、FC5的办公字处理openoffice、writer、图像处理GIMP、上网浏览、上网聊天、DVD/VCD播放等特性。...
前段时间我在网上fadora 14资源找到的,其中前三个是从普通网站上找到的,分别是Fedora-14-i386-DVD,Fedora-14-x86_64-DVD,Fedora-14-i686-Live-Desktop;后两个种子是在官网找到的,分别是:Fedora-14-i386-DVD....
Fedora 10 的全套中文教程 学习linux 必备资料 共分为9个压缩包,之5 下齐后一次接压即可。
fedora一些安装说明fedora一些安装说明fedora一些安装说明fedora一些安装说明
fedora下mplayer的配置fedora下mplayer的配置fedora下mplayer的配置fedora下mplayer的配置fedora下mplayer的配置
Beginning Fedora Desktop: Fedora 20 Edition is a complete guide to using the Fedora 20 Desktop Linux release as your daily driver for multimedia, productivity, social networking, the GNOME 3 desktop, ...
U盘作为启动盘,成功安装最新Fedora系统Fedora19. (节约了资源,无需刻录光盘,操作简单)
fedora14安装配置fedora14安装配置fedora14安装配置fedora14安装配置
Chapter 5: Accessing and Running Applications. Chapter 6: Publishing with Fedora. Chapter 7: Music, Video, and Images in Linux. Chapter 8: Using the Internet and the Web. Part III: Administering ...
只要按照默认配置安装完Red Hat Fedora Core 5 Linux系统,NFS服务就会被安装在系统中。但是portmap 服务在fedora 12已经改我,不知为什么,不用管它。 2.在终端窗口中输入"rpcinfo -p"命令。如果NFS服务运行正常,...
Beginning Fedora Desktop: Fedora 18 Edition is a complete guide to using the Fedora 18 Desktop Linux release as your daily driver for mail, productivity, social networking, and more. Author and Linux ...
fedora
fedora 7 安装图解
Fedora常用软件安装卸载与设置 Fedora常用软件安装卸载与设置 Fedora常用软件安装卸载与设置
Fedora 11 ,开发代号 Leonidas (雷奥尼达,古斯巴达国王,译者注),正式版已经发布 了! Fedora 是一个基于 RPM 的 Linux 发行版,是一种开源操作系统,由 Redhat 支持并 赞助的 FedoraProject 项目开发。 Fedora 只包含...