blob: 5f72d309043956ec0cfe0ea55316920137dab454 (
plain)
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
113
114
115
116
117
118
119
120
121
|
#!/sbin/runscript
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
opts="configtest fullstatus graceful gracefulstop modules reload"
depend() {
need net
use mysql dns logger netmount postgresql
after sshd
}
configtest() {
ebegin "Checking Apache Configuration"
checkconfig
eend $?
}
checkconfig() {
SERVERROOT="${SERVERROOT:-/usr/lib/apache2}"
if [ ! -d ${SERVERROOT} ]; then
eerror "SERVERROOT does not exist: ${SERVERROOT}"
return 1
fi
CONFIGFILE="${CONFIGFILE:-/etc/apache2/httpd.conf}"
[ "${CONFIGFILE#/}" = "${CONFIGFILE}" ] && CONFIGFILE="${SERVERROOT}/${CONFIGFILE}"
if [ ! -r "${CONFIGFILE}" ]; then
eerror "Unable to read configuration file: ${CONFIGFILE}"
return 1
fi
APACHE2_OPTS="${APACHE2_OPTS} -d ${SERVERROOT}"
APACHE2_OPTS="${APACHE2_OPTS} -f ${CONFIGFILE}"
[ -n "${STARTUPERRORLOG}" ] && APACHE2_OPTS="${APACHE2_OPTS} -E ${STARTUPERRORLOG}"
APACHE2="/usr/sbin/apache2"
${APACHE2} ${APACHE2_OPTS} -t 1>/dev/null 2>&1
ret=$?
if [ $ret -ne 0 ]; then
eerror "Apache2 has detected a syntax error in your configuration files:"
${APACHE2} ${APACHE2_OPTS} -t
fi
return $ret
}
start() {
checkconfig || return 1
ebegin "Starting apache2"
[ -f /var/log/apache2/ssl_scache ] && rm /var/log/apache2/ssl_scache
start-stop-daemon --start --exec ${APACHE2} -- ${APACHE2_OPTS} -k start
eend $?
}
stop() {
checkconfig || return 1
ebegin "Stopping apache2"
start-stop-daemon --stop --retry -TERM/5/-KILL/5 --exec ${APACHE2} --pidfile /var/run/apache2.pid
eend $?
}
reload() {
RELOAD_TYPE="${RELOAD_TYPE:-graceful}"
checkconfig || return 1
if [ "${RELOAD_TYPE}" = "restart" ]; then
ebegin "Restarting apache2"
start-stop-daemon --stop --oknodo --signal HUP --exec ${APACHE2} --pidfile /var/run/apache2.pid
eend $?
elif [ "${RELOAD_TYPE}" = "graceful" ]; then
ebegin "Gracefully restarting apache2"
start-stop-daemon --stop --oknodo --signal USR1 --exec ${APACHE2} --pidfile /var/run/apache2.pid
eend $?
else
eerror "${RELOAD_TYPE} is not a valid RELOAD_TYPE. Please edit /etc/conf.d/apache2"
fi
}
graceful() {
checkconfig || return 1
ebegin "Gracefully restarting apache2"
start-stop-daemon --stop --signal USR1 --exec ${APACHE2} --pidfile /var/run/apache2.pid
eend $?
}
gracefulstop() {
checkconfig || return 1
# zap!
if service_started "${myservice}"; then
mark_service_stopped "${myservice}"
fi
ebegin "Gracefully stopping apache2"
# 28 is SIGWINCH
start-stop-daemon --stop --signal 28 --exec ${APACHE2} --pidfile /var/run/apache2.pid
eend $?
}
modules() {
checkconfig || return 1
${APACHE2} ${APACHE2_OPTS} -M 2>&1
}
status() {
LYNX="${LYNX:-lynx -dump}"
STATUSURL="${STATUSURL:-http://localhost/server-status}"
${LYNX} ${STATUSURL} | awk ' /process$/ { print; exit } { print } '
}
fullstatus() {
LYNX="${LYNX:-lynx -dump}"
STATUSURL="${STATUSURL:-http://localhost/server-status}"
${LYNX} ${STATUSURL}
}
|