2 # Copyright 1999-2011 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
5 opts="configdump configtest fullstatus graceful gracefulstop modules reload virtualhosts"
9 use mysql dns logger netmount postgresql
14 ebegin "Checking ${SVCNAME} configuration"
20 PIDFILE="${PIDFILE:-/var/run/apache2-backuppc.pid}"
21 TIMEOUT=${TIMEOUT:-10}
23 SERVERROOT="${SERVERROOT:-/usr/lib/apache2}"
24 if [ ! -d ${SERVERROOT} ]; then
25 eerror "SERVERROOT does not exist: ${SERVERROOT}"
29 CONFIGFILE="${CONFIGFILE:-/etc/BackupPC/httpd.conf}"
30 [ "${CONFIGFILE#/}" = "${CONFIGFILE}" ] && CONFIGFILE="${SERVERROOT}/${CONFIGFILE}"
31 if [ ! -r "${CONFIGFILE}" ]; then
32 eerror "Unable to read configuration file: ${CONFIGFILE}"
36 APACHE2_OPTS="${APACHE2_OPTS} -d ${SERVERROOT}"
37 APACHE2_OPTS="${APACHE2_OPTS} -f ${CONFIGFILE}"
38 [ -n "${STARTUPERRORLOG}" ] && APACHE2_OPTS="${APACHE2_OPTS} -E ${STARTUPERRORLOG}"
40 APACHE2="/usr/sbin/apache2"
44 checkconfd || return 1
46 ${APACHE2} ${APACHE2_OPTS} -t 1>/dev/null 2>&1
48 if [ $ret -ne 0 ]; then
49 eerror "${SVCNAME} has detected a syntax error in your configuration files:"
50 ${APACHE2} ${APACHE2_OPTS} -t
57 checkconfig || return 1
59 [ -f /var/log/apache2/ssl_scache ] && rm /var/log/apache2/ssl_scache
61 ebegin "Starting ${SVCNAME}"
62 ${APACHE2} ${APACHE2_OPTS} -k start
65 while [ ! -e "${PIDFILE}" ] && [ $i -lt ${TIMEOUT} ]; do
66 sleep 1 && i=$(expr $i + 1)
69 test $i -le ${TIMEOUT}
74 checkconfd || return 1
76 ebegin "Stopping ${SVCNAME}"
77 ${APACHE2} ${APACHE2_OPTS} -k stop
80 while pidof "${APACHE2}" >/dev/null && [ $i -lt ${TIMEOUT} ]; do
81 sleep 1 && i=$(expr $i + 1)
84 test $i -le ${TIMEOUT}
89 RELOAD_TYPE="${RELOAD_TYPE:-graceful}"
91 checkconfig || return 1
92 service_started "${SVCNAME}" || return
94 if [ "${RELOAD_TYPE}" = "restart" ]; then
95 ebegin "Restarting ${SVCNAME}"
96 ${APACHE2} ${APACHE2_OPTS} -k restart
98 elif [ "${RELOAD_TYPE}" = "graceful" ]; then
99 ebegin "Gracefully restarting ${SVCNAME}"
100 ${APACHE2} ${APACHE2_OPTS} -k graceful
103 eerror "${RELOAD_TYPE} is not a valid RELOAD_TYPE. Please edit /etc/conf.d/${SVCNAME}"
108 checkconfig || return 1
109 service_started "${SVCNAME}" || return
110 ebegin "Gracefully restarting ${SVCNAME}"
111 ${APACHE2} ${APACHE2_OPTS} -k graceful
116 checkconfig || return 1
119 if service_started "${SVCNAME}"; then
120 mark_service_stopped "${SVCNAME}"
123 ebegin "Gracefully stopping ${SVCNAME}"
124 ${APACHE2} ${APACHE2_OPTS} -k graceful-stop
129 checkconfig || return 1
131 ${APACHE2} ${APACHE2_OPTS} -M 2>&1
135 LYNX="${LYNX:-lynx -dump}"
136 STATUSURL="${STATUSURL:-http://localhost/server-status}"
138 if ! service_started "${SVCNAME}"; then
139 eerror "${SVCNAME} not started"
140 elif ! type -p ${LYNX} 2>&1 >/dev/null; then
141 eerror "lynx not found! you need to emerge www-client/lynx"
148 checkconfd || return 1
149 ${APACHE2} ${APACHE2_OPTS} -S
153 LYNX="${LYNX:-lynx -dump}"
154 INFOURL="${INFOURL:-http://localhost/server-info}"
156 checkconfd || return 1
158 if ! service_started "${SVCNAME}"; then
159 eerror "${SVCNAME} not started"
160 elif ! type -p ${LYNX} 2>&1 >/dev/null; then
161 eerror "lynx not found! you need to emerge www-client/lynx"
163 echo "${APACHE2} started with '${APACHE2_OPTS}'"
164 for i in config server list; do
165 ${LYNX} "${INFOURL}/?${i}" | sed '/Apache Server Information/d;/^[[:space:]]\+[_]\+$/Q'
170 # vim: ts=4 filetype=gentoo-init-d