blob: 788538c3e99c44b4dfef721f1440253f96f5ae4b (
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
|
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header$
opts="${opts} reload configtest"
depend() {
need net
use mysql dns logger netmount postgresql lingerd
after sshd
}
configtest() {
ebegin "Checking Apache Configuration"
checkconfig
eend $?
}
checkconfig() {
SERVERROOT="${SERVERROOT:-/usr/lib/apache}"
if [ ! -d ${SERVERROOT} ]; then
eerror "SERVERROOT does not exist: ${SERVERROOT}"
return 1
fi
CONFIGFILE="${CONFIGFILE:-/etc/apache/httpd.conf}"
[ ${CONFIGFILE:0:1} != "/" ] && CONFIGFILE="${SERVERROOT}/${CONFIGFILE}"
if [ ! -r "${CONFIGFILE}" ]; then
eerror "Unable to read configuration file: ${CONFIGFILE}"
return 1
fi
# check to see if the old config files exist and aren't used
if [[ "${CONFIGFILE}" != "/etc/apache/conf/apache.conf" &&
-e "/etc/apache/conf/apache.conf" ]]; then
eerror "Found old apache.conf in /etc/apache/conf. Configuration locations \n have moved, please check ${CONFIGFILE} to make sure it is correct, \n and remove /etc/apache/conf/apache.conf\n\nPlease see http://dev.gentoo.org/~vericgar/doc/apache-package-refresh.html\n for more information."
return 1
fi
PIDFILE="${PIDFILE:-/var/run/apache.pid}"
[ -n "${SERVERROOT}" ] && APACHE_OPTS="${APACHE_OPTS} -d ${SERVERROOT}"
[ -n "${CONFIGFILE}" ] && APACHE_OPTS="${APACHE_OPTS} -f ${CONFIGFILE}"
# set sane defaults for KEEPENV and OLDENV
KEEPENV="${KEEPENV:-PATH}"
OLDENV=
for new_env in ${KEEPENV}; do
OLDENV="${OLDENV} ${new_env}=`printenv ${new_env}`"
done
APACHE="env -i ${OLDENV} /usr/sbin/apache ${APACHE_OPTS}"
$APACHE -t 1>/dev/null 2>&1
ret=$?
if [ $ret -ne 0 ]; then
eerror "Apache has detected a syntax error in your configuration files:"
${APACHE} -t
fi
return $ret
}
start() {
checkconfig || return 1
ebegin "Starting apache"
env -i PATH=$PATH PERL5LIB=PERL5LIB \
/sbin/start-stop-daemon -o --quiet --start \
--startas /usr/sbin/apache --pidfile ${PIDFILE} -- ${APACHE_OPTS}
eend $?
}
stop() {
checkconfig || return 1
ebegin "Stopping apache"
/sbin/start-stop-daemon -o --quiet --stop --pidfile ${PIDFILE}
eend $?
}
restart() {
checkconfig || return 1
svc_stop
svc_start
}
reload() {
checkconfig || return 1
ebegin "Reloading apache"
if [ -f ${PIDFILE} ]; then
kill -USR1 $(<${PIDFILE})
eend $?
else
eerror "Apache not running."
eend $?
svc_start
fi
}
|