-#!/sbin/runscript
-# Copyright 1999-2011 Gentoo Foundation
+#!/sbin/openrc-run
+# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
extra_commands="configtest modules virtualhosts"
description_virtualhosts="Show the settings as parsed from the config file (currently only shows the virtualhost settings)."
description_stop="Kills all children and stops the server."
+# Apply default values for some conf.d variables.
+PIDFILE="${PIDFILE:-/var/run/apache2.pid}"
+TIMEOUT=${TIMEOUT:-15}
+SERVERROOT="${SERVERROOT:-/usr/lib64/apache2}"
+CONFIGFILE="${CONFIGFILE:-/etc/apache2/httpd.conf}"
+LYNX="${LYNX:-lynx -dump}"
+STATUSURL="${STATUSURL:-http://localhost/server-status}"
+RELOAD_TYPE="${RELOAD_TYPE:-graceful}"
+
+# Append the server root and configuration file parameters to the
+# user's APACHE2_OPTS.
+APACHE2_OPTS="${APACHE2_OPTS} -d ${SERVERROOT}"
+APACHE2_OPTS="${APACHE2_OPTS} -f ${CONFIGFILE}"
+
+# The path to the apache2 binary.
+APACHE2="/usr/sbin/apache2"
+
depend() {
need net
use mysql dns logger netmount postgresql
}
checkconfd() {
- if [ ! -f /etc/init.d/sysfs ]; then
- eerror "This init script works only with openrc (baselayout-2)."
- eerror "If you still need baselayout-1.x, please, use"
- eerror "apache2.initd-baselayout-1 from /usr/share/doc/apache2-*/"
- fi
-
- PIDFILE="${PIDFILE:-/var/run/apache2.pid}"
- TIMEOUT=${TIMEOUT:-15}
-
- SERVERROOT="${SERVERROOT:-/usr/lib64/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"
}
checkconfig() {
checkpath --directory /run/apache_ssl_mutex
checkconfd || return 1
- ${APACHE2} ${APACHE2_OPTS} -t 1>/dev/null 2>&1
+ OUTPUT=$( ${APACHE2} ${APACHE2_OPTS} -t 2>&1 )
ret=$?
if [ $ret -ne 0 ]; then
eerror "${SVCNAME} has detected an error in your setup:"
- ${APACHE2} ${APACHE2_OPTS} -t
+ printf "%s\n" "${OUTPUT}"
fi
return $ret
start() {
checkconfig || return 1
+ if [ -n "${STARTUPERRORLOG}" ] ; then
+ # We must make sure that we only append to APACHE2_OPTS
+ # in start() and not in stop() or anywhere else that may
+ # be executed along with start(), see bug #566726.
+ APACHE2_OPTS="${APACHE2_OPTS} -E ${STARTUPERRORLOG}"
+ fi
+
ebegin "Starting ${SVCNAME}"
# Use start stop daemon to apply system limits #347301
start-stop-daemon --start -- ${APACHE2} ${APACHE2_OPTS} -k start
stop() {
if [ "${RC_CMD}" = "restart" ]; then
checkconfig || return 1
- else
- checkconfd || return 1
fi
PID=$(cat "${PIDFILE}" 2>/dev/null)
}
reload() {
- RELOAD_TYPE="${RELOAD_TYPE:-graceful}"
-
checkconfig || return 1
if [ "${RELOAD_TYPE}" = "restart" ]; then
}
fullstatus() {
- LYNX="${LYNX:-lynx -dump}"
- STATUSURL="${STATUSURL:-http://localhost/server-status}"
-
if ! type -p $(set -- ${LYNX}; echo $1) 2>&1 >/dev/null; then
eerror "lynx not found! you need to emerge www-client/lynx"
else
}
configdump() {
- LYNX="${LYNX:-lynx -dump}"
INFOURL="${INFOURL:-http://localhost/server-info}"
checkconfd || return 1