summaryrefslogtreecommitdiff
blob: 8031b8b28fec4cb53e9be2e913a90ab5ff62f60b (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
#!/bin/sh

APACHE2="/usr/sbin/apache2"
APACHE_OPTS=""
APACHE_RC_CONF="/etc/conf.d/apache2"
# List of init script verbs that should be passed forward
RC_VERBS="start stop restart checkconfd configtest modules virtualhosts configdump fullstatus graceful gracefulstop reload"

load_rc_config() {
	[ -f "${APACHE_RC_CONF}" ] || return 1
	if ! grep -q '^[[:space:]]*APACHE2_OPTS' ${APACHE_RC_CONF} ; then
		echo "Cannot find APACHE2_OPTS in ${APACHE_RC_CONF}"
		exit 1
	fi
	. ${APACHE_RC_CONF}
	export APACHE2_OPTS
	export SERVERROOT="${SERVERROOT:-/usr/@LIBDIR@/apache2}"
	export CONFIGFILE="${CONFIGFILE:-/etc/apache2/httpd.conf}"
}

# If first parameter is a verb defined in $RC_VERBS, pass the command to init script.
# In other cases, compile command line and run the command on apache binary.
if echo "${RC_VERBS}" | grep -q -- "${1}" ; then
	exec /etc/init.d/apache2 "${@}"
else
	load_rc_config || exit 1
	${APACHE2} ${APACHE2_OPTS} -d ${SERVERROOT} -f ${CONFIGFILE} "${@}"
fi