2015-07-13 10:18:58 +02:00
|
|
|
#!/bin/sh
|
2011-09-12 14:20:52 +02:00
|
|
|
#
|
|
|
|
# Copyright (c) 1996, 1997, 1998 S.u.S.E. GmbH
|
|
|
|
# Copyright (c) 1998, 1999, 2000, 2001 SuSE GmbH
|
|
|
|
# Copyright (c) 2002, 2003, (2004?) SuSE Linux AG
|
|
|
|
# Copyright (c) 2004(?), 2005, 2006, 2007, 2008 SUSE Linux Products GmbH
|
|
|
|
#
|
|
|
|
# Authors: Rolf Haberrecker <apache@suse.de>, 2001
|
|
|
|
# Peter Poeml <apache@suse.de>, 2002, 2003, 2004, 2005, 2006, 2007,
|
|
|
|
# 2008, 2009, 2010
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
2015-07-13 10:18:58 +02:00
|
|
|
. /usr/share/apache2/script-helpers
|
2011-09-12 14:20:52 +02:00
|
|
|
|
2015-07-13 10:18:58 +02:00
|
|
|
#
|
|
|
|
# which instance should we will run
|
|
|
|
#
|
2011-09-12 14:20:52 +02:00
|
|
|
|
2015-07-13 10:18:58 +02:00
|
|
|
unset instance_suffix
|
|
|
|
if [ -n "$HTTPD_INSTANCE" ]; then
|
|
|
|
instance_suffix="@$HTTPD_INSTANCE"
|
2011-09-12 14:20:52 +02:00
|
|
|
fi
|
|
|
|
|
2015-07-13 10:18:58 +02:00
|
|
|
#
|
|
|
|
# load sysconfig variables APACHE_* from instance sysconfig
|
|
|
|
# file
|
|
|
|
#
|
|
|
|
export SYSCONFIG_FILE=/etc/sysconfig/apache2${instance_suffix}
|
|
|
|
load_sysconfig
|
2011-09-12 14:20:52 +02:00
|
|
|
|
|
|
|
unset server_flags
|
2015-07-13 10:18:58 +02:00
|
|
|
#
|
2015-07-14 11:04:22 +02:00
|
|
|
# server_flags: -DSYSCONFIG
|
2015-07-13 10:18:58 +02:00
|
|
|
#
|
|
|
|
if [ -f "$SYSCONFIG_FILE" ]; then
|
|
|
|
server_flags="$server_flags -DSYSCONFIG"
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# figure out correct apache2 binary (/usr/sbin/httpd-prefork,
|
|
|
|
# /usr/sbin/httpd-worker, etc.) and serverflags
|
|
|
|
#
|
|
|
|
find_mpm
|
|
|
|
if [ -n "$HTTPD_MPM" ]; then
|
|
|
|
apache_bin="$HTTPD_SBIN_BASE-$HTTPD_MPM"
|
|
|
|
if ! [ -x $apache_bin ]; then
|
|
|
|
echo >&2 "$apache_bin-$APACHE_MPM is not a valid httpd binary."
|
|
|
|
echo >&2 "Check your APACHE_MPM setting in /etc/sysconfig/apache2."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo >&2 "${warn}No Apache binary found. No MPM package installed? $norm"
|
|
|
|
echo >&2 "Hint: install the apache2-prefork package, and try again."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# server flags from APACHE_SERVER_FLAGS
|
2011-09-12 14:20:52 +02:00
|
|
|
for i in $APACHE_SERVER_FLAGS; do
|
|
|
|
case $i in
|
|
|
|
-D) ;;
|
|
|
|
-D*) server_flags="$server_flags $i";;
|
|
|
|
*) server_flags="$server_flags -D$i";;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2015-07-13 10:18:58 +02:00
|
|
|
#
|
|
|
|
# head configuration file
|
|
|
|
#
|
|
|
|
httpd_conf=${APACHE_HTTPD_CONF:-/etc/apache2${instance_suffix}/httpd.conf}
|
|
|
|
|
2015-10-13 13:37:24 +02:00
|
|
|
#
|
|
|
|
# where to write configuration depending on sysconfig variables
|
|
|
|
#
|
|
|
|
sysconfd_dir=$(dirname $httpd_conf)/sysconfig${instance_suffix}.d/
|
|
|
|
|
2015-07-13 10:18:58 +02:00
|
|
|
#
|
2015-07-14 11:04:22 +02:00
|
|
|
# set PidFile to this file name; PidFile should not
|
|
|
|
# be used in the configuration to change this, otherwise
|
|
|
|
# stopping will not work
|
2015-07-13 10:18:58 +02:00
|
|
|
#
|
2015-07-14 11:04:22 +02:00
|
|
|
pid_file=/var/run/httpd${instance_suffix}.pid
|
2015-07-13 10:18:58 +02:00
|
|
|
|
|
|
|
unset sysconfig_setting
|
|
|
|
#
|
|
|
|
# involve the sysconfig variables
|
|
|
|
#
|
2015-10-13 13:37:24 +02:00
|
|
|
mkdir -p ${sysconfd_dir} || exit 1
|
|
|
|
for c in global.conf include.conf loadmodule.conf; do
|
|
|
|
echo "# File generated from $SYSCONFIG_FILE, do not edit. Edit the sysconfig file instead." > ${sysconfd_dir}/$c
|
|
|
|
done
|
|
|
|
# APACHE_ACCESS_LOG -> global.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
if [ -n "$APACHE_ACCESS_LOG" ]; then
|
2015-10-13 13:37:24 +02:00
|
|
|
echo "CustomLog $APACHE_ACCESS_LOG" >> ${sysconfd_dir}/global.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
fi
|
2015-10-13 13:37:24 +02:00
|
|
|
# APACHE_CONF_INCLUDE_FILES -> include.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
for file in $APACHE_CONF_INCLUDE_FILES; do
|
2015-10-26 10:36:35 +01:00
|
|
|
test ${file:0:1} = / || file=/etc/apache2/$file
|
|
|
|
if [ ! -e $file ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
echo "Include $file" >> ${sysconfd_dir}/include.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
done
|
2015-10-13 13:37:24 +02:00
|
|
|
# APACHE_CONF_INCLUDE_DIRS -> include.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
for dir in $APACHE_CONF_INCLUDE_DIRS; do
|
2015-10-26 10:36:35 +01:00
|
|
|
test ${dir:0:1} = / || dir=/etc/apache2/$dir
|
|
|
|
if [ ! -e $dir ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
echo "Include $dir" >> ${sysconfd_dir}/include.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
done
|
2015-10-13 13:37:24 +02:00
|
|
|
# APACHE_SERVERADMIN -> global.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
if [ -n "$APACHE_SERVERADMIN" ]; then
|
2015-10-13 13:37:24 +02:00
|
|
|
echo "ServerAdmin $APACHE_SERVERADMIN" >> ${sysconfd_dir}/global.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
fi
|
2015-10-13 13:37:24 +02:00
|
|
|
# APACHE_SERVERNAME -> global.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
if [ -n "$APACHE_SERVERNAME" ]; then
|
2015-10-13 13:37:24 +02:00
|
|
|
echo "ServerName $APACHE_SERVERNAME" >> ${sysconfd_dir}/global.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
fi
|
|
|
|
# APACHE_START_TIMEOUT
|
|
|
|
# not used nowadays
|
2015-10-13 13:37:24 +02:00
|
|
|
# APACHE_SERVERSIGNATURE -> global.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
if [ -n "$APACHE_SERVERSIGNATURE" ]; then
|
2015-10-13 13:37:24 +02:00
|
|
|
echo "ServerSignature $APACHE_SERVERSIGNATURE" >> ${sysconfd_dir}/global.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
fi
|
2015-10-13 13:37:24 +02:00
|
|
|
# APACHE_LOGLEVEL -> global.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
if [ -n "$APACHE_LOGLEVEL" ]; then
|
2015-11-05 09:31:34 +01:00
|
|
|
echo "LogLevel $APACHE_LOGLEVEL" >> ${sysconfd_dir}/global.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
fi
|
2015-10-13 13:37:24 +02:00
|
|
|
# APACHE_USE_CANONICAL_NAME -> global.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
if [ -n "$APACHE_USE_CANONICAL_NAME" ]; then
|
2015-10-13 13:37:24 +02:00
|
|
|
echo "UseCanonicalName $APACHE_USE_CANONICAL_NAME" >> ${sysconfd_dir}/global.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
fi
|
2015-10-13 13:37:24 +02:00
|
|
|
# APACHE_SERVERTOKENS -> global.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
if [ -n "$APACHE_SERVERTOKENS" ]; then
|
2015-10-13 13:37:24 +02:00
|
|
|
echo "ServerTokens $APACHE_SERVERTOKENS" >> ${sysconfd_dir}/global.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
fi
|
2015-10-13 13:37:24 +02:00
|
|
|
# APACHE_EXTENDED_STATUS -> global.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
if [ -n "$APACHE_EXTENDED_STATUS" ]; then
|
2015-10-13 13:37:24 +02:00
|
|
|
echo "ExtendedStatus $APACHE_EXTENDED_STATUS" >> ${sysconfd_dir}/global.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
fi
|
2015-10-13 13:37:24 +02:00
|
|
|
# APACHE_MODULES -> loadmodule.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
get_module_list
|
|
|
|
module_ids=($HTTPD_MODULE_IDS)
|
|
|
|
module_paths=($HTTPD_MODULE_PATHS)
|
|
|
|
for i in "${!module_ids[@]}"; do
|
2015-10-13 13:37:24 +02:00
|
|
|
echo "LoadModule ${module_ids[$i]} ${module_paths[$i]}" >> ${sysconfd_dir}/loadmodule.conf
|
2015-07-13 10:18:58 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
#
|
|
|
|
# a proper home should be set, otherwise the server might end up
|
|
|
|
# with HOME=/root and some script might try to use that
|
|
|
|
#
|
|
|
|
HOME=/var/lib/apache2${instance_suffix}
|
|
|
|
|
|
|
|
#
|
|
|
|
# run Apache
|
|
|
|
#
|
|
|
|
|
|
|
|
exec $apache_bin -f $httpd_conf $server_flags \
|
2015-07-14 11:04:22 +02:00
|
|
|
-C "PidFile $pid_file" \
|
2015-10-13 13:37:24 +02:00
|
|
|
-C "Include $sysconfd_dir" \
|
2015-07-13 10:18:58 +02:00
|
|
|
"${sysconfig_setting[@]}" \
|
|
|
|
$@
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|