-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtomcat-7.0-tomcat-jsvc-sysd
113 lines (96 loc) · 2.84 KB
/
tomcat-7.0-tomcat-jsvc-sysd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/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'
#
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-jsvc"
# 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
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() {
# fix permissions on the log and pid files
export CATALINA_PID="/var/run/${NAME}.pid"
touch $CATALINA_PID 2>&1
if [ "$?" -eq "0" ]; then
chown ${TOMCAT_USER}:${TOMCAT_USER} $CATALINA_PID
fi
touch $TOMCAT_LOG 2>&1
if [ "$?" -eq "0" ]; then
chown ${TOMCAT_USER}:${TOMCAT_USER} $TOMCAT_LOG
fi
# if jsvc installed and USE_JSVC=true
# then start as root and use jsvc to drop privileges
if [ -x /usr/bin/jsvc ]; then
TOMCAT_USER="root"
fi
parseOptions
if [ "$SECURITY_MANAGER" = "true" ]; then
$SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} start-security" >> $TOMCAT_LOG 2>&1
else
$SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} start" >> $TOMCAT_LOG 2>&1
fi
}
function stop() {
# if jsvc installed and USE_JSVC=true
# then start as root and use jsvc to drop privileges
if [ -x /usr/bin/jsvc ]; then
TOMCAT_USER="root"
fi
parseOptions
$SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} stop" >> $TOMCAT_LOG 2>&1
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
esac