diff options
author | Stefan Fritsch <sf@debian.org> | 2010-02-07 00:37:44 +0000 |
---|---|---|
committer | Stefan Fritsch <sf@sfritsch.de> | 2012-01-02 10:37:06 +0100 |
commit | bf80bc0faa743a20492eea4e0dcb20d75a65d894 (patch) | |
tree | 44c1595a931b8f067ce0e10aafa3946b6b74f6fc | |
parent | 75475e8d076d4e602b91f7f14a0af2931b53ebfb (diff) | |
download | apache2-bf80bc0faa743a20492eea4e0dcb20d75a65d894.tar.gz |
Add support for multiple apache2 instances to initscript and apache2ctl.
git-svn-id: svn+ssh://svn.debian.org/svn/pkg-apache/trunk/apache2@1140 01b336ce-410b-0410-9a02-a0e7f243c266
-rw-r--r-- | debian/apache2.2-common.apache2.init | 73 | ||||
-rw-r--r-- | debian/apache2.2-common.install | 2 | ||||
-rwxr-xr-x | debian/apache2ctl | 151 | ||||
-rw-r--r-- | debian/changelog | 2 | ||||
-rwxr-xr-x | debian/patches/002_apachectl | 20 | ||||
-rw-r--r-- | debian/patches/00list | 2 | ||||
-rwxr-xr-x | debian/patches/050_enhance_apache2ctl.dpatch | 121 | ||||
-rwxr-xr-x | debian/rules | 3 |
8 files changed, 204 insertions, 170 deletions
diff --git a/debian/apache2.2-common.apache2.init b/debian/apache2.2-common.apache2.init index 8484ac50..e601c212 100644 --- a/debian/apache2.2-common.apache2.init +++ b/debian/apache2.2-common.apache2.init @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh ### BEGIN INIT INFO # Provides: apache2 # Required-Start: $local_fs $remote_fs $network $syslog @@ -8,28 +8,44 @@ # X-Interactive: true # Short-Description: Start/stop apache2 web server ### END INIT INFO -# -# apache2 This init.d script is used to start apache2. -# It basically just calls apache2ctl. + +set -e + +if [ -n "$APACHE_CONFDIR" ] ; then + DIR_SUFFIX= +elif [ "${0##*/apache2-}" != "$0" ] ; then + DIR_SUFFIX="-${0##*/apache2-}" + APACHE_CONFDIR=/etc/apache2$DIR_SUFFIX +else + DIR_SUFFIX= + APACHE_CONFDIR=/etc/apache2 +fi +if [ -z "$APACHE_ENVVARS" ] ; then + APACHE_ENVVARS=$APACHE_CONFDIR/envvars +fi ENV="env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin" +if [ "$APACHE_CONFDIR" != /etc/apache2 ] ; then + ENV="$ENV APACHE_CONFDIR=$APACHE_CONFDIR" +fi +if [ "$APACHE_ENVVARS" != "$APACHE_CONFDIR/envvars" ] ; then + ENV="$ENV APACHE_ENVVARS=$APACHE_ENVVARS" +fi -#[ $(ls -1 /etc/apache2/sites-enabled/ | wc -l | sed -e 's/ *//;') -eq 0 ] && \ -#echo "You haven't enabled any sites yet, so I'm not starting apache2." && \ -#echo "To add and enable a host, use addhost and enhost." && exit 0 #edit /etc/default/apache2 to change this. HTCACHECLEAN_RUN=auto HTCACHECLEAN_MODE=daemon HTCACHECLEAN_SIZE=300M HTCACHECLEAN_DAEMON_INTERVAL=120 -HTCACHECLEAN_PATH=/var/cache/apache2/mod_disk_cache +HTCACHECLEAN_PATH=/var/cache/apache2$DIR_SUFFIX/mod_disk_cache HTCACHECLEAN_OPTIONS="" -set -e -if [ -x /usr/sbin/apache2 ] ; then - HAVE_APACHE2=1 -else +APACHE_HTTPD=$(. $APACHE_ENVVARS && echo $APACHE_HTTPD) +if [ -z "$APACHE_HTTPD" ] ; then + APACHE_HTTPD=/usr/sbin/apache2 +fi +if [ ! -x $APACHE_HTTPD ] ; then echo "No apache MPM package installed" exit 0 fi @@ -37,14 +53,19 @@ fi . /lib/lsb/init-functions test -f /etc/default/rcS && . /etc/default/rcS -test -f /etc/default/apache2 && . /etc/default/apache2 + +if [ -f /etc/default/apache2$DIR_SUFFIX ] ; then + . /etc/default/apache2$DIR_SUFFIX +elif [ -f /etc/default/apache2 ] ; then + . /etc/default/apache2 +fi APACHE2CTL="$ENV /usr/sbin/apache2ctl" HTCACHECLEAN="$ENV /usr/sbin/htcacheclean" -PIDFILE=$(. /etc/apache2/envvars && echo $APACHE_PID_FILE) +PIDFILE=$(. $APACHE_ENVVARS && echo $APACHE_PID_FILE) if [ -z "$PIDFILE" ] ; then - echo ERROR: APACHE_PID_FILE needs to be defined in /etc/apache2/envvars >&2 + echo ERROR: APACHE_PID_FILE needs to be defined in $APACHE_ENVVARS >&2 exit 2 fi @@ -54,16 +75,20 @@ check_htcacheclean() { [ "$HTCACHECLEAN_RUN" = "yes" ] && return 0 + MODSDIR=$(. $APACHE_ENVVARS && echo $APACHE_MODS_ENABLED) [ "$HTCACHECLEAN_RUN" = "auto" \ - -a -e /etc/apache2/mods-enabled/disk_cache.load ] && return 0 + -a -e ${MODSDIR:-$APACHE_CONFDIR/mods-enabled}/disk_cache.load ] && \ + return 0 return 1 } start_htcacheclean() { + if [ ! -d "$HTCACHECLEAN_PATH" ] ; then + echo "Directory $HTCACHECLEAN_PATH does not exist!" >&2 + fi $HTCACHECLEAN $HTCACHECLEAN_OPTIONS -d$HTCACHECLEAN_DAEMON_INTERVAL \ -i -p$HTCACHECLEAN_PATH -l$HTCACHECLEAN_SIZE - } stop_htcacheclean() { @@ -74,7 +99,7 @@ pidof_apache() { # if there is actually an apache2 process whose pid is in PIDFILE, # print it and return 0. if [ -e "$PIDFILE" ]; then - if pidof apache2 | tr ' ' '\n' | grep $(cat $PIDFILE); then + if pidof apache2 | tr ' ' '\n' | grep -w $(cat $PIDFILE); then return 0 fi fi @@ -91,9 +116,9 @@ apache_stop() { PID=$(pidof_apache) || true if [ "${PID}" ]; then - # in this case it is everything nice and dandy - # and we kill apache2 - log_warning_msg "We failed to correctly shutdown apache, so we're now killing all running apache processes. This is almost certainly suboptimal, so please make sure your system is working as you'd expect now!" + # in this case it is everything nice and dandy and we kill apache2 + echo + log_warning_msg "The apache2$DIR_SUFFIX configtest failed, so we are trying to kill it manually. This is almost certainly suboptimal, so please make sure your system is working as you'd expect now!" kill $PID elif [ "$(pidof apache2)" ]; then if [ "$VERBOSE" != no ]; then @@ -226,15 +251,15 @@ case $1 in status) PID=$(pidof_apache) || true if [ -n "$PID" ]; then - echo "Apache is running (pid $PID)." + echo "Apache2 is running (pid $PID)." exit 0 else - echo "Apache is NOT running." + echo "Apache2$DIR_SUFFIX is NOT running." exit 1 fi ;; *) - log_success_msg "Usage: /etc/init.d/apache2 {start|stop|graceful-stop|restart|reload|force-reload|start-htcacheclean|stop-htcacheclean|status}" + log_success_msg "Usage: /etc/init.d/apache2$DIR_SUFFIX {start|stop|graceful-stop|restart|reload|force-reload|start-htcacheclean|stop-htcacheclean|status}" exit 1 ;; esac diff --git a/debian/apache2.2-common.install b/debian/apache2.2-common.install index e15caa1e..154ffaa0 100644 --- a/debian/apache2.2-common.install +++ b/debian/apache2.2-common.install @@ -1,7 +1,7 @@ usr/share/apache2/icons -usr/sbin/apache2ctl usr/share/apache2/error usr/sbin/envvars-std usr/share/apache2/build etc/apache2 usr/share/doc/apache2.2-common/examples debian/config-dir/* etc/apache2 debian/a2enmod usr/sbin +debian/apache2ctl usr/sbin diff --git a/debian/apache2ctl b/debian/apache2ctl new file mode 100755 index 00000000..7ce31c5c --- /dev/null +++ b/debian/apache2ctl @@ -0,0 +1,151 @@ +#!/bin/sh +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# Apache control script designed to allow an easy command line interface +# to controlling Apache. Written by Marc Slemko, 1997/08/23 +# +# Heavily modified for Debian by Stefan Fritsch 2007-2010 +# +# The exit codes returned are: +# XXX this doc is no longer correct now that the interesting +# XXX functions are handled by httpd +# 0 - operation completed successfully +# 1 - +# 2 - usage error +# 3 - httpd could not be started +# 4 - httpd could not be stopped +# 5 - httpd could not be started during a restart +# 6 - httpd could not be restarted during a restart +# 7 - httpd could not be restarted during a graceful restart +# 8 - configuration syntax error +# +# When multiple arguments are given, only the error from the _last_ +# one is reported. Run "apachectl help" for usage info +# +ARGV="$@" +# +# |||||||||||||||||||| START CONFIGURATION SECTION |||||||||||||||||||| +# -------------------- -------------------- +# +# main configuration directory +if test -z "$APACHE_CONFDIR" ; then + if test "${0##*apache2-}" != "$0" ; then + APACHE_CONFDIR="/etc/apache2-${0##*apache2-}" + else + APACHE_CONFDIR=/etc/apache2 + fi +fi +# the path to the environment variable file +test -z "$APACHE_ENVVARS" && APACHE_ENVVARS="$APACHE_CONFDIR/envvars" +# pick up any necessary environment variables +if test -f $APACHE_ENVVARS; then + . $APACHE_ENVVARS +fi + +if test "$APACHE_CONFDIR" != /etc/apache2 ; then + APACHE_ARGUMENTS="-d $APACHE_CONFDIR $APACHE_ARGUMENTS" +fi +# the following APACHE_* variables should be set in /etc/apache2/envvars +# +# the path to your httpd binary, including options if necessary +HTTPD=${APACHE_HTTPD:-/usr/sbin/apache2} +# +# a command that outputs a formatted text version of the HTML at the +# url given on the command line. Designed for lynx, however other +# programs may work. +LYNX="${APACHE_LYNX:-www-browser -dump}" +# +# the URL to your server's mod_status status page. If you do not +# have one, then status and fullstatus will not work. +STATUSURL="${APACHE_STATUSURL:-http://localhost:80/server-status}" +# +# Set this variable to a command that increases the maximum +# number of file descriptors allowed per child process. This is +# critical for configurations that use many file descriptors, +# such as mass vhosting, or a multithreaded server. +ULIMIT_MAX_FILES="${APACHE_ULIMIT_MAX_FILES:-ulimit -S -n `ulimit -H -n`}" +# -------------------- -------------------- +# |||||||||||||||||||| END CONFIGURATION SECTION |||||||||||||||||||| + +# Set the maximum number of file descriptors allowed per child process. +if [ "x$ULIMIT_MAX_FILES" != "x" ] ; then + $ULIMIT_MAX_FILES +fi + +ERROR=0 +if [ "x$ARGV" = "x" ] || [ "x$ARGV" = "xusage" ] || [ "x$ARGV" = "xhelp" ] || [ "x$ARGV" = "x--help" ]; then + echo "Usage: $0 start|stop|restart|graceful|graceful-stop|configtest|status|fullstatus|help" >&2 + echo " $0 <apache2 args>" >&2 + echo " $0 -h (for help on <apache2 args>)" >&2 + exit 1 +fi + +get_status () { + if ! $LYNX $STATUSURL ; then + echo "'$LYNX $STATUSURL'" failed. >&2 + echo Maybe you need to install a package providing www-browser or you >&2 + echo need to adjust the APACHE_LYNX variable in /etc/apache2/envvars >&2 + exit 1 + fi +} + +case $ARGV in +start) + mkdir -p ${APACHE_RUN_DIR:-/var/run/apache2} + install -d -o ${APACHE_RUN_USER:-www-data} ${APACHE_LOCK_DIR:-/var/lock/apache2} + # ssl_scache shouldn't be here if we're just starting up. + # (this is bad if there are several apache2 instances running) + rm -f ${APACHE_RUN_DIR:-/var/run/apache2}/*ssl_scache* + $HTTPD ${APACHE_ARGUMENTS} -k $ARGV + ERROR=$? + ;; +stop|graceful-stop) + $HTTPD ${APACHE_ARGUMENTS} -k $ARGV + ERROR=$? + ;; +restart|graceful) + if $HTTPD ${APACHE_ARGUMENTS} -t 2> /dev/null ; then + $HTTPD ${APACHE_ARGUMENTS} -k $ARGV + else + $HTTPD ${APACHE_ARGUMENTS} -t + fi + ERROR=$? + ;; +startssl|sslstart|start-SSL) + echo The startssl option is no longer supported. + echo Please edit httpd.conf to include the SSL configuration settings + echo and then use "apachectl start". + ERROR=2 + ;; +configtest) + $HTTPD ${APACHE_ARGUMENTS} -t + ERROR=$? + ;; +status) + get_status | awk ' /process$/ { print; exit } { print } ' + ;; +fullstatus) + get_status + ;; +*) + $HTTPD ${APACHE_ARGUMENTS} $ARGV + ERROR=$? +esac + +exit $ERROR + diff --git a/debian/changelog b/debian/changelog index 74b1b90e..ed3ed9a7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ apache2 (2.2.14-6) UNRELEASED; urgency=low * Move ab and logresolve from /usr/sbin to /usr/bin. Closes: #351450, #564061 + * Add support for multiple apache2 instances to initscript and apache2ctl. + Documentation ist still missing, though... Closes: #353450 * Set default compiled-in ServerRoot to /etc/apache2 and make paths in apache2.conf relative to ServerRoot. * Fix symlinks in apache2-dbg package. Closes: #567076 diff --git a/debian/patches/002_apachectl b/debian/patches/002_apachectl deleted file mode 100755 index cffbcaf8..00000000 --- a/debian/patches/002_apachectl +++ /dev/null @@ -1,20 +0,0 @@ -#! /bin/sh /usr/share/dpatch/dpatch-run -## 002_apachectl by Adam Conrad <adconrad@0c3.net> -## -## All lines beginning with `## DP:' are a description of the patch. -## DP: envvars lives in /etc/apache2 in our setup. - -@DPATCH@ ---- apache2/support/apachectl.in 2003-05-07 13:18:19.000000000 +0100 -+++ apache2/support/apachectl.in 2003-05-07 13:17:37.000000000 +0100 -@@ -31,8 +31,8 @@ - HTTPD='@exp_sbindir@/@progname@' - # - # pick up any necessary environment variables --if test -f @exp_sbindir@/envvars; then -- . @exp_sbindir@/envvars -+if test -f @exp_sysconfdir@/envvars; then -+ . @exp_sysconfdir@/envvars - fi - # - # a command that outputs a formatted text version of the HTML at the diff --git a/debian/patches/00list b/debian/patches/00list index e1193c13..4b3bb7ef 100644 --- a/debian/patches/00list +++ b/debian/patches/00list @@ -1,5 +1,4 @@ 001_branding -002_apachectl 004_usr_bin_perl_0wnz_j00 008_make_include_safe 009_apache2_has_dso @@ -12,7 +11,6 @@ 042_htdigest_CAN-2005-1344 045_suexec_log_cloexec.dpatch 047_fix_usage_message.dpatch -050_enhance_apache2ctl.dpatch 052_logresolve_linelength.dpatch 057_disablemods.dpatch 058_suexec-CVE-2007-1742.dpatch diff --git a/debian/patches/050_enhance_apache2ctl.dpatch b/debian/patches/050_enhance_apache2ctl.dpatch deleted file mode 100755 index 0b641f31..00000000 --- a/debian/patches/050_enhance_apache2ctl.dpatch +++ /dev/null @@ -1,121 +0,0 @@ -#! /bin/sh /usr/share/dpatch/dpatch-run -## 050_enhance_apache2ctl.dpatch by Stefan Fritsch <sf@debian.org> -## -## All lines beginning with `## DP:' are a description of the patch. -## DP: - mv creation of necessary directories to apache2ctl, -## DP: to make it work on new installations -## DP: - add usage message - -@DPATCH@ -diff -urNad trunk~/support/apachectl.in trunk/support/apachectl.in ---- trunk~/support/apachectl.in 2010-01-02 17:51:49.480626116 +0100 -+++ trunk/support/apachectl.in 2010-01-02 17:52:31.089347144 +0100 -@@ -40,28 +40,31 @@ - # |||||||||||||||||||| START CONFIGURATION SECTION |||||||||||||||||||| - # -------------------- -------------------- - # --# the path to your httpd binary, including options if necessary --HTTPD='@exp_sbindir@/@progname@' --# -+# the path to the environment variable file -+test -z "$APACHE_ENVVARS" && APACHE_ENVVARS='/etc/apache2/envvars' - # pick up any necessary environment variables --if test -f @exp_sysconfdir@/envvars; then -- . @exp_sysconfdir@/envvars -+if test -f $APACHE_ENVVARS; then -+ . $APACHE_ENVVARS - fi -+# the following APACHE_* variables should be set in /etc/apache2/envvars -+# -+# the path to your httpd binary, including options if necessary -+HTTPD=${APACHE_HTTPD:-/usr/sbin/apache2} - # - # a command that outputs a formatted text version of the HTML at the - # url given on the command line. Designed for lynx, however other - # programs may work. --LYNX="@LYNX_PATH@ -dump" -+LYNX="${APACHE_LYNX:-@LYNX_PATH@ -dump}" - # - # the URL to your server's mod_status status page. If you do not - # have one, then status and fullstatus will not work. --STATUSURL="http://localhost:@PORT@/server-status" -+STATUSURL="${APACHE_STATUSURL:-http://localhost:@PORT@/server-status}" - # - # Set this variable to a command that increases the maximum - # number of file descriptors allowed per child process. This is - # critical for configurations that use many file descriptors, - # such as mass vhosting, or a multithreaded server. --ULIMIT_MAX_FILES="@APACHECTL_ULIMIT@" -+ULIMIT_MAX_FILES="${APACHE_ULIMIT_MAX_FILES:-@APACHECTL_ULIMIT@}" - # -------------------- -------------------- - # |||||||||||||||||||| END CONFIGURATION SECTION |||||||||||||||||||| - -@@ -71,13 +74,42 @@ - fi - - ERROR=0 --if [ "x$ARGV" = "x" ] ; then -- ARGV="-h" -+if [ "x$ARGV" = "x" ] || [ "x$ARGV" = "xusage" ] || [ "x$ARGV" = "xhelp" ] || [ "x$ARGV" = "x--help" ]; then -+ echo "Usage: $0 start|stop|restart|graceful|graceful-stop|configtest|status|fullstatus|help" >&2 -+ echo " $0 <apache2 args>" >&2 -+ echo " $0 -h (for help on <apache2 args>)" >&2 -+ exit 1 - fi - -+get_status () { -+ if ! $LYNX $STATUSURL ; then -+ echo "'$LYNX $STATUSURL'" failed. >&2 -+ echo Maybe you need to install a package providing www-browser or you >&2 -+ echo need to adjust the APACHE_LYNX variable in /etc/apache2/envvars >&2 -+ exit 1 -+ fi -+} -+ - case $ARGV in --start|stop|restart|graceful|graceful-stop) -- $HTTPD -k $ARGV -+start) -+ mkdir -p ${APACHE_RUN_DIR:-/var/run/apache2} -+ install -d -o ${APACHE_RUN_USER:-www-data} ${APACHE_LOCK_DIR:-/var/lock/apache2} -+ # ssl_scache shouldn't be here if we're just starting up. -+ # (this is bad if there are several apache2 instances running) -+ rm -f ${APACHE_RUN_DIR:-/var/run/apache2}/*ssl_scache* -+ $HTTPD ${APACHE_ARGUMENTS} -k $ARGV -+ ERROR=$? -+ ;; -+stop|graceful-stop) -+ $HTTPD ${APACHE_ARGUMENTS} -k $ARGV -+ ERROR=$? -+ ;; -+restart|graceful) -+ if $HTTPD ${APACHE_ARGUMENTS} -t 2> /dev/null ; then -+ $HTTPD ${APACHE_ARGUMENTS} -k $ARGV -+ else -+ $HTTPD ${APACHE_ARGUMENTS} -t -+ fi - ERROR=$? - ;; - startssl|sslstart|start-SSL) -@@ -87,17 +119,17 @@ - ERROR=2 - ;; - configtest) -- $HTTPD -t -+ $HTTPD ${APACHE_ARGUMENTS} -t - ERROR=$? - ;; - status) -- $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } ' -+ get_status | awk ' /process$/ { print; exit } { print } ' - ;; - fullstatus) -- $LYNX $STATUSURL -+ get_status - ;; - *) -- $HTTPD $ARGV -+ $HTTPD ${APACHE_ARGUMENTS} $ARGV - ERROR=$? - esac - diff --git a/debian/rules b/debian/rules index 5f08f5dc..c534cc3f 100755 --- a/debian/rules +++ b/debian/rules @@ -208,14 +208,13 @@ install: build install-dev rm -rf debian/tmp/usr/include rm -rf debian/tmp/usr/share/apache2/build rm -f debian/tmp/usr/share/man/man8/httpd.8 # We install our own - rm -f debian/tmp/usr/sbin/apxs debian/tmp/usr/sbin/apache2 + rm -f debian/tmp/usr/sbin/apxs debian/tmp/usr/sbin/apache2 debian/tmp/usr/sbin/apachectl # DO NOT FALL FOR THE TEMPTATION TO MV INTO PACKAGES OR DOOM # WILL FIND YOU. Use dh_install, this is just because dh_install # can't rename files mv debian/tmp/usr/share/man/man8/apxs.8 debian/tmp/usr/share/man/man8/apxs2.8 - mv debian/tmp/usr/sbin/apachectl debian/tmp/usr/sbin/apache2ctl mv debian/tmp/usr/share/man/man8/apachectl.8 debian/tmp/usr/share/man/man8/apache2ctl.8 mkdir -p debian/tmp/usr/share/apache2/icons/ for i in `ls debian/icons/ | cut -d. -f1,2`; do \ |