/[packages]/updates/2/tomcat/current/SOURCES/tomcat-7.0-tomcat-jsvc-sysd
ViewVC logotype

Contents of /updates/2/tomcat/current/SOURCES/tomcat-7.0-tomcat-jsvc-sysd

Parent Directory Parent Directory | Revision Log Revision Log


Revision 338837 - (show annotations) (download)
Fri Jan 4 23:34:49 2013 UTC (11 years, 9 months ago) by dmorgan
File size: 2907 byte(s)
New version 7.0.32

Fix CVE-2012-2733, CVE-2012-3439, CVE-2012-3546, CVE-2012-4431, CVE-2012-4534


1 #!/bin/bash
2 #
3 # This script provides systemd activation of the tomcat service
4 # To create clones of this service:
5 # 1) SERVICE_NAME must be defined before calling this script
6 # 2) Create /etc/sysconfig/${SERVICE_NAME} from /etc/sysconfig/tomcat
7 # to override tomcat defaults
8
9 # SERVICE_NAME is a required value only if the service name is
10 # different from 'tomcat'
11 #
12 NAME="${SERVICE_NAME:-tomcat}"
13
14 #I'll bet this isn't required.
15 # unset ISBOOT
16
17 # For SELinux we need to use 'runuser' not 'su'
18 if [ -x "/sbin/runuser" ]; then
19 SU="/sbin/runuser -s /bin/sh"
20 else
21 SU="/bin/su -s /bin/sh"
22 fi
23
24 # Path to the tomcat launch script
25 TOMCAT_SCRIPT="/usr/sbin/tomcat-jsvc"
26
27 # Define the tomcat username
28 TOMCAT_USER="${TOMCAT_USER:-tomcat}"
29
30 # TOMCAT_LOG should be different from catalina.out.
31 # Usually the below config is all that is necessary
32 TOMCAT_LOG=/var/log/${NAME}/${NAME}-sysd.log
33
34 # Get the tomcat config (use this for environment specific settings)
35 TOMCAT_CFG="/etc/tomcat/tomcat.conf"
36 if [ -r "$TOMCAT_CFG" ]; then
37 . $TOMCAT_CFG
38 fi
39
40 # Get instance specific config file
41 if [ -r "/etc/sysconfig/${NAME}" ]; then
42 . /etc/sysconfig/${NAME}
43 fi
44
45 function parseOptions() {
46 options=""
47 options="$options $(
48 awk '!/^#/ && !/^$/ { ORS=" "; print "export ", $0, ";" }' \
49 $TOMCAT_CFG
50 )"
51 if [ -r "/etc/sysconfig/${NAME}" ]; then
52 options="$options $(
53 awk '!/^#/ && !/^$/ { ORS=" ";
54 print "export ", $0, ";" }' \
55 /etc/sysconfig/${NAME}
56 )"
57 fi
58 TOMCAT_SCRIPT="$options ${TOMCAT_SCRIPT}"
59 }
60
61 # See how we were called.
62 function start() {
63 # fix permissions on the log and pid files
64 export CATALINA_PID="/var/run/${NAME}.pid"
65 touch $CATALINA_PID 2>&1
66 if [ "$?" -eq "0" ]; then
67 chown ${TOMCAT_USER}:${TOMCAT_USER} $CATALINA_PID
68 fi
69
70 touch $TOMCAT_LOG 2>&1
71 if [ "$?" -eq "0" ]; then
72 chown ${TOMCAT_USER}:${TOMCAT_USER} $TOMCAT_LOG
73 fi
74
75 # if jsvc installed and USE_JSVC=true
76 # then start as root and use jsvc to drop privileges
77 if [ -x /usr/bin/jsvc ]; then
78 TOMCAT_USER="root"
79 fi
80
81 parseOptions
82 if [ "$SECURITY_MANAGER" = "true" ]; then
83 $SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} start-security" >> $TOMCAT_LOG 2>&1
84 else
85 $SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} start" >> $TOMCAT_LOG 2>&1
86 fi
87 }
88
89 function stop() {
90 # if jsvc installed and USE_JSVC=true
91 # then start as root and use jsvc to drop privileges
92 if [ -x /usr/bin/jsvc ]; then
93 TOMCAT_USER="root"
94 fi
95
96 parseOptions
97 $SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} stop" >> $TOMCAT_LOG 2>&1
98 }
99
100 # See how we were called.
101 case "$1" in
102 start)
103 start
104 ;;
105 stop)
106 stop
107 ;;
108 restart)
109 stop
110 start
111 ;;
112 esac
113

  ViewVC Help
Powered by ViewVC 1.1.30