diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2010-08-10 12:19:19 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2010-08-10 12:19:19 +0000 |
commit | c82268523e28a998de4dce38b842b25c4ba4ffd2 (patch) | |
tree | e32c719037aa82138ceb1319a27971ed0dee2f9f /main/apache2/apache2.initd | |
parent | c0367e7f1e95ef668455892afc61ebbbc53a35d9 (diff) | |
download | aports-c82268523e28a998de4dce38b842b25c4ba4ffd2.tar.bz2 aports-c82268523e28a998de4dce38b842b25c4ba4ffd2.tar.xz |
main/apache2: moved from testing
fixes #392
Diffstat (limited to 'main/apache2/apache2.initd')
-rwxr-xr-x | main/apache2/apache2.initd | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/main/apache2/apache2.initd b/main/apache2/apache2.initd new file mode 100755 index 0000000000..03a6d03032 --- /dev/null +++ b/main/apache2/apache2.initd @@ -0,0 +1,154 @@ +#!/sbin/runscript +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +opts="configdump configtest fullstatus graceful gracefulstop modules reload virtualhosts" + +depend() { + need net + use mysql dns logger netmount postgresql + after sshd +} + +configtest() { + ebegin "Checking ${SVCNAME} configuration" + checkconfig + eend $? +} + +checkconfd() { + PIDFILE="${PIDFILE:-/var/run/apache2/httpd.pid}" + TIMEOUT=${TIMEOUT:-10} + + SERVERROOT="${SERVERROOT:-/var/www}" + 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 + + HTTPD_OPTS="${HTTPD_OPTS} -d ${SERVERROOT}" + HTTPD_OPTS="${HTTPD_OPTS} -f ${CONFIGFILE}" + [ -n "${STARTUPERRORLOG}" ] && HTTPD_OPTS="${HTTPD_OPTS} -E ${STARTUPERRORLOG}" + return 0 + +} + +checkconfig() { + checkconfd || return 1 + + ${HTTPD} ${HTTPD_OPTS} -t 1>/dev/null 2>&1 + ret=$? + if [ $ret -ne 0 ]; then + eerror "${SVCNAME} has detected an error in your setup:" + ${HTTPD} ${HTTPD_OPTS} -t + fi + + return $ret +} + +start() { + checkconfig || return 1 + + [ -f /var/log/apache2/ssl_scache ] && rm /var/log/apache2/ssl_scache + + ebegin "Starting ${SVCNAME}" + start-stop-daemon --start \ + --pidfile ${PIDFILE} \ + --exec ${HTTPD} \ + -- ${HTTPD_OPTS} -k start + eend $? +} + +stop() { + checkconfd || return 1 + + ebegin "Stopping ${SVCNAME}" + start-stop-daemon --stop --pidfile ${PIDFILE} --exec ${HTTPD} \ + --retry ${TIMEOUT} + eend $? +} + +reload() { + RELOAD_TYPE="${RELOAD_TYPE:-graceful}" + + checkconfig || return 1 + service_started "${SVCNAME}" || return + + if [ "${RELOAD_TYPE}" = "restart" ]; then + ebegin "Restarting ${SVCNAME}" + ${HTTPD} ${HTTPD_OPTS} -k restart + eend $? + elif [ "${RELOAD_TYPE}" = "graceful" ]; then + ebegin "Gracefully restarting ${SVCNAME}" + ${HTTPD} ${HTTPD_OPTS} -k graceful + eend $? + else + eerror "${RELOAD_TYPE} is not a valid RELOAD_TYPE. Please edit /etc/conf.d/${SVCNAME}" + fi +} + +graceful() { + checkconfig || return 1 + service_started "${SVCNAME}" || return + ebegin "Gracefully restarting ${SVCNAME}" + ${HTTPD} ${HTTPD_OPTS} -k graceful + eend $? +} + +gracefulstop() { + checkconfig || return 1 + ebegin "Gracefully stopping ${SVCNAME}" + start-stop-daemon --stop --pidfile ${PIDFILE} --exec ${HTTPD} \ + --retry SIGWINCH/${TIMEOUT} + eend $? +} + +modules() { + checkconfig || return 1 + + ${HTTPD} ${HTTPD_OPTS} -M 2>&1 +} + +fullstatus() { + LYNX="${LYNX:-lynx -dump}" + STATUSURL="${STATUSURL:-http://localhost/server-status}" + + if ! service_started "${SVCNAME}"; then + eerror "${SVCNAME} not started" + elif ! type -p $(set -- ${LYNX}; echo $1) 2>&1 >/dev/null; then + eerror "lynx not found! you need to emerge www-client/lynx" + else + ${LYNX} ${STATUSURL} + fi +} + +virtualhosts() { + checkconfd || return 1 + ${HTTPD} ${HTTPD_OPTS} -S +} + +configdump() { + LYNX="${LYNX:-lynx -dump}" + INFOURL="${INFOURL:-http://localhost/server-info}" + + checkconfd || return 1 + + if ! service_started "${SVCNAME}"; then + eerror "${SVCNAME} not started" + elif ! type -p $(set -- ${LYNX}; echo $1) 2>&1 >/dev/null; then + eerror "lynx not found! you need to emerge www-client/lynx" + else + echo "${HTTPD} started with '${HTTPD_OPTS}'" + for i in config server list; do + ${LYNX} "${INFOURL}/?${i}" | sed '/Apache Server Information/d;/^[[:space:]]\+[_]\+$/Q' + done + fi +} + |