apache2/get_module_list

159 lines
4.7 KiB
Bash

#!/bin/bash
pname=apache2
: ${sysconfdir:=/etc/$pname}
: ${sysconfig_apache:=/etc/sysconfig/$pname}
default_APACHE_DOCUMENT_ROOT=/srv/www/htdocs
test -z "$APACHE_MODULES" && . /usr/share/$pname/load_configuration
apache_bin=$(/usr/share/$pname/find_mpm 2>/dev/null)
APACHE_MPM=${apache_bin##*-}
if [ -z "$APACHE_MPM" ]; then
echo >&2 Warning: no MPM found. Some modules are dependant on the type of MPM.
fi
if [ "$1" = -q ]; then
quiet=true
else
quiet=false
fi
#echo -n writing sysconfig.d/loadmodule.conf
TMPFILE=`/bin/mktemp /tmp/$pname.XXXXXXXXXXXX`
if [ -z "$TMPFILE" ]; then
echo >&2 Error: could not create temporary file for writing loadmodules.conf.
exit 1
fi
exec 3>$TMPFILE
echo >&3 "#
# Files in this directory are created at apache start time by /usr/sbin/rc$pname
# Do not edit them!
#
# as listed in APACHE_MODULES ($sysconfig_apache)
"
test -z "$APACHE_MODULES" && APACHE_MODULES=$LOADMODULES
# see whether APACHE_MODULES is declared as array (it was so, in the past)
# if it is not an array, we convert it to one.
if [[ -z ${APACHE_MODULES[1]} ]]; then
# strip leading and trailing parens... since it might erroneously be written as
# APACHE_MODULES="(asdf 1234)"
APACHE_MODULES=${APACHE_MODULES/(}; APACHE_MODULES=${APACHE_MODULES/)}
APACHE_MODULES=($APACHE_MODULES)
fi
for i in ${APACHE_MODULES[*]}; do
unset module_path module_id
case $i in mod_cgid|cgid) case $APACHE_MPM in prefork|leader) i=${i%d};; esac;; esac
case $i in mod_cgi|cgi) case $APACHE_MPM in event|worker) i=${i}d;; esac;; esac
module_id=${i##*/}
module_id=${module_id#mod_}
module_id=${module_id#lib}
module_id=${module_id%.so}_module
# special case
case $module_id in auth_mysql_module) module_id=mysql_auth_module;; esac
case $i in
/*)
module_path=$i
;;
*)
for j in /usr/lib/$pname-$APACHE_MPM/mod_$i.so \
/usr/lib/$pname-$APACHE_MPM/$i.so \
/usr/lib/$pname-$APACHE_MPM/mod_$i \
/usr/lib/$pname-$APACHE_MPM/$i \
/usr/lib/$pname-$APACHE_MPM/${i/mod_}.so \
/usr/lib/$pname-$APACHE_MPM/${i/mod_} \
/usr/lib/$pname-$APACHE_MPM/lib${i/mod_}.so \
/usr/lib/$pname-$APACHE_MPM/lib${i/mod_} \
/usr/lib/$pname-$APACHE_MPM/lib$i.so \
/usr/lib/$pname-$APACHE_MPM/lib$i \
/usr/lib/$pname/mod_$i.so \
/usr/lib/$pname/$i.so \
/usr/lib/$pname/mod_$i \
/usr/lib/$pname/$i \
/usr/lib/$pname/${i/mod_}.so \
/usr/lib/$pname/${i/mod_} \
/usr/lib/$pname/lib${i/mod_}.so \
/usr/lib/$pname/lib${i/mod_} \
/usr/lib/$pname/lib$i.so \
/usr/lib/$pname/lib$i
do
if [ -f $j ]; then
module_path=$j
break
fi
done
;;
esac
if [[ -f $module_path ]]; then
printf "LoadModule %-30s %s\n" $module_id $module_path >&3
else
# print a warning?
# php modules are in the list by default, so we don't warn about it [#66729]
if ! $quiet && [ $i != "php4" -a $i != "php5" ]; then
echo >&2 "Module \"$i\" is not installed, ignoring."
echo >&2 "Check the APACHE_MODULES setting in /etc/sysconfig/$pname."
fi
fi
done
echo >&3 -e "#\n"
exec 3<&-
chmod 644 $TMPFILE
mv $TMPFILE $sysconfdir/sysconfig.d/loadmodule.conf
#echo -n ". "
#echo -n writing sysconfig.d/global.conf
exec 3>$sysconfdir/sysconfig.d/global.conf
echo >&3 "#
# Files in this directory are created at apache start time by /usr/sbin/rc$pname
# Do not edit them!
#
# see $sysconfig_apache
"
if [[ -n $APACHE_DOCUMENT_ROOT ]]; then
echo >&3 "DocumentRoot $APACHE_DOCUMENT_ROOT"
# else
# if ! grep -q "^DocumentRoot" $sysconfdir/httpd.conf 2>/dev/null; then
# echo >&3 "DocumentRoot $default_APACHE_DOCUMENT_ROOT"
# fi
fi
[[ -n $APACHE_TIMEOUT ]] && echo >&3 "Timeout $APACHE_TIMEOUT"
if [[ -n $APACHE_SERVERSIGNATURE ]]; then
case $APACHE_SERVERSIGNATURE in
no) APACHE_SERVERSIGNATURE=off;;
yes) APACHE_SERVERSIGNATURE=on;;
esac
echo >&3 "ServerSignature $APACHE_SERVERSIGNATURE"
fi
[[ -n $APACHE_SERVERADMIN ]] && echo >&3 "ServerAdmin $APACHE_SERVERADMIN"
[[ -n $APACHE_SERVERNAME ]] && echo >&3 "ServerName $APACHE_SERVERNAME"
[[ -n $APACHE_USE_CANONICAL_NAME ]] && echo >&3 "UseCanonicalName $APACHE_USE_CANONICAL_NAME"
[[ -n $APACHE_SERVERTOKENS ]] && echo >&3 "ServerTokens $APACHE_SERVERTOKENS"
[[ $APACHE_EXTENDED_STATUS = on ]] && echo -e >&3 "<IfModule mod_status.c>\n ExtendedStatus on\n</IfModule>"
[[ $APACHE_BUFFERED_LOGS = on ]] && echo >&3 "BufferedLogs on"
[[ -n $APACHE_LOGLEVEL ]] && echo >&3 "LogLevel $APACHE_LOGLEVEL"
if [[ -n $APACHE_ACCESS_LOG ]]; then
# split multiple entries
APACHE_ACCESS_LOG=($APACHE_ACCESS_LOG)
for ((i=0; $i<${#APACHE_ACCESS_LOG[*]}; i=i+2)); do
filename=${APACHE_ACCESS_LOG[$i]}
format=${APACHE_ACCESS_LOG[$i+1]}
echo >&3 "CustomLog $filename ${format/%,}"
done
fi
exec 3<&-
#echo -n ". "