SHA256
1
0
forked from pool/tomcat

Accepting request 385746 from home:dmacvicar:branches:Java:packages

- package was partly merged with the scripts used in the
  Fedora distribution
- support running multiple tomcat instances on the same server
  (fate#317783)
- add catalina-jmx-remote.jar (fate#318403)
- remove sysvinit support: systemd is required

OBS-URL: https://build.opensuse.org/request/show/385746
OBS-URL: https://build.opensuse.org/package/show/Java:packages/tomcat?expand=0&rev=83
This commit is contained in:
Tomáš Chvátal 2016-04-07 12:59:42 +00:00 committed by Git OBS Bridge
parent 505ecb2dd1
commit 122197843b
18 changed files with 391 additions and 445 deletions

View File

@ -1,25 +0,0 @@
# Systemd unit file for tomcat
#
# You can clone this service by:
# 1.) Add a new EnvironmentFile declaring the new values for CATALINA_BASE
# and others
# 2.) Define new Environment=JSVC_PIDFILE=/var/run/tomcat-foo.pid if you want
# to run more than one service
[Unit]
Description=Apache Tomcat Web Application Container JSVC wrapper
After=network.target
[Service]
Type=simple
EnvironmentFile=/etc/tomcat/tomcat.conf
#PIDFILE is needed for jsvc
#Environment=JSVC_PIDFILE=/var/run/tomcat-jsvc.pid
ExecStart=/usr/sbin/tomcat-jsvc-sysd start
ExecStop=/usr/sbin/tomcat-jsvc-sysd stop
StandardOutput=syslog
SyslogIdentifier=%n
SyslogFacility=daemon
[Install]
WantedBy=multi-user.target

View File

@ -1,145 +0,0 @@
#!/bin/bash
#
# This script provides systemd activation of the tomcat service and tomcat
# throught jsvc wrapper
# check the basic environment variables
if [[ -z "${CATALINA_BASE}" || \
-z "${CATALINA_HOME}" || \
-z "${CATALINA_TMPDIR}" ]]; then
echo "ERROR: one of CATALINA_BASE, CATALINA_HOME or CATALINA_TMPDIR is not defined" >&2
echo " use proper EnvironmentFile= in your .service file" >&2
exit 1
fi
if [[ "${0}" =~ tomcat-jsvc ]]; then
if [[ ! -x /usr/bin/jsvc ]]; then
echo "ERROR: cannot use ${0}, /usr/bin/jsvc does not exists" >&2
exit 1
fi
USE_JSVC=true
JSVC_PIDFILE=${JSVC_PIDFILE:-/var/run/${0##*/}}
else
USE_JSVC=false
fi
#### from /usr/sbin/dtomcat
if [[ -r /usr/share/java-utils/java-functions ]]; then
. /usr/share/java-utils/java-functions
else
echo "ERROR: Can't read Java functions library, aborting" >&2
exit 1
fi
set_javacmd
# CLASSPATH munging
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)"
#sanitize the classpath - remove double and trailing colons
CLASSPATH="`echo ${CLASSPATH} | sed 's/::+/:/g; s/^://; s/:$//g'`"
# See how we were called.
function start() {
local ret
# running as root is not allowed if not running with jsvc
if ! ${USE_JSVC} && [[ $(id -u) == 0 ]]; then
echo "ERROR: starting tomcat under uid 0 is not supported" >&2
echo " use appropriate User/Group settings in service file" >&2
echo " see man systemd.exec for details" >&2
exit 2
fi
if [[ "$SECURITY_MANAGER" = "true" ]]; then
DSECURITY_MANAGER="-Djava.security.manager"
DSECURITY_POLICY="-Djava.security.policy=${CATALINA_BASE}/conf/catalina.policy"
else
unset DSECURITY_MANAGER
unset DSECURITY_POLICY
fi
if ${USE_JSVC}; then
JAVACMD="/usr/bin/jsvc -pidfile ${JSVC_PIDFILE} -nodetach -user ${TOMCAT_USER:-tomcat}"
fi
#bnc#779538
cd ${CATALINA_BASE}
exec ${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" ${DSECURITY_MANAGER} ${DSECURITY_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
}
function stop() {
local ret
if ${USE_JSVC}; then
#XXX: foo is needed because of funny jsvc parser needs a class name
/usr/bin/jsvc -stop -pidfile ${JSVC_PIDFILE} foo
ret=${?}
if [[ $ret == 0 ]]; then
rm -f ${JSVC_PIDFILE}
fi
else
${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
ret=${?}
# workaround the 143 code emmited by jvm in case of sigterm
# using ExecStart=- will ignore all other failures as well
if [[ ret == 143 ]]; then
ret=0
fi
fi
return $ret
}
function version() {
exec ${JAVACMD} -classpath ${CATALINA_HOME}/lib/catalina.jar \
org.apache.catalina.util.ServerInfo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
version)
version
;;
*)
echo "Usage: $0 {start|stop|restart|version}" >&2
exit 1
esac

View File

@ -1,24 +0,0 @@
# Systemd unit file for tomcat
#
# You can clone this service by:
# 1.) Add a new EnvironmentFile declaring the new values for CATALINA_BASE
# and others
[Unit]
Description=Apache Tomcat Web Application Container
After=network.target
[Service]
Type=simple
EnvironmentFile=/etc/tomcat/tomcat.conf
User=tomcat
Group=tomcat
ExecStart=/usr/sbin/tomcat-sysd start
ExecStop=/usr/sbin/tomcat-sysd stop
StandardOutput=syslog
SyslogIdentifier=%n
SyslogFacility=daemon
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target

View File

@ -1,7 +1,5 @@
Index: apache-tomcat-7.0.2-src/res/META-INF/bootstrap.jar.manifest --- res/META-INF/bootstrap.jar.manifest.orig 2010-04-06 10:11:09.000000000 -0600
=================================================================== +++ res/META-INF/bootstrap.jar.manifest 2010-04-06 10:45:56.000000000 -0600
--- apache-tomcat-7.0.2-src.orig/res/META-INF/bootstrap.jar.manifest 2010-08-04 01:26:39.000000000 +0200
+++ apache-tomcat-7.0.2-src/res/META-INF/bootstrap.jar.manifest 2010-09-23 11:25:07.237277450 +0200
@@ -1,6 +1,5 @@ @@ -1,6 +1,5 @@
Manifest-Version: 1.0 Manifest-Version: 1.0
Main-Class: org.apache.catalina.startup.Bootstrap Main-Class: org.apache.catalina.startup.Bootstrap

View File

@ -10,39 +10,36 @@ else
echo "Can't find functions library, aborting" echo "Can't find functions library, aborting"
exit 1 exit 1
fi fi
# Get the tomcat config (use this for environment specific settings) # Get the tomcat config (use this for environment specific settings)
if [ -z "${TOMCAT_CFG}" ]; then if [ -z "${TOMCAT_CFG}" ]; then
TOMCAT_CFG="/etc/tomcat/tomcat.conf" TOMCAT_CFG="/etc/tomcat/tomcat.conf"
fi fi
if [ -r "$TOMCAT_CFG" ]; then if [ -r "$TOMCAT_CFG" ]; then
. $TOMCAT_CFG . $TOMCAT_CFG
fi fi
set_javacmd set_javacmd
# CLASSPATH munging # CLASSPATH munging
if [ -n "$JSSE_HOME" ]; then if [ -n "$JSSE_HOME" ]; then
CLASSPATH="${CLASSPATH}:$(build-classpath jcert jnet jsse 2>/dev/null)" CLASSPATH="${CLASSPATH}:$(build-classpath jcert jnet jsse 2>/dev/null)"
fi fi
CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/bootstrap.jar" CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/bootstrap.jar"
CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/tomcat-juli.jar" CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/tomcat-juli.jar"
#sanitize the classpath - remove double and trailing colons
CLASSPATH="`echo ${CLASSPATH} | sed 's/::+/:/g; s/^://; s/:$//g'`"
export CLASSPATH export CLASSPATH
# Configuration # Configuration
MAIN_CLASS="org.apache.catalina.startup.Tool" MAIN_CLASS="org.apache.catalina.startup.Tool"
BASE_FLAGS="-Dcatalina.home=\"$CATALINA_HOME\"" BASE_FLAGS="-Dcatalina.home=\"$CATALINA_HOME\""
BASE_OPTIONS="" BASE_OPTIONS=""
BASE_JARS="commons-daemon tomcat/catalina servlet" BASE_JARS="commons-daemon tomcat/catalina servlet"
# Set parameters # Set parameters
set_classpath $BASE_JARS set_classpath $BASE_JARS
set_flags $BASE_FLAGS set_flags $BASE_FLAGS
set_options $BASE_OPTIONS set_options $BASE_OPTIONS
# Let's start # Let's start
run -server org.apache.catalina.realm.RealmBase "$@" run -server org.apache.catalina.realm.RealmBase "$@"

21
tomcat-8.0-jsvc.service Normal file
View File

@ -0,0 +1,21 @@
# Systemd unit file for tomcat
#
# To create clones of this service:
# 1) By default SERVICE_NAME=tomcat. When cloned, the value must be defined
# before tomcat-sysd is called.
# 2) Create /etc/sysconfig/${SERVICE_NAME} from /etc/sysconfig/tomcat
# to override tomcat defaults
[Unit]
Description=Apache Tomcat Web Application Container JSVC wrapper
After=syslog.target network.target
[Service]
Type=simple
EnvironmentFile=/etc/tomcat/tomcat.conf
Environment="NAME=" "USE_JSVC=true"
ExecStart=/usr/lib/tomcat/server start
ExecStop=/usr/lib/tomcat/server stop
[Install]
WantedBy=multi-user.target

View File

@ -1,7 +1,5 @@
Index: apache-tomcat-7.0.2-src/conf/tomcat-users.xml --- conf/tomcat-users.xml~ 2008-01-28 17:41:06.000000000 -0500
=================================================================== +++ conf/tomcat-users.xml 2008-03-07 19:40:07.000000000 -0500
--- apache-tomcat-7.0.2-src/conf/tomcat-users.xml 2010-08-04 01:26:35.000000000 +0200
+++ apache-tomcat-7.0.2-src/conf/tomcat-users.xml 2010-09-23 11:27:11.819276755 +0200
@@ -23,4 +23,14 @@ @@ -23,4 +23,14 @@
<user username="both" password="tomcat" roles="tomcat,role1"/> <user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/> <user username="role1" password="tomcat" roles="role1"/>

View File

@ -2,7 +2,7 @@
# #
# tomcat-digest script # tomcat-digest script
# JPackage Project <http://www.jpackage.org/> # JPackage Project <http://www.jpackage.org/>
# Source functions library # Source functions library
if [ -f /usr/share/java-utils/java-functions ] ; then if [ -f /usr/share/java-utils/java-functions ] ; then
. /usr/share/java-utils/java-functions . /usr/share/java-utils/java-functions
@ -10,40 +10,36 @@ else
echo "Can't find functions library, aborting" echo "Can't find functions library, aborting"
exit 1 exit 1
fi fi
# Get the tomcat config (use this for environment specific settings) # Get the tomcat config (use this for environment specific settings)
if [ -z "${TOMCAT_CFG}" ]; then if [ -z "${TOMCAT_CFG}" ]; then
TOMCAT_CFG="/etc/tomcat/tomcat.conf" TOMCAT_CFG="/etc/tomcat/tomcat.conf"
fi fi
if [ -r "$TOMCAT_CFG" ]; then if [ -r "$TOMCAT_CFG" ]; then
. $TOMCAT_CFG . $TOMCAT_CFG
fi fi
set_javacmd set_javacmd
# CLASSPATH munging # CLASSPATH munging
if [ -n "$JSSE_HOME" ]; then if [ -n "$JSSE_HOME" ]; then
CLASSPATH="${CLASSPATH}:$(build-classpath jcert jnet jsse 2>/dev/null)" CLASSPATH="${CLASSPATH}:$(build-classpath jcert jnet jsse 2>/dev/null)"
fi fi
CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/bootstrap.jar" CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/bootstrap.jar"
CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/tomcat-juli.jar" CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/tomcat-juli.jar"
#sanitize the classpath - remove double and trailing colons
CLASSPATH="`echo ${CLASSPATH} | sed 's/::+/:/g; s/^://; s/:$//g'`"
export CLASSPATH export CLASSPATH
# Configuration # Configuration
MAIN_CLASS="org.apache.catalina.startup.Tool" MAIN_CLASS="org.apache.catalina.startup.Tool"
BASE_OPTIONS="" BASE_OPTIONS=""
BASE_FLAGS="-Dcatalina.home=\"$CATALINA_HOME\"" BASE_FLAGS="-Dcatalina.home=\"$CATALINA_HOME\""
BASE_JARS="commons-daemon tomcat/catalina servlet" BASE_JARS="commons-daemon tomcat/catalina servlet"
# Set parameters # Set parameters
set_classpath $BASE_JARS set_classpath $BASE_JARS
set_flags $BASE_FLAGS set_flags $BASE_FLAGS
set_options $BASE_OPTIONS set_options $BASE_OPTIONS
# Let's start # Let's start
run "$@" run "$@"

View File

@ -1,62 +1,52 @@
# System-wide configuration file for tomcat services # System-wide configuration file for tomcat services
# This will be sourced by tomcat and any secondary service # This will be loaded by systemd as an environment file,
# so please keep the syntax. For shell expansion support
# place your custom files as /etc/tomcat/conf.d/*.conf
#
# 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 # Where your java installation lives
JAVA_HOME="@@@JAVAHOME@@@" JAVA_HOME="/usr/lib/jvm/jre"
# Where your tomcat installation lives # Where your tomcat installation lives
CATALINA_HOME="@@@TCHOME@@@" CATALINA_HOME="@@@TCHOME@@@"
# where the given instance lives
CATALINA_BASE="@@@TCHOME@@@" # System-wide tmp
# the temp dir of the instance CATALINA_TMPDIR="/var/cache/tomcat/temp"
CATALINA_TMPDIR="@@@TCTEMP@@@"
# You can pass some parameters to java here if you wish to # You can pass some parameters to java here if you wish to
#JAVA_OPTS="-Xminf0.1 -Xmaxf0.3" #JAVA_OPTS="-Xminf0.1 -Xmaxf0.3"
# Use JAVA_OPTS to set java.library.path for libtcnative.so # Use JAVA_OPTS to set java.library.path for libtcnative.so
#JAVA_OPTS="-Djava.library.path=@@@LIBDIR@@@" #JAVA_OPTS="-Djava.library.path=/usr/lib"
# What user should run tomcat # Set default javax.sql.DataSource factory to apache commons one. See rhbz#1214381
# This value is interpreted differently JAVA_OPTS="-Djavax.sql.DataSource.Factory=org.apache.commons.dbcp.BasicDataSourceFactory"
# 1.) for systemd units derived from tomcat.service, the User/Group settings is used
# 2.) for systemd units derived from tomcat-jsvc.service this value is respected (with tomcat as a default)
# 3.) for sysv init script, this value is respected (with tomcat as a default)
#TOMCAT_USER="tomcat"
# You can change your tomcat locale here # You can change your tomcat locale here
#LANG="en_US" #LANG="en_US"
# Run tomcat under the Java Security Manager # Run tomcat under the Java Security Manager
SECURITY_MANAGER="false" SECURITY_MANAGER="false"
# Time to wait in seconds, before killing process # Time to wait in seconds, before killing process
SHUTDOWN_WAIT="30" # TODO(stingray): does nothing, fix.
# SHUTDOWN_WAIT="30"
# Whether to annoy the user with "attempting to shut down" messages or not
SHUTDOWN_VERBOSE="false"
# Set the TOMCAT_PID location
# WARNING: does not make any sense for systemd users
#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, # If you wish to further customize your tomcat environment,
# put your own definitions here # put your own definitions here
# (i.e. LD_LIBRARY_PATH for some jdbc drivers) # (i.e. LD_LIBRARY_PATH for some jdbc drivers)
# Clear work directory when tomcat is stopped or restarted
CLEAR_WORK="false"
# Java runtime options used when the "start", or "run" command is executed
# Use # it if you want:
# Set a location of JAAS config file
# CATALINA_OPTS="-Djava.security.auth.login.config=$CATALINA_HOME/conf/jaas.config"
# To collect data on how long garbage collection is taking
# CATALINA_OPTS="-verbose:gc"
# Make jikes error messages compatible with jasper
# CATALINA_OPTS="-Dbuild.compiler.emacs=true"
# Debug the permission (WARNING - This will generate many megabytes of output!)
# CATALINA_OPTS="-Djava.security.debug=all"

23
tomcat-8.0.service Normal file
View File

@ -0,0 +1,23 @@
# Systemd unit file for default tomcat
#
# To create clones of this service:
# DO NOTHING, use tomcat@.service instead.
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target
[Service]
Type=simple
EnvironmentFile=/etc/tomcat/tomcat.conf
Environment="NAME="
EnvironmentFile=-/etc/sysconfig/tomcat
ExecStart=/usr/lib/tomcat/server start
ExecStop=/usr/lib/tomcat/server stop
SuccessExitStatus=143
User=tomcat
Group=tomcat
[Install]
WantedBy=multi-user.target

11
tomcat-8.0.sysconfig Normal file
View File

@ -0,0 +1,11 @@
# Service-specific configuration file for tomcat. This will be sourced by
# systemd for the default service (tomcat.service)
# If you want to customize named instance, make a similar file
# and name it tomcat@instancename.
# 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@@@"
# Please take a look at /etc/tomcat/tomcat.conf to have an idea what you
# can override.

View File

@ -1,77 +1,24 @@
#!/bin/bash #!/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}" ]; then
TOMCAT_CFG="/etc/tomcat/tomcat.conf"
fi
if [ -r "$TOMCAT_CFG" ]; then
. $TOMCAT_CFG
fi
set_javacmd
# CLASSPATH munging
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)"
#sanitize the classpath - remove double and trailing colons if [ "$1" = "version" ]; then
CLASSPATH="`echo ${CLASSPATH} | sed 's/::+/:/g; s/^://; s/:$//g'`" . /usr/lib/tomcat/preamble
exec ${JAVACMD} -classpath ${CATALINA_HOME}/lib/catalina.jar \
org.apache.catalina.util.ServerInfo
fi
SRV="tomcat"
if [ -n "$2" ]; then
SRV="tomcat@$2"
fi
if [ "$1" = "start" ]; then if [ "$1" = "start" ]; then
${JAVACMD} $JAVA_OPTS $CATALINA_OPTS \ systemctl start ${SRV}.service
-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
elif [ "$1" = "stop" ]; then elif [ "$1" = "stop" ]; then
${JAVACMD} $JAVA_OPTS \ systemctl stop ${SRV}.service
-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
elif [ "$1" = "version" ]; then elif [ "$1" = "version" ]; then
${JAVACMD} -classpath ${CATALINA_HOME}/lib/catalina.jar \ ${JAVACMD} -classpath ${CATALINA_HOME}/lib/catalina.jar \
org.apache.catalina.util.ServerInfo org.apache.catalina.util.ServerInfo
else else
echo "Usage: $0 {start|start-security|stop|version}" echo "Usage: $0 {start|stop|version} [server-id]"
exit 1 exit 1
fi fi

42
tomcat-functions Normal file
View File

@ -0,0 +1,42 @@
#!/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
_save_function() {
local ORIG_FUNC=$(declare -f $1)
local NEWNAME_FUNC="$2${ORIG_FUNC#$1}"
eval "$NEWNAME_FUNC"
}
run_jsvc(){
if [ -x /usr/bin/jsvc ]; then
TOMCAT_USER="tomcat"
JSVC="/usr/bin/jsvc"
JSVC_OPTS="-nodetach -pidfile /var/run/jsvc-tomcat${NAME}.pid -user ${TOMCAT_USER} -outfile ${CATALINA_BASE}/logs/catalina.out -errfile ${CATALINA_BASE}/logs/catalina.out"
if [ "$1" = "stop" ]; then
JSVC_OPTS="${JSVC_OPTS} -stop"
fi
exec "${JSVC}" ${JSVC_OPTS} ${FLAGS} -classpath "${CLASSPATH}" ${OPTIONS} "${MAIN_CLASS}" "${@}"
else
echo "Can't find /usr/bin/jsvc executable"
fi
}
_save_function run run_java
run() {
if [ "${USE_JSVC}" = "true" ] ; then
run_jsvc $@
else
run_java $@
fi
}

26
tomcat-named.service Normal file
View File

@ -0,0 +1,26 @@
# Systemd unit file for tomcat instances.
#
# To create clones of this service:
# 0. systemctl enable tomcat@name.service
# 1. create catalina.base directory structure in
# /var/lib/tomcats/name
# 2. profit.
[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/lib/tomcat/server start
ExecStop=/usr/lib/tomcat/server stop
SuccessExitStatus=143
User=tomcat
Group=tomcat
[Install]
WantedBy=multi-user.target

52
tomcat-preamble Normal file
View File

@ -0,0 +1,52 @@
#!/bin/bash
. /usr/lib/tomcat/functions
# 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 [ -d "${TOMCAT_CONFD=/etc/tomcat/conf.d}" ]; then
for file in ${TOMCAT_CONFD}/*.conf ; do
if [ -f "$file" ] ; then
. "$file"
fi
done
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

25
tomcat-server Normal file
View File

@ -0,0 +1,25 @@
#!/bin/bash
. /usr/lib/tomcat/preamble
MAIN_CLASS=org.apache.catalina.startup.Bootstrap
FLAGS="$JAVA_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
FLAGS="${FLAGS} $CATALINA_OPTS"
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

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Thu Mar 31 08:18:39 UTC 2016 - dmacvicar@suse.de
- package was partly merged with the scripts used in the
Fedora distribution
- support running multiple tomcat instances on the same server
(fate#317783)
- add catalina-jmx-remote.jar (fate#318403)
- remove sysvinit support: systemd is required
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Feb 29 12:45:46 UTC 2016 - dmacvicar@suse.de Mon Feb 29 12:45:46 UTC 2016 - dmacvicar@suse.de

View File

@ -17,7 +17,6 @@
# #
%global with_systemd 0%{?suse_version} > 1210
%define jspspec 2.3 %define jspspec 2.3
%define servletspec 3.1 %define servletspec 3.1
%define elspec 3.0 %define elspec 3.0
@ -26,7 +25,8 @@
%define micro_version 32 %define micro_version 32
%define packdname apache-tomcat-%{version}-src %define packdname apache-tomcat-%{version}-src
# FHS 2.3 compliant tree structure - http://www.pathname.com/fhs/2.3/ # FHS 2.3 compliant tree structure - http://www.pathname.com/fhs/2.3/
%define appdir /srv/%{name}/webapps %global basedir /srv/%{name}
%define appdir %{basedir}/webapps
%define bindir %{_datadir}/%{name}/bin %define bindir %{_datadir}/%{name}/bin
%define confdir %{_sysconfdir}/%{name} %define confdir %{_sysconfdir}/%{name}
%define homedir %{_datadir}/%{name} %define homedir %{_datadir}/%{name}
@ -45,6 +45,7 @@ Url: http://tomcat.apache.org
Source0: http://www.apache.org/dist/tomcat/tomcat-%{major_version}/v%{version}/src/%{packdname}.tar.gz Source0: http://www.apache.org/dist/tomcat/tomcat-%{major_version}/v%{version}/src/%{packdname}.tar.gz
Source1: %{name}-%{major_version}.%{minor_version}.conf Source1: %{name}-%{major_version}.%{minor_version}.conf
Source2: %{name}-%{major_version}.%{minor_version}.init Source2: %{name}-%{major_version}.%{minor_version}.init
Source3: %{name}-%{major_version}.%{minor_version}.sysconfig
Source4: %{name}-%{major_version}.%{minor_version}.wrapper Source4: %{name}-%{major_version}.%{minor_version}.wrapper
Source5: %{name}-%{major_version}.%{minor_version}.logrotate Source5: %{name}-%{major_version}.%{minor_version}.logrotate
Source6: %{name}-%{major_version}.%{minor_version}-digest.script Source6: %{name}-%{major_version}.%{minor_version}-digest.script
@ -52,15 +53,18 @@ Source7: %{name}-%{major_version}.%{minor_version}-tool-wrapper.script
Source8: servlet-api-OSGi-MANIFEST.MF Source8: servlet-api-OSGi-MANIFEST.MF
Source9: jsp-api-OSGi-MANIFEST.MF Source9: jsp-api-OSGi-MANIFEST.MF
Source10: %{name}-%{major_version}.%{minor_version}-log4j.properties Source10: %{name}-%{major_version}.%{minor_version}-log4j.properties
Source11: tomcat-7.0.service Source11: %{name}-%{major_version}.%{minor_version}.service
Source12: el-api-OSGi-MANIFEST.MF Source12: el-api-OSGi-MANIFEST.MF
Source13: jasper-el-OSGi-MANIFEST.MF Source13: jasper-el-OSGi-MANIFEST.MF
Source14: jasper-OSGi-MANIFEST.MF Source14: jasper-OSGi-MANIFEST.MF
Source15: tomcat-api-OSGi-MANIFEST.MF Source15: tomcat-api-OSGi-MANIFEST.MF
Source16: tomcat-juli-OSGi-MANIFEST.MF Source16: tomcat-juli-OSGi-MANIFEST.MF
Source17: tomcat-7.0-tomcat-sysd Source20: %{name}-%{major_version}.%{minor_version}-jsvc.service
Source20: tomcat-7.0-jsvc.service Source21: tomcat-functions
Source30: dbcp-tomcat-build.xml Source30: tomcat-preamble
Source31: tomcat-server
Source32: tomcat-named.service
Source40: dbcp-tomcat-build.xml
Source1000: tomcat-rpmlintrc Source1000: tomcat-rpmlintrc
Source1001: http://www.apache.org/dist/tomcat/tomcat-%{major_version}/v%{version}/src/%{packdname}.tar.gz.asc Source1001: http://www.apache.org/dist/tomcat/tomcat-%{major_version}/v%{version}/src/%{packdname}.tar.gz.asc
Source1002: %{name}.keyring Source1002: %{name}.keyring
@ -95,6 +99,8 @@ BuildRequires: javapackages-tools
BuildRequires: junit BuildRequires: junit
BuildRequires: log4j BuildRequires: log4j
BuildRequires: sed BuildRequires: sed
BuildRequires: systemd
BuildRequires: systemd-rpm-macros
BuildRequires: unzip BuildRequires: unzip
BuildRequires: wsdl4j BuildRequires: wsdl4j
BuildRequires: zip BuildRequires: zip
@ -104,19 +110,16 @@ Requires: jakarta-commons-dbcp
Requires: jakarta-commons-logging Requires: jakarta-commons-logging
Requires: jakarta-commons-pool Requires: jakarta-commons-pool
Requires: log4j Requires: log4j
Requires(post): /sbin/chkconfig # FIXME: use proper Requires(pre/post/preun/...)
PreReq: %fillup_prereq
Requires(post): systemd-rpm-macros
Requires(pre): %{_sbindir}/groupadd Requires(pre): %{_sbindir}/groupadd
Requires(pre): %{_sbindir}/useradd Requires(pre): %{_sbindir}/useradd
Requires(preun): /sbin/chkconfig
Recommends: libtcnative-1-0 >= 1.1.24 Recommends: libtcnative-1-0 >= 1.1.24
Recommends: logrotate
BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch BuildArch: noarch
%if %{with_systemd}
BuildRequires: systemd
%systemd_requires %systemd_requires
%else
Recommends: logrotate
%endif
%description %description
Tomcat is the servlet container that is used in the official Reference Tomcat is the servlet container that is used in the official Reference
@ -186,7 +189,6 @@ Obsoletes: jsp < %{jspspec}
%description jsp-2_3-api %description jsp-2_3-api
Apache Tomcat JSP API implementation classes version 2.3 Apache Tomcat JSP API implementation classes version 2.3
%if %{with_systemd}
%package jsvc %package jsvc
Summary: Apache jsvc wrapper for Apache Tomcat as separate service Summary: Apache jsvc wrapper for Apache Tomcat as separate service
Group: Productivity/Networking/Web/Servers Group: Productivity/Networking/Web/Servers
@ -197,7 +199,6 @@ Requires: apache-commons-daemon-jsvc
Systemd service and wrapper scripts to start tomcat with jsvc, Systemd service and wrapper scripts to start tomcat with jsvc,
which allows tomcat to perform some privileged operations which allows tomcat to perform some privileged operations
(e.g. bind to a port < 1024) and then switch identity to a non-privileged user. (e.g. bind to a port < 1024) and then switch identity to a non-privileged user.
%endif
%package lib %package lib
Summary: Libraries needed to run the Tomcat Web container Summary: Libraries needed to run the Tomcat Web container
@ -242,8 +243,8 @@ The ROOT and examples web applications for Apache Tomcat
# remove pre-built binaries and windows files # remove pre-built binaries and windows files
find . -type f \( -name "*.bat" -o -name "*.class" -o -name Thumbs.db -o -name "*.gz" -o \ find . -type f \( -name "*.bat" -o -name "*.class" -o -name Thumbs.db -o -name "*.gz" -o \
-name "*.jar" -o -name "*.war" -o -name "*.zip" \) | xargs -t rm -f -name "*.jar" -o -name "*.war" -o -name "*.zip" \) | xargs -t rm -f
%patch0 -p1 %patch0
%patch1 -p1 %patch1
%patch2 -p1 %patch2 -p1
%patch3 %patch3
%patch4 -p1 %patch4 -p1
@ -257,7 +258,7 @@ sed -i -e '/build-date/ d' webapps/docs/tomcat-docs.xsl
mkdir -p commons/dbcp mkdir -p commons/dbcp
pushd commons/dbcp pushd commons/dbcp
cp %{SOURCE30} . cp %{SOURCE40} .
mkdir src mkdir src
cp -r %{_usrsrc}/commons-dbcp/java src/ cp -r %{_usrsrc}/commons-dbcp/java src/
export CLASSPATH=$(build-classpath commons-pool-tomcat5) export CLASSPATH=$(build-classpath commons-pool-tomcat5)
@ -297,7 +298,7 @@ ant -Dbase.path="." \
-Dno.build.dbcp=true \ -Dno.build.dbcp=true \
-Dversion="%{version}" \ -Dversion="%{version}" \
-Dversion.build="%{micro_version}" \ -Dversion.build="%{micro_version}" \
deploy dist-prepare dist-source javadoc package embed-jars deploy dist-prepare dist-source javadoc package embed-jars extras-jmx-remote
# remove some jars that we'll replace with symlinks later # remove some jars that we'll replace with symlinks later
rm output/build/bin/commons-daemon.jar \ rm output/build/bin/commons-daemon.jar \
@ -345,25 +346,27 @@ export NO_BRP_CHECK_BYTECODE_VERSION=true
install -d -m 0755 %{buildroot}%{_bindir} install -d -m 0755 %{buildroot}%{_bindir}
install -d -m 0755 %{buildroot}%{_sbindir} install -d -m 0755 %{buildroot}%{_sbindir}
install -d -m 0755 %{buildroot}%{_javadocdir}/%{name} install -d -m 0755 %{buildroot}%{_javadocdir}/%{name}
install -d -m 0755 %{buildroot}%{_initrddir}
%if %{with_systemd} install -d -m 0755 %{buildroot}%{_systemddir}
install -d -m 0755 %{buildroot}%{_unitdir}
%else
install -d -m 0755 %{buildroot}%{_initddir}
install -d -m 0755 %{buildroot}%{_sysconfdir}/logrotate.d install -d -m 0755 %{buildroot}%{_sysconfdir}/logrotate.d
%endif install -d -m 0755 %{buildroot}%{_sysconfdir}/sysconfig
install -d -m 0755 %{buildroot}%{_localstatedir}/log/%{name}
install -d -m 0755 %{buildroot}%{appdir} install -d -m 0755 %{buildroot}%{appdir}
install -d -m 0755 %{buildroot}%{bindir} install -d -m 0755 %{buildroot}%{bindir}
install -d -m 0755 %{buildroot}%{confdir} install -d -m 0775 %{buildroot}%{confdir}
install -d -m 0755 %{buildroot}%{libdir}
install -d -m 0755 %{buildroot}%{logdir}
install -d -m 0755 %{buildroot}%{homedir}
install -d -m 0755 %{buildroot}%{tempdir}
install -d -m 0775 %{buildroot}%{workdir}
install -d -m 0755 %{buildroot}%{cachedir}/Catalina/localhost install -d -m 0755 %{buildroot}%{cachedir}/Catalina/localhost
install -d -m 0755 %{buildroot}/%{_sbindir} install -d -m 0775 %{buildroot}%{confdir}/conf.d
/bin/echo "Place your custom *.conf files here. Shell expansion is supported." > %{buildroot}%{confdir}/conf.d/README
install -d -m 0755 %{buildroot}%{libdir}
install -d -m 0775 %{buildroot}%{logdir}
/bin/touch %{buildroot}%{logdir}/catalina.out
install -d -m 0775 %{buildroot}%{_localstatedir}/lib/tomcats
/bin/echo "%{name}-%{major_version}.%{minor_version}.%{micro_version} RPM installed" >> %{buildroot}%{logdir}/catalina.out
install -d -m 0775 %{buildroot}%{homedir}
install -d -m 0775 %{buildroot}%{tempdir}
install -d -m 0775 %{buildroot}%{workdir}
install -d -m 0755 %{buildroot}%{_unitdir}
install -d -m 0755 %{buildroot}%{_libexecdir}/%{name}
install -d -m 0755 %{buildroot}%{_localstatedir}/adm/fillup-templates
# move things into place # move things into place
# First copy supporting libs to tomcat lib # First copy supporting libs to tomcat lib
@ -379,6 +382,11 @@ pushd output/embed
cp -a *.jar %{buildroot}%{libdir} cp -a *.jar %{buildroot}%{libdir}
popd popd
# tomcat extras
pushd output/extras
cp -a *.jar %{buildroot}%{libdir}
popd
# bnc#847505: add missing tomcat-dbcp.jar # bnc#847505: add missing tomcat-dbcp.jar
cp -a commons/dbcp/dbcp-tomcat5/commons-dbcp-tomcat5.jar %{buildroot}/%{libdir}/tomcat-dbcp.jar cp -a commons/dbcp/dbcp-tomcat5/commons-dbcp-tomcat5.jar %{buildroot}/%{libdir}/tomcat-dbcp.jar
@ -386,42 +394,42 @@ cp -a commons/dbcp/dbcp-tomcat5/commons-dbcp-tomcat5.jar %{buildroot}/%{libdir}/
cp -a output/dist/webapps/docs/api/* %{buildroot}%{_javadocdir}/%{name} cp -a output/dist/webapps/docs/api/* %{buildroot}%{_javadocdir}/%{name}
sed -e "s|\@\@\@TCHOME\@\@\@|%{homedir}|g" \ sed -e "s|\@\@\@TCHOME\@\@\@|%{homedir}|g" \
-e "s|\@\@\@TCTEMP\@\@\@|%{tempdir}|g" \ -e "s|\@\@\@TCTEMP\@\@\@|%{tempdir}|g" \
-e "s|\@\@\@JAVAHOME\@\@\@|%{_sysconfdir}/alternatives/jre|g" \ -e "s|\@\@\@LIBDIR\@\@\@|%{_libdir}|g" %{SOURCE1} \
-e "s|\@\@\@LIBDIR\@\@\@|%{_libdir}|g" %{SOURCE1} \
> %{buildroot}%{confdir}/%{name}.conf > %{buildroot}%{confdir}/%{name}.conf
sed -e "s|\@\@\@TCHOME\@\@\@|%{homedir}|g" \
%if %{with_systemd} -e "s|\@\@\@TCTEMP\@\@\@|%{tempdir}|g" \
-e "s|\@\@\@LIBDIR\@\@\@|%{_libdir}|g" %{SOURCE3} \
> %{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}
install -m 0644 %{SOURCE4} \
%{buildroot}%{_sbindir}/%{name}
install -m 0644 %{SOURCE11} \ install -m 0644 %{SOURCE11} \
%{buildroot}%{_unitdir}/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
install -m 0644 %{SOURCE17} \
%{buildroot}%{_sbindir}/%{name}-sysd
install -m 0644 %{SOURCE20} \ install -m 0644 %{SOURCE20} \
%{buildroot}%{_unitdir}/%{name}-jsvc.service %{buildroot}%{_unitdir}/%{name}-jsvc.service
(cd %{buildroot}%{_sbindir}; ln -s %{name}-sysd %{name}-jsvc-sysd)
ln -sf %{_sbindir}/service %{buildroot}/%{_sbindir}/rc%{name}
ln -sf %{_sbindir}/service %{buildroot}/%{_sbindir}/rc%{name}-jsvc
%else
install -m 0755 %{SOURCE2} \
%{buildroot}%{_initddir}/%{name}
ln -sf %{_initddir}/%{name} %{buildroot}/%{_sbindir}/rc%{name}
%endif
install -m 0755 %{SOURCE4} \
%{buildroot}%{_sbindir}/d%{name}
%if ! %{with_systemd}
sed -e "s|\@\@\@TCLOG\@\@\@|%{logdir}|g" %{SOURCE5} \ sed -e "s|\@\@\@TCLOG\@\@\@|%{logdir}|g" %{SOURCE5} \
> %{buildroot}%{_sysconfdir}/logrotate.d/%{name} > %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
%endif
sed -e "s|\@\@\@TCHOME\@\@\@|%{homedir}|g" \ sed -e "s|\@\@\@TCHOME\@\@\@|%{homedir}|g" \
-e "s|\@\@\@TCTEMP\@\@\@|%{tempdir}|g" \ -e "s|\@\@\@TCTEMP\@\@\@|%{tempdir}|g" \
-e "s|\@\@\@LIBDIR\@\@\@|%{_libdir}|g" %{SOURCE6} \ -e "s|\@\@\@LIBDIR\@\@\@|%{_libdir}|g" %{SOURCE6} \
> %{buildroot}%{_bindir}/%{name}-digest > %{buildroot}%{_bindir}/%{name}-digest
sed -e "s|\@\@\@TCHOME\@\@\@|%{homedir}|g" \ sed -e "s|\@\@\@TCHOME\@\@\@|%{homedir}|g" \
-e "s|\@\@\@TCTEMP\@\@\@|%{tempdir}|g" \ -e "s|\@\@\@TCTEMP\@\@\@|%{tempdir}|g" \
-e "s|\@\@\@LIBDIR\@\@\@|%{_libdir}|g" %{SOURCE7} \ -e "s|\@\@\@LIBDIR\@\@\@|%{_libdir}|g" %{SOURCE7} \
> %{buildroot}%{_bindir}/%{name}-tool-wrapper > %{buildroot}%{_bindir}/%{name}-tool-wrapper
install -m 0644 %{SOURCE21} \
%{buildroot}%{_libexecdir}/%{name}/functions
install -m 0755 %{SOURCE30} \
%{buildroot}%{_libexecdir}/%{name}/preamble
install -m 0755 %{SOURCE31} \
%{buildroot}%{_libexecdir}/%{name}/server
install -m 0644 %{SOURCE32} \
%{buildroot}%{_unitdir}/%{name}@.service
ln -sf %{_sbindir}/service %{buildroot}/%{_sbindir}/rc%{name}
ln -sf %{_sbindir}/service %{buildroot}/%{_sbindir}/rc%{name}-jsvc
# create jsp and servlet and el API symlinks # create jsp and servlet and el API symlinks
pushd %{buildroot}%{_javadir} pushd %{buildroot}%{_javadir}
mv %{name}/jsp-api.jar %{name}-jsp-%{jspspec}-api.jar mv %{name}/jsp-api.jar %{name}-jsp-%{jspspec}-api.jar
@ -568,7 +576,7 @@ install -d -m 0755 %{buildroot}/%{_sysconfdir}/ant.d/
echo "%{name}/catalina-ant" > %{buildroot}/%{_sysconfdir}/ant.d/catalina-ant echo "%{name}/catalina-ant" > %{buildroot}/%{_sysconfdir}/ant.d/catalina-ant
%fdupes %{buildroot} /srv/%{name} %fdupes %{buildroot} /srv/%{name}
#bnc#565901 #bnc#565901
ln -sf %{_sbindir}/d%{name} %{buildroot}/%{bindir}/catalina.sh ln -sf %{_sbindir}/%{name} %{buildroot}/%{bindir}/catalina.sh
# Install update-alternatives content # Install update-alternatives content
mkdir -p %{buildroot}%{_sysconfdir}/alternatives mkdir -p %{buildroot}%{_sysconfdir}/alternatives
@ -581,38 +589,33 @@ ln -sf %{_sysconfdir}/alternatives/jsp.jar %{buildroot}%{_javadir}/jsp.jar
touch %{buildroot}%{_sysconfdir}/alternatives/servlet.jar touch %{buildroot}%{_sysconfdir}/alternatives/servlet.jar
ln -sf %{_sysconfdir}/alternatives/servlet.jar %{buildroot}%{_javadir}/servlet.jar ln -sf %{_sysconfdir}/alternatives/servlet.jar %{buildroot}%{_javadir}/servlet.jar
mkdir -p %{buildroot}%{_tmpfilesdir}
cat > %{buildroot}%{_tmpfilesdir}/%{name}.conf <<EOF
f %{_localstatedir}/run/%{name}.pid 0644 tomcat tomcat -
EOF
%pre %pre
# add the tomcat user and group # add the tomcat user and group
%{_sbindir}/groupadd -r tomcat 2>/dev/null || : %{_sbindir}/groupadd -r tomcat 2>/dev/null || :
%{_sbindir}/useradd -c "Apache Tomcat" -g tomcat \ %{_sbindir}/useradd -c "Apache Tomcat" -g tomcat \
-s /bin/sh -r -d %{homedir} tomcat 2>/dev/null || : -s /bin/sh -r -d %{homedir} tomcat 2>/dev/null || :
%if %{with_systemd}
%service_add_pre %{name}.service %service_add_pre %{name}.service
%endif %service_add_pre %{name}@.service
%post %post
%if %{with_systemd}
%service_add_post %{name}.service %service_add_post %{name}.service
%else %service_add_post %{name}@.service
%{fillup_only %{name}} %fillup_only
%endif %{_bindir}/systemd-tmpfiles --create >/dev/null 2>&1 || :
%preun %preun
%if %{with_systemd}
%service_del_preun %{name}.service %service_del_preun %{name}.service
%else %service_del_preun %{name}@.service
%stop_on_removal %{name}
%endif
%postun %postun
%if %{with_systemd}
%service_del_postun %{name}.service %service_del_postun %{name}.service
%else %service_del_postun %{name}@.service
%insserv_cleanup
%restart_on_update %{name}
%endif
%if %{with_systemd}
%pre jsvc %pre jsvc
%service_add_pre %{name}-jsvc.service %service_add_pre %{name}-jsvc.service
@ -624,7 +627,6 @@ ln -sf %{_sysconfdir}/alternatives/servlet.jar %{buildroot}%{_javadir}/servlet.j
%postun jsvc %postun jsvc
%service_del_postun %{name}-jsvc.service %service_del_postun %{name}-jsvc.service
%endif
%post el-3_0-api %post el-3_0-api
update-alternatives --install %{_javadir}/el_api.jar el_api %{_javadir}/%{name}-el-%{elspec}-api.jar 20300 update-alternatives --install %{_javadir}/el_api.jar el_api %{_javadir}/%{name}-el-%{elspec}-api.jar 20300
@ -665,34 +667,46 @@ rm -f \
%{libdir}/\[ecj\].jar >/dev/null 2>&1 %{libdir}/\[ecj\].jar >/dev/null 2>&1
%files %files
%defattr(-,root,root) %defattr(0664,root,tomcat,0755)
%doc {LICENSE,NOTICE,RELEASE*} %doc {LICENSE,NOTICE,RELEASE*}
%attr(0755,root,root) %{_bindir}/%{name}-digest %attr(0755,root,root) %{_bindir}/%{name}-digest
%attr(0755,root,root) %{_bindir}/%{name}-tool-wrapper %attr(0755,root,root) %{_bindir}/%{name}-tool-wrapper
%attr(0755,root,root) %{_sbindir}/d%{name} %attr(0755,root,root) %{_sbindir}/%{name}
%if %{with_systemd}
%attr(0644,root,root) %{_unitdir}/%{name}.service %attr(0644,root,root) %{_unitdir}/%{name}.service
%attr(0755,root,root) %{_sbindir}/%{name}-sysd %{_sbindir}/rc%{name}
%else %attr(0644,root,root) %{_unitdir}/%{name}@.service
%attr(0755,root,root) %{_initddir}/%{name} %attr(0755,root,root) %dir %{_libexecdir}/%{name}
%endif %attr(0755,root,root) %dir %{_localstatedir}/lib/tomcats
%attr(0755,root,root) %{_libexecdir}/%{name}/functions
%attr(0755,root,root) %{_libexecdir}/%{name}/preamble
%attr(0755,root,root) %{_libexecdir}/%{name}/server
#bnc#565901 #bnc#565901
%{bindir}/catalina.sh %{bindir}/catalina.sh
%if ! %{with_systemd}
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/logrotate.d/%{name} %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%endif %attr(0755,root,tomcat) %dir %{basedir}
# bnc#726307 %attr(0755,root,tomcat) %dir %{confdir}
%attr(0775,root,tomcat) %dir %{confdir} %defattr(0664,tomcat,root,0770)
%attr(0775,root,tomcat) %dir %{appdir}
%attr(0770,tomcat,root) %{logdir}
%attr(0660,tomcat,tomcat) %{logdir}/catalina.out
%attr(0770,root,tomcat) %{cachedir}
%defattr(0664,root,tomcat,0770)
%attr(0770,root,tomcat) %dir %{tempdir}
%attr(0770,root,tomcat) %dir %{workdir}
# tomcat group writtable dirs - bnc#625415
%defattr(0664,root,tomcat,0775)
%{confdir}/Catalina %{confdir}/Catalina
%config(noreplace) %{confdir}/%{name}.conf %attr(0775,root,tomcat) %dir %{confdir}/conf.d
%config(noreplace) %{confdir}/*.policy %attr(0664,tomcat,tomcat) %{confdir}/conf.d/README
%config(noreplace) %{confdir}/*.properties %attr(0664,tomcat,tomcat) %config(noreplace) %{confdir}/%{name}.conf
%config(noreplace) %{confdir}/context.xml %attr(0664,tomcat,tomcat) %config(noreplace) %{confdir}/*.policy
%config(noreplace) %{confdir}/server.xml %attr(0664,tomcat,tomcat) %config(noreplace) %{confdir}/*.properties
%config(noreplace) %{confdir}/web.xml %attr(0664,tomcat,tomcat) %config(noreplace) %{confdir}/context.xml
%verify (not user group) %attr(0660,tomcat,tomcat) %config(noreplace) %{confdir}/tomcat-users.xml %attr(0664,tomcat,tomcat) %config(noreplace) %{confdir}/server.xml
%attr(0660,tomcat,tomcat) %config(noreplace) %{confdir}/tomcat-users.xml
%attr(0664,tomcat,tomcat) %config(noreplace) %{confdir}/web.xml
%dir %{homedir} %dir %{homedir}
%dir %{bindir} %{_tmpfilesdir}/%{name}.conf
%{bindir}/bootstrap.jar %{bindir}/bootstrap.jar
%{bindir}/catalina-tasks.xml %{bindir}/catalina-tasks.xml
%{homedir}/lib %{homedir}/lib
@ -701,14 +715,7 @@ rm -f \
%{homedir}/work %{homedir}/work
%{homedir}/logs %{homedir}/logs
%{homedir}/conf %{homedir}/conf
%dir /srv/%{name} %{_localstatedir}/adm/fillup-templates/sysconfig.%{name}
%{_sbindir}/rc%{name}
%{confdir}/Catalina
# tomcat group writtable dirs - bnc#625415
%defattr(0664,root,tomcat,0775)
%verify (not user group) %dir %{appdir}
%verify (not user group) %{logdir}
%verify (not user group) %{cachedir}
%files admin-webapps %files admin-webapps
%defattr(0644,root,root,0755) %defattr(0644,root,root,0755)
@ -795,12 +802,9 @@ rm -f \
%{appdir}/examples %{appdir}/examples
%{appdir}/sample %{appdir}/sample
%if %{with_systemd}
%files jsvc %files jsvc
%defattr(755,root,root,0755) %defattr(755,root,root,0755)
%{_sbindir}/%{name}-jsvc-sysd
%{_sbindir}/rc%{name}-jsvc
%attr(0644,root,root) %{_unitdir}/%{name}-jsvc.service %attr(0644,root,root) %{_unitdir}/%{name}-jsvc.service
%endif %{_sbindir}/rc%{name}-jsvc
%changelog %changelog