Enable multiple instances on same installation.
This keeps the default tomcat.service unchanged (except for internals), and adds template for tomcat@name.service services. In the new world, if you need an instance, you'll create a directory /var/lib/tomcats/name, create {conf temp work webapps} in it, and then systemctl enable tomcat@name.service. This commit doesn't contain anything related to jsvc.
This commit is contained in:
parent
004db978af
commit
0543334466
@ -1,6 +1,6 @@
|
||||
log4j.rootLogger=debug, R
|
||||
log4j.appender.R=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.R.File=${catalina.home}/logs/tomcat.log
|
||||
log4j.appender.R.File=${catalina.base}/logs/tomcat.log
|
||||
log4j.appender.R.MaxFileSize=10MB
|
||||
log4j.appender.R.MaxBackupIndex=10
|
||||
log4j.appender.R.layout=org.apache.log4j.PatternLayout
|
||||
|
@ -1,79 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This script provides systemd activation of the tomcat service
|
||||
# To create clones of this service:
|
||||
# 1) SERVICE_NAME must be defined before calling this script
|
||||
# 2) Create /etc/sysconfig/${SERVICE_NAME} from /etc/sysconfig/tomcat
|
||||
# to override tomcat defaults
|
||||
|
||||
# SERVICE_NAME is a required value only if the service name is
|
||||
# different from 'tomcat'
|
||||
#
|
||||
export NAME="${SERVICE_NAME:-tomcat}"
|
||||
|
||||
#I'll bet this isn't required.
|
||||
# unset ISBOOT
|
||||
|
||||
# For SELinux we need to use 'runuser' not 'su'
|
||||
if [ -x "/sbin/runuser" ]; then
|
||||
SU="/sbin/runuser -s /bin/sh"
|
||||
else
|
||||
SU="/bin/su -s /bin/sh"
|
||||
fi
|
||||
|
||||
# Path to the tomcat launch script
|
||||
TOMCAT_SCRIPT="/usr/sbin/tomcat"
|
||||
|
||||
# Define the tomcat username
|
||||
TOMCAT_USER="${TOMCAT_USER:-tomcat}"
|
||||
|
||||
# TOMCAT_LOG should be different from catalina.out.
|
||||
# Usually the below config is all that is necessary
|
||||
TOMCAT_LOG=/var/log/${NAME}/${NAME}-sysd.log
|
||||
|
||||
# Get the tomcat config (use this for environment specific settings)
|
||||
TOMCAT_CFG="/etc/tomcat/tomcat.conf"
|
||||
if [ -r "$TOMCAT_CFG" ]; then
|
||||
. $TOMCAT_CFG
|
||||
fi
|
||||
|
||||
# Get instance specific config file
|
||||
if [ -r "/etc/sysconfig/${NAME}" ]; then
|
||||
. /etc/sysconfig/${NAME}
|
||||
fi
|
||||
|
||||
# See how we were called.
|
||||
function start() {
|
||||
# fix permissions on the log and pid files
|
||||
export CATALINA_PID="/var/run/${NAME}.pid"
|
||||
|
||||
touch $TOMCAT_LOG 2>&1
|
||||
if [ "$?" -eq "0" ]; then
|
||||
chown ${TOMCAT_USER}:${TOMCAT_USER} $TOMCAT_LOG
|
||||
fi
|
||||
|
||||
if [ "$SECURITY_MANAGER" = "true" ]; then
|
||||
${TOMCAT_SCRIPT} start-security >> $TOMCAT_LOG 2>&1
|
||||
else
|
||||
${TOMCAT_SCRIPT} start #>> $TOMCAT_LOG 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
function stop() {
|
||||
${TOMCAT_SCRIPT} stop >> $TOMCAT_LOG 2>&1
|
||||
}
|
||||
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
esac
|
||||
|
@ -1,30 +1,37 @@
|
||||
# System-wide configuration file for tomcat services
|
||||
# This will be sourced by tomcat and any secondary service
|
||||
# Values will be overridden by service-specific configuration
|
||||
# files in /etc/sysconfig
|
||||
# This will be loaded by systemd as an environment file,
|
||||
# so please keep the syntax.
|
||||
#
|
||||
# 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/tomcat)
|
||||
# There are 2 "classes" of startup behavior in this package.
|
||||
# The old one, the default service named tomcat.service.
|
||||
# The new named instances are called tomcat@instance.service.
|
||||
#
|
||||
# Use this file to change default values for all services.
|
||||
# Change the service specific ones to affect only one service.
|
||||
# For tomcat.service it's /etc/sysconfig/tomcat, for
|
||||
# tomcat@instance it's /etc/sysconfig/tomcat@instance.
|
||||
|
||||
# This variable is used to figure out if config is loaded or not.
|
||||
TOMCAT_CFG_LOADED="1"
|
||||
|
||||
# In new-style instances, if CATALINA_BASE isn't specified, it will
|
||||
# be constructed by joining TOMCATS_BASE and NAME.
|
||||
TOMCATS_BASE="/var/lib/tomcats/"
|
||||
|
||||
# Where your java installation lives
|
||||
JAVA_HOME="/usr/lib/jvm/jre"
|
||||
|
||||
# Where your tomcat installation lives
|
||||
CATALINA_BASE="@@@TCHOME@@@"
|
||||
CATALINA_HOME="@@@TCHOME@@@"
|
||||
JASPER_HOME="@@@TCHOME@@@"
|
||||
CATALINA_TMPDIR="@@@TCTEMP@@@"
|
||||
|
||||
# System-wide tmp
|
||||
CATALINA_TMPDIR="/var/cache/tomcat/temp"
|
||||
|
||||
# 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=@@@LIBDIR@@@"
|
||||
|
||||
# What user should run tomcat
|
||||
TOMCAT_USER="tomcat"
|
||||
#JAVA_OPTS="-Djava.library.path=/usr/lib"
|
||||
|
||||
# You can change your tomcat locale here
|
||||
#LANG="en_US"
|
||||
@ -33,18 +40,9 @@ TOMCAT_USER="tomcat"
|
||||
SECURITY_MANAGER="false"
|
||||
|
||||
# Time to wait in seconds, before killing process
|
||||
SHUTDOWN_WAIT="30"
|
||||
|
||||
# Whether to annoy the user with "attempting to shut down" messages or not
|
||||
SHUTDOWN_VERBOSE="false"
|
||||
|
||||
# Set the TOMCAT_PID location
|
||||
CATALINA_PID="/var/run/tomcat.pid"
|
||||
|
||||
# Connector port is 8080 for this tomcat instance
|
||||
#CONNECTOR_PORT="8080"
|
||||
# TODO(stingray): does nothing, fix.
|
||||
# SHUTDOWN_WAIT="30"
|
||||
|
||||
# If you wish to further customize your tomcat environment,
|
||||
# put your own definitions here
|
||||
# (i.e. LD_LIBRARY_PATH for some jdbc drivers)
|
||||
|
||||
|
319
tomcat-7.0.init
319
tomcat-7.0.init
@ -1,319 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# tomcat This shell script takes care of starting and stopping Tomcat
|
||||
#
|
||||
# chkconfig: - 80 20
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: tomcat
|
||||
# Required-Start: $network $syslog
|
||||
# Required-Stop: $network $syslog
|
||||
# Default-Start:
|
||||
# Default-Stop:
|
||||
# Description: Release implementation for Servlet 3.0 and JSP 2.2
|
||||
# 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
|
||||
#
|
||||
|
||||
## Source function library.
|
||||
#. /etc/rc.d/init.d/functions
|
||||
# Source LSB function library.
|
||||
if [ -r /lib/lsb/init-functions ]; then
|
||||
. /lib/lsb/init-functions
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DISTRIB_ID=`lsb_release -i -s 2>/dev/null`
|
||||
|
||||
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 -s /bin/sh"
|
||||
else
|
||||
SU="/bin/su -s /bin/sh"
|
||||
fi
|
||||
|
||||
# Get the tomcat config (use this for environment specific settings)
|
||||
TOMCAT_CFG="/etc/tomcat/tomcat.conf"
|
||||
if [ -r "$TOMCAT_CFG" ]; then
|
||||
. $TOMCAT_CFG
|
||||
fi
|
||||
|
||||
# Get instance specific config file
|
||||
if [ -r "/etc/sysconfig/${NAME}" ]; then
|
||||
. /etc/sysconfig/${NAME}
|
||||
fi
|
||||
|
||||
# Define which connector port to use
|
||||
CONNECTOR_PORT="${CONNECTOR_PORT:-8080}"
|
||||
|
||||
# Path to the tomcat launch script
|
||||
TOMCAT_SCRIPT="/usr/sbin/tomcat"
|
||||
|
||||
# Tomcat program name
|
||||
TOMCAT_PROG="${NAME}"
|
||||
|
||||
# Define the tomcat username
|
||||
TOMCAT_USER="${TOMCAT_USER:-tomcat}"
|
||||
|
||||
# Define the tomcat log file
|
||||
TOMCAT_LOG="${TOMCAT_LOG:-${CATALINA_HOME}/logs/${NAME}-initd.log}"
|
||||
|
||||
|
||||
RETVAL="0"
|
||||
|
||||
# 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() {
|
||||
if [ ! -d "$CATALINA_HOME" ]; then
|
||||
echo "$CATALINA_HOME does not exist, creating"
|
||||
if [ ! -d "/usr/share/${NAME}" ]; then
|
||||
mkdir /usr/share/${NAME}
|
||||
cp -pLR /usr/share/tomcat/* /usr/share/${NAME}
|
||||
fi
|
||||
mkdir -p /var/log/${NAME} \
|
||||
/var/cache/${NAME} \
|
||||
/var/tmp/${NAME}
|
||||
ln -fs /var/cache/${NAME} ${CATALINA_HOME}/work
|
||||
ln -fs /var/tmp/${NAME} ${CATALINA_HOME}/temp
|
||||
cp -pLR /usr/share/${NAME}/bin $CATALINA_HOME
|
||||
cp -pLR /usr/share/${NAME}/conf $CATALINA_HOME
|
||||
ln -fs /usr/share/java/tomcat ${CATALINA_HOME}/lib
|
||||
ln -fs /usr/share/tomcat/webapps ${CATALINA_HOME}/webapps
|
||||
chown ${TOMCAT_USER}:${TOMCAT_USER} /var/log/${NAME}
|
||||
fi
|
||||
}
|
||||
|
||||
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 [ "$RETVAL" != "0" ]; then
|
||||
log_failure_msg
|
||||
return
|
||||
fi
|
||||
if [ -f "/var/lock/subsys/${NAME}" ]; then
|
||||
if [ -s "/var/run/${NAME}.pid" ]; then
|
||||
read kpid < /var/run/${NAME}.pid
|
||||
# if checkpid $kpid 2>&1; then
|
||||
if [ -d "/proc/${kpid}" ]; then
|
||||
log_success_msg
|
||||
if [ "$DISTRIB_ID" = "MandrivaLinux" ]; then
|
||||
echo
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
# fix permissions on the log and pid files
|
||||
export CATALINA_PID="/var/run/${NAME}.pid"
|
||||
touch $CATALINA_PID 2>&1 || RETVAL="4"
|
||||
if [ "$RETVAL" -eq "0" -a "$?" -eq "0" ]; then
|
||||
chown ${TOMCAT_USER}:${TOMCAT_USER} $CATALINA_PID
|
||||
fi
|
||||
[ "$RETVAL" -eq "0" ] && touch $TOMCAT_LOG 2>&1 || RETVAL="4"
|
||||
if [ "$RETVAL" -eq "0" -a "$?" -eq "0" ]; then
|
||||
chown ${TOMCAT_USER}:${TOMCAT_USER} $TOMCAT_LOG
|
||||
fi
|
||||
if [ "$CATALINA_HOME" != "/usr/share/tomcat" -a "$RETVAL" -eq "0" ]; 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
|
||||
parseOptions
|
||||
if [ "$RETVAL" -eq "0" -a "$SECURITY_MANAGER" = "true" ]; then
|
||||
$SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} start-security" \
|
||||
>> ${TOMCAT_LOG} 2>&1 || RETVAL="4"
|
||||
else
|
||||
|
||||
[ "$RETVAL" -eq "0" ] && $SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} start" >> ${TOMCAT_LOG} 2>&1 || RETVAL="4"
|
||||
fi
|
||||
if [ "$RETVAL" -eq "0" ]; then
|
||||
log_success_msg
|
||||
touch /var/lock/subsys/${NAME}
|
||||
else
|
||||
log_failure_msg "Error code ${RETVAL}"
|
||||
fi
|
||||
if [ "$DISTRIB_ID" = "MandrivaLinux" ]; then
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
function stop() {
|
||||
echo -n "Stopping ${TOMCAT_PROG}: "
|
||||
if [ -f "/var/lock/subsys/${NAME}" ]; then
|
||||
parseOptions
|
||||
if [ "$RETVAL" -eq "0" ]; then
|
||||
touch /var/lock/subsys/${NAME} 2>&1 || RETVAL="4"
|
||||
[ "$RETVAL" -eq "0" ] && $SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} stop" >> ${TOMCAT_LOG} 2>&1 || RETVAL="4"
|
||||
fi
|
||||
if [ "$RETVAL" -eq "0" ]; then
|
||||
count="0"
|
||||
if [ -s "/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 [ "$SHUTDOWN_VERBOSE" = "true" ]; then
|
||||
echo "waiting for processes $kpid to exit"
|
||||
fi
|
||||
sleep 1
|
||||
let count="${count}+1"
|
||||
done
|
||||
if [ "$count" -gt "$SHUTDOWN_WAIT" ]; then
|
||||
if [ "$SHUTDOWN_VERBOSE" = "true" ]; then
|
||||
log_warning_msg "killing processes which did not stop after ${SHUTDOWN_WAIT} seconds"
|
||||
fi
|
||||
kill -9 $kpid
|
||||
fi
|
||||
log_success_msg
|
||||
fi
|
||||
rm -f /var/lock/subsys/${NAME} /var/run/${NAME}.pid
|
||||
else
|
||||
log_failure_msg
|
||||
RETVAL="4"
|
||||
fi
|
||||
else
|
||||
log_success_msg
|
||||
RETVAL="0"
|
||||
fi
|
||||
if [ "$DISTRIB_ID" = "MandrivaLinux" ]; then
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
function usage()
|
||||
{
|
||||
echo "Usage: $0 {start|stop|restart|condrestart|try-restart|reload|force-reload|status|version}"
|
||||
RETVAL="2"
|
||||
}
|
||||
|
||||
# See how we were called.
|
||||
RETVAL="0"
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
condrestart|try-restart)
|
||||
if [ -s "/var/run/${NAME}.pid" ]; then
|
||||
stop
|
||||
start
|
||||
fi
|
||||
;;
|
||||
reload)
|
||||
RETVAL="3"
|
||||
;;
|
||||
force-reload)
|
||||
if [ -s "/var/run/${NAME}.pid" ]; then
|
||||
stop
|
||||
start
|
||||
fi
|
||||
;;
|
||||
status)
|
||||
if [ -s "/var/run/${NAME}.pid" ]; then
|
||||
read kpid < /var/run/${NAME}.pid
|
||||
if [ -d "/proc/${kpid}" ]; then
|
||||
log_success_msg "${NAME} (pid ${kpid}) is running..."
|
||||
RETVAL="0"
|
||||
else
|
||||
# The pid file exists but the process is not running
|
||||
log_warning_msg "PID file exists, but process is not running"
|
||||
RETVAL="1"
|
||||
fi
|
||||
else
|
||||
pid="$(/usr/bin/pgrep -d , -u ${TOMCAT_USER} -G ${TOMCAT_USER} java)"
|
||||
if [ -z "$pid" ]; then
|
||||
# status ${NAME}
|
||||
# RETVAL="$?"
|
||||
log_success_msg "${NAME} is stopped"
|
||||
RETVAL="3"
|
||||
else
|
||||
log_success_msg "${NAME} (pid $pid) is running..."
|
||||
RETVAL="0"
|
||||
fi
|
||||
fi
|
||||
if [ -f /var/lock/subsys/${NAME} ]; then
|
||||
pid="$(/usr/bin/pgrep -d , -u ${TOMCAT_USER} -G ${TOMCAT_USER} java)"
|
||||
# The lockfile exists but the process is not running
|
||||
if [ -z "$pid" ]; then
|
||||
log_failure_msg "${NAME} lockfile exists but process is not running"
|
||||
RETVAL="2"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
version)
|
||||
${TOMCAT_SCRIPT} version
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
@ -1,56 +1,11 @@
|
||||
# Service-specific configuration file for tomcat. This will be sourced by
|
||||
# the SysV init script after the global configuration file
|
||||
# /etc/tomcat/tomcat.conf, thus allowing values to be overridden in
|
||||
# a per-service manner.
|
||||
#
|
||||
# NEVER change the init script itself. To change values for all services make
|
||||
# your changes in /etc/tomcat/tomcat.conf
|
||||
#
|
||||
# To change values for a specific service make your edits here.
|
||||
# To create a new service create a link from /etc/init.d/<your new service> to
|
||||
# /etc/init.d/tomcat (do not copy the init script) and make a copy of the
|
||||
# /etc/sysconfig/tomcat file to /etc/sysconfig/<your new service> 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).
|
||||
#
|
||||
# systemd for the default service (tomcat.service)
|
||||
# If you want to customize named instance, make a similar file
|
||||
# and name it tomcat@instancename.
|
||||
|
||||
# Where your java installation lives
|
||||
#JAVA_HOME="/usr/lib/jvm/java"
|
||||
|
||||
# Where your tomcat installation lives
|
||||
# You will not need to set this, usually. For default service it equals
|
||||
# CATALINA_HOME. For named service, it equals ${TOMCATS_BASE}${NAME}
|
||||
#CATALINA_BASE="@@@TCHOME@@@"
|
||||
#CATALINA_HOME="@@@TCHOME@@@"
|
||||
#JASPER_HOME="@@@TCHOME@@@"
|
||||
#CATALINA_TMPDIR="@@@TCTEMP@@@"
|
||||
|
||||
# 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=@@@LIBDIR@@@"
|
||||
|
||||
# What user should run tomcat
|
||||
#TOMCAT_USER="tomcat"
|
||||
|
||||
# You can change your tomcat locale here
|
||||
#LANG="en_US"
|
||||
|
||||
# Run tomcat under the Java Security Manager
|
||||
#SECURITY_MANAGER="false"
|
||||
|
||||
# Time to wait in seconds, before killing process
|
||||
#SHUTDOWN_WAIT="30"
|
||||
|
||||
# Whether to annoy the user with "attempting to shut down" messages or not
|
||||
#SHUTDOWN_VERBOSE="false"
|
||||
|
||||
# Set the TOMCAT_PID location
|
||||
#CATALINA_PID="/var/run/tomcat.pid"
|
||||
|
||||
# Connector port is 8080 for this tomcat instance
|
||||
#CONNECTOR_PORT="8080"
|
||||
|
||||
# If you wish to further customize your tomcat environment,
|
||||
# put your own definitions here
|
||||
# (i.e. LD_LIBRARY_PATH for some jdbc drivers)
|
||||
|
||||
# Please take a look at /etc/tomcat/tomcat.conf to have an idea what you
|
||||
# can override.
|
||||
|
@ -1,83 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -r /usr/share/java-utils/java-functions ]; then
|
||||
. /usr/share/java-utils/java-functions
|
||||
else
|
||||
echo "Can't read Java functions library, aborting"
|
||||
exit 1
|
||||
if [ "$1" = "version" ]; then
|
||||
. /usr/libexec/tomcat/preamble
|
||||
exec ${JAVACMD} -classpath ${CATALINA_HOME}/lib/catalina.jar \
|
||||
org.apache.catalina.util.ServerInfo
|
||||
fi
|
||||
|
||||
# Get the tomcat config (use this for environment specific settings)
|
||||
if [ -z "${TOMCAT_CFG}" ]; then
|
||||
TOMCAT_CFG="/etc/tomcat/tomcat.conf"
|
||||
SRV="tomcat"
|
||||
if [ -n "$2" ]; then
|
||||
SRV="tomcat@$2"
|
||||
fi
|
||||
|
||||
if [ -r "$TOMCAT_CFG" ]; then
|
||||
. $TOMCAT_CFG
|
||||
fi
|
||||
|
||||
# Get instance specific config file
|
||||
if [ -r "/etc/sysconfig/${NAME}" ]; then
|
||||
. /etc/sysconfig/${NAME}
|
||||
fi
|
||||
|
||||
set_javacmd
|
||||
cd ${CATALINA_HOME}
|
||||
# CLASSPATH munging
|
||||
if [ ! -z "$CLASSPATH" ] ; then
|
||||
CLASSPATH="$CLASSPATH":
|
||||
fi
|
||||
|
||||
if [ -n "$JSSE_HOME" ]; then
|
||||
CLASSPATH="${CLASSPATH}$(build-classpath jcert jnet jsse 2>/dev/null):"
|
||||
fi
|
||||
CLASSPATH="${CLASSPATH}${CATALINA_HOME}/bin/bootstrap.jar"
|
||||
CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/tomcat-juli.jar"
|
||||
CLASSPATH="${CLASSPATH}:$(build-classpath commons-daemon 2>/dev/null)"
|
||||
|
||||
if [ "$1" = "start" ]; then
|
||||
${JAVACMD} $JAVA_OPTS $CATALINA_OPTS \
|
||||
-classpath "$CLASSPATH" \
|
||||
-Dcatalina.base="$CATALINA_BASE" \
|
||||
-Dcatalina.home="$CATALINA_HOME" \
|
||||
-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \
|
||||
-Djava.io.tmpdir="$CATALINA_TMPDIR" \
|
||||
-Djava.util.logging.config.file="${CATALINA_BASE}/conf/logging.properties" \
|
||||
-Djava.util.logging.manager="org.apache.juli.ClassLoaderLogManager" \
|
||||
org.apache.catalina.startup.Bootstrap start \
|
||||
>> ${CATALINA_BASE}/logs/catalina.out 2>&1 &
|
||||
if [ ! -z "$CATALINA_PID" ]; then
|
||||
echo $! > $CATALINA_PID
|
||||
fi
|
||||
elif [ "$1" = "start-security" ]; then
|
||||
${JAVACMD} $JAVA_OPTS $CATALINA_OPTS \
|
||||
-classpath "$CLASSPATH" \
|
||||
-Dcatalina.base="$CATALINA_BASE" \
|
||||
-Dcatalina.home="$CATALINA_HOME" \
|
||||
-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \
|
||||
-Djava.io.tmpdir="$CATALINA_TMPDIR" \
|
||||
-Djava.security.manager \
|
||||
-Djava.security.policy=="${CATALINA_BASE}/conf/catalina.policy" \
|
||||
-Djava.util.logging.config.file="${CATALINA_BASE}/conf/logging.properties" \
|
||||
-Djava.util.logging.manager="org.apache.juli.ClassLoaderLogManager" \
|
||||
org.apache.catalina.startup.Bootstrap start \
|
||||
>> ${CATALINA_BASE}/logs/catalina.out 2>&1 &
|
||||
if [ ! -z "$CATALINA_PID" ]; then
|
||||
echo $! > $CATALINA_PID
|
||||
fi
|
||||
systemctl start ${SRV}.service
|
||||
elif [ "$1" = "stop" ]; then
|
||||
${JAVACMD} $JAVA_OPTS \
|
||||
-classpath "$CLASSPATH" \
|
||||
-Dcatalina.base="$CATALINA_BASE" \
|
||||
-Dcatalina.home="$CATALINA_HOME" \
|
||||
-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \
|
||||
-Djava.io.tmpdir="$CATALINA_TMPDIR" \
|
||||
org.apache.catalina.startup.Bootstrap stop \
|
||||
>> ${CATALINA_BASE}/logs/catalina.out 2>&1
|
||||
systemctl stop ${SRV}.service
|
||||
elif [ "$1" = "version" ]; then
|
||||
${JAVACMD} -classpath ${CATALINA_HOME}/lib/catalina.jar \
|
||||
org.apache.catalina.util.ServerInfo
|
||||
else
|
||||
echo "Usage: $0 {start|start-security|stop|version}"
|
||||
echo "Usage: $0 {start|stop|version} [server-id]"
|
||||
exit 1
|
||||
fi
|
||||
|
18
tomcat-named.service
Normal file
18
tomcat-named.service
Normal file
@ -0,0 +1,18 @@
|
||||
[Unit]
|
||||
Description=Apache Tomcat Web Application Container
|
||||
After=syslog.target network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
EnvironmentFile=/etc/tomcat/tomcat.conf
|
||||
Environment="NAME=%I"
|
||||
EnvironmentFile=-/etc/sysconfig/tomcat@%I
|
||||
ExecStart=/usr/libexec/tomcat/server start
|
||||
ExecStop=/usr/libexec/tomcat/server stop
|
||||
SuccessExitStatus=143
|
||||
User=tomcat
|
||||
Group=tomcat
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
50
tomcat-preamble
Normal file
50
tomcat-preamble
Normal file
@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -r /usr/share/java-utils/java-functions ]; then
|
||||
. /usr/share/java-utils/java-functions
|
||||
else
|
||||
echo "Can't read Java functions library, aborting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the tomcat config (use this for environment specific settings)
|
||||
|
||||
if [ -z "${TOMCAT_CFG_LOADED}" ]; then
|
||||
if [ -z "${TOMCAT_CFG}" ]; then
|
||||
TOMCAT_CFG="/etc/tomcat/tomcat.conf"
|
||||
fi
|
||||
. $TOMCAT_CFG
|
||||
fi
|
||||
|
||||
if [ -z "$CATALINA_BASE" ]; then
|
||||
if [ -n "$NAME" ]; then
|
||||
if [ -z "$TOMCATS_BASE" ]; then
|
||||
TOMCATS_BASE="/var/lib/tomcats/"
|
||||
fi
|
||||
CATALINA_BASE="${TOMCATS_BASE}${NAME}"
|
||||
else
|
||||
CATALINA_BASE="${CATALINA_HOME}"
|
||||
fi
|
||||
fi
|
||||
|
||||
VERBOSE=1
|
||||
set_javacmd
|
||||
cd ${CATALINA_HOME}
|
||||
# CLASSPATH munging
|
||||
if [ ! -z "$CLASSPATH" ] ; then
|
||||
CLASSPATH="$CLASSPATH":
|
||||
fi
|
||||
|
||||
if [ -n "$JSSE_HOME" ]; then
|
||||
CLASSPATH="${CLASSPATH}$(build-classpath jcert jnet jsse 2>/dev/null):"
|
||||
fi
|
||||
CLASSPATH="${CLASSPATH}${CATALINA_HOME}/bin/bootstrap.jar"
|
||||
CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/tomcat-juli.jar"
|
||||
CLASSPATH="${CLASSPATH}:$(build-classpath commons-daemon 2>/dev/null)"
|
||||
|
||||
if [ -z "$LOGGING_PROPERTIES" ] ; then
|
||||
LOGGING_PROPERTIES="${CATALINA_BASE}/conf/logging.properties"
|
||||
if [ ! -f "${LOGGING_PROPERTIES}" ] ; then
|
||||
LOGGING_PROPERTIES="${CATALINA_HOME}/conf/logging.properties"
|
||||
fi
|
||||
fi
|
24
tomcat-server
Normal file
24
tomcat-server
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
. /usr/libexec/tomcat/preamble
|
||||
|
||||
MAIN_CLASS=org.apache.catalina.startup.Bootstrap
|
||||
|
||||
FLAGS="$JAVA_OPTS $CATALINA_OPTS"
|
||||
OPTIONS="-Dcatalina.base=$CATALINA_BASE \
|
||||
-Dcatalina.home=$CATALINA_HOME \
|
||||
-Djava.endorsed.dirs=$JAVA_ENDORSED_DIRS \
|
||||
-Djava.io.tmpdir=$CATALINA_TMPDIR \
|
||||
-Djava.util.logging.config.file=${LOGGING_PROPERTIES} \
|
||||
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
|
||||
|
||||
if [ "$1" = "start" ] ; then
|
||||
if [ "${SECURITY_MANAGER}" = "true" ] ; then
|
||||
OPTIONS="${OPTIONS} \
|
||||
-Djava.security.manager \
|
||||
-Djava.security.policy==\"${CATALINA_BASE}/conf/catalina.policy\""
|
||||
fi
|
||||
run start
|
||||
elif [ "$1" = "stop" ] ; then
|
||||
run stop
|
||||
fi
|
57
tomcat.spec
57
tomcat.spec
@ -54,7 +54,7 @@
|
||||
Name: tomcat
|
||||
Epoch: 0
|
||||
Version: %{major_version}.%{minor_version}.%{micro_version}
|
||||
Release: 2%{?dist}
|
||||
Release: 3%{?dist}
|
||||
Summary: Apache Servlet/JSP Engine, RI for Servlet %{servletspec}/JSP %{jspspec} API
|
||||
|
||||
Group: System Environment/Daemons
|
||||
@ -62,7 +62,6 @@ License: ASL 2.0
|
||||
URL: http://tomcat.apache.org/
|
||||
Source0: http://www.apache.org/dist/tomcat/tomcat-%{major_version}/v%{version}/src/%{packdname}.tar.gz
|
||||
Source1: %{name}-%{major_version}.%{minor_version}.conf
|
||||
Source2: %{name}-%{major_version}.%{minor_version}.init
|
||||
Source3: %{name}-%{major_version}.%{minor_version}.sysconfig
|
||||
Source4: %{name}-%{major_version}.%{minor_version}.wrapper
|
||||
Source5: %{name}-%{major_version}.%{minor_version}.logrotate
|
||||
@ -77,11 +76,12 @@ Source13: jasper-el-OSGi-MANIFEST.MF
|
||||
Source14: jasper-OSGi-MANIFEST.MF
|
||||
Source15: tomcat-api-OSGi-MANIFEST.MF
|
||||
Source16: tomcat-juli-OSGi-MANIFEST.MF
|
||||
Source17: %{name}-%{major_version}.%{minor_version}-tomcat-sysd
|
||||
Source18: %{name}-%{major_version}.%{minor_version}-tomcat-jsvc-sysd
|
||||
Source19: %{name}-%{major_version}.%{minor_version}-jsvc.wrapper
|
||||
Source20: %{name}-%{major_version}.%{minor_version}-jsvc.service
|
||||
|
||||
Source30: tomcat-preamble
|
||||
Source31: tomcat-server
|
||||
Source32: tomcat-named.service
|
||||
|
||||
Patch0: %{name}-%{major_version}.%{minor_version}-bootstrap-MANIFEST.MF.patch
|
||||
Patch1: %{name}-%{major_version}.%{minor_version}-tomcat-users-webapp.patch
|
||||
@ -152,16 +152,6 @@ Requires: jpackage-utils
|
||||
%description javadoc
|
||||
Javadoc generated documentation for Apache Tomcat.
|
||||
|
||||
%package systemv
|
||||
Group: System Environment/Daemons
|
||||
Summary: Systemv scripts for Apache Tomcat
|
||||
Requires: %{name} = %{epoch}:%{version}-%{release}
|
||||
Requires(post): chkconfig
|
||||
Requires(postun): chkconfig
|
||||
|
||||
%description systemv
|
||||
SystemV scripts to start and stop tomcat service
|
||||
|
||||
%package jsvc
|
||||
Group: System Environment/Daemons
|
||||
Summary: Apache jsvc wrapper for Apache Tomcat as separate service
|
||||
@ -336,6 +326,7 @@ zip -u output/build/bin/tomcat-juli.jar META-INF/MANIFEST.MF
|
||||
%{__install} -d -m 0775 ${RPM_BUILD_ROOT}%{tempdir}
|
||||
%{__install} -d -m 0775 ${RPM_BUILD_ROOT}%{workdir}
|
||||
%{__install} -d -m 0755 ${RPM_BUILD_ROOT}%{_unitdir}
|
||||
%{__install} -d -m 0755 ${RPM_BUILD_ROOT}%{_libexecdir}/%{name}
|
||||
|
||||
# move things into place
|
||||
# First copy supporting libs to tomcat lib
|
||||
@ -357,21 +348,16 @@ popd
|
||||
-e "s|\@\@\@TCTEMP\@\@\@|%{tempdir}|g" \
|
||||
-e "s|\@\@\@LIBDIR\@\@\@|%{_libdir}|g" %{SOURCE3} \
|
||||
> ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/%{name}
|
||||
%{__install} -m 0644 %{SOURCE2} \
|
||||
${RPM_BUILD_ROOT}%{_initrddir}/%{name}
|
||||
%{__install} -m 0644 %{SOURCE4} \
|
||||
${RPM_BUILD_ROOT}%{_sbindir}/%{name}
|
||||
%{__install} -m 0644 %{SOURCE11} \
|
||||
${RPM_BUILD_ROOT}%{_unitdir}/%{name}.service
|
||||
%{__install} -m 0644 %{SOURCE17} \
|
||||
${RPM_BUILD_ROOT}%{_sbindir}/%{name}-sysd
|
||||
%{__install} -m 0644 %{SOURCE19} \
|
||||
${RPM_BUILD_ROOT}%{_sbindir}/%{name}-jsvc
|
||||
%{__install} -m 0644 %{SOURCE20} \
|
||||
${RPM_BUILD_ROOT}%{_unitdir}/%{name}-jsvc.service
|
||||
%{__install} -m 0644 %{SOURCE18} \
|
||||
${RPM_BUILD_ROOT}%{_sbindir}/%{name}-jsvc-sysd
|
||||
%{__ln_s} %{name} ${RPM_BUILD_ROOT}%{_sbindir}/d%{name}
|
||||
%{__sed} -e "s|\@\@\@TCLOG\@\@\@|%{logdir}|g" %{SOURCE5} \
|
||||
> ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d/%{name}
|
||||
%{__sed} -e "s|\@\@\@TCHOME\@\@\@|%{homedir}|g" \
|
||||
@ -382,6 +368,14 @@ popd
|
||||
-e "s|\@\@\@TCTEMP\@\@\@|%{tempdir}|g" \
|
||||
-e "s|\@\@\@LIBDIR\@\@\@|%{_libdir}|g" %{SOURCE7} \
|
||||
> ${RPM_BUILD_ROOT}%{_bindir}/%{name}-tool-wrapper
|
||||
|
||||
%{__install} -m 0755 %{SOURCE30} \
|
||||
${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/preamble
|
||||
%{__install} -m 0755 %{SOURCE31} \
|
||||
${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/server
|
||||
%{__install} -m 0644 %{SOURCE32} \
|
||||
${RPM_BUILD_ROOT}%{_unitdir}/%{name}@.service
|
||||
|
||||
# create jsp and servlet API symlinks
|
||||
pushd ${RPM_BUILD_ROOT}%{_javadir}
|
||||
%{__mv} %{name}/jsp-api.jar %{name}-jsp-%{jspspec}-api.jar
|
||||
@ -508,10 +502,6 @@ EOF
|
||||
# install but don't activate
|
||||
%systemd_post %{name}.service
|
||||
|
||||
%post systemv
|
||||
# install but don't activate
|
||||
/sbin/chkconfig --add %{name}
|
||||
|
||||
%post jsp-%{jspspec}-api
|
||||
%{_sbindir}/update-alternatives --install %{_javadir}/jsp.jar jsp \
|
||||
%{_javadir}/%{name}-jsp-%{jspspec}-api.jar 20200
|
||||
@ -524,10 +514,6 @@ EOF
|
||||
%{_sbindir}/update-alternatives --install %{_javadir}/elspec.jar elspec \
|
||||
%{_javadir}/%{name}-el-%{elspec}-api.jar 20300
|
||||
|
||||
%preun systemv
|
||||
%{_initrddir}/%{name} stop >/dev/null 2>&1
|
||||
/sbin/chkconfig --del %{name}
|
||||
|
||||
%preun
|
||||
# clean tempdir and workdir on removal or upgrade
|
||||
%{__rm} -rf %{workdir}/* %{tempdir}/*
|
||||
@ -567,7 +553,10 @@ fi
|
||||
%attr(0755,root,root) %{_bindir}/%{name}-tool-wrapper
|
||||
%attr(0755,root,root) %{_sbindir}/%{name}
|
||||
%attr(0644,root,root) %{_unitdir}/%{name}.service
|
||||
%attr(0755,root,root) %{_sbindir}/%{name}-sysd
|
||||
%attr(0644,root,root) %{_unitdir}/%{name}@.service
|
||||
%attr(0755,root,root) %dir %{_libexecdir}/%{name}
|
||||
%attr(0755,root,root) %{_libexecdir}/%{name}/preamble
|
||||
%attr(0755,root,root) %{_libexecdir}/%{name}/server
|
||||
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
|
||||
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
|
||||
%attr(0755,root,tomcat) %dir %{basedir}
|
||||
@ -664,11 +653,6 @@ fi
|
||||
%{appdir}/examples
|
||||
%{appdir}/sample
|
||||
|
||||
%files systemv
|
||||
%defattr(755,root,root,0755)
|
||||
%{_sbindir}/d%{name}
|
||||
%{_initrddir}/%{name}
|
||||
|
||||
%files jsvc
|
||||
%defattr(755,root,root,0755)
|
||||
%{_sbindir}/%{name}-jsvc
|
||||
@ -676,6 +660,13 @@ fi
|
||||
%attr(0644,root,root) %{_unitdir}/%{name}-jsvc.service
|
||||
|
||||
%changelog
|
||||
* Tue Jun 11 2013 Paul Komkoff <i@stingr.net> 0:7.0.40-3
|
||||
- Dropped systemv inits. Bye-bye.
|
||||
- Updated the systemd wrappers to allow running multiple instances.
|
||||
Added wrapper scripts to do that, ported the original non-named
|
||||
service file to work with the same wrappers, updated
|
||||
/usr/sbin/tomcat to call systemctl.
|
||||
|
||||
* Sat May 11 2013 Ivan Afonichev <ivan.afonichev@gmail.com> 0:7.0.40-1
|
||||
- Updated to 7.0.40
|
||||
- Resolves: rhbz 956569 added missing commons-pool link
|
||||
|
Loading…
Reference in New Issue
Block a user