2024-01-05 20:27:07 +01:00
|
|
|
#!/bin/bash
|
|
|
|
# update_httpdconf.sh - updates httpd.conf modules list
|
2024-01-05 20:27:08 +01:00
|
|
|
# Copyright (c) 2006-2016 by Silvan Calarco <silvan.calarco@qilinux.it>
|
2024-01-05 20:27:07 +01:00
|
|
|
|
|
|
|
INPUT_CONF=/etc/httpd/httpd.conf.rpmnew
|
|
|
|
OUTPUT_CONF=/etc/httpd/httpd.conf
|
|
|
|
MODULES_PREFIX=/usr
|
2024-01-05 20:27:08 +01:00
|
|
|
if [ -d /usr/lib64/apache ]; then
|
|
|
|
MODULES_APPEND=lib64/apache
|
|
|
|
else
|
|
|
|
MODULES_APPEND=lib/apache
|
|
|
|
fi
|
2024-01-05 20:27:07 +01:00
|
|
|
MODULES_PATH=$MODULES_PREFIX/$MODULES_APPEND
|
|
|
|
cont=0
|
|
|
|
|
|
|
|
# no rpmnew file ? silently nothing to do
|
|
|
|
[ -e $INPUT_CONF ] || exit 0
|
|
|
|
|
|
|
|
for a in `grep ^LoadModule $INPUT_CONF | gawk '{ print $3 }'`; do
|
|
|
|
MODULE[$cont]=`echo $a | sed "s|.*/mod_\(.*\)\.so|\1|"`
|
|
|
|
let cont+=1
|
|
|
|
done
|
|
|
|
|
|
|
|
# remove missing modules
|
|
|
|
for a in `grep ^LoadModule $OUTPUT_CONF | gawk '{ print $3 }'`; do
|
|
|
|
[ -e $MODULES_PREFIX/$a ] || {
|
|
|
|
echo "Removing missing module $a"
|
|
|
|
A=`echo $a | sed 's|\/|\\\\\/|g'`
|
|
|
|
sed -i "/^LoadModule .* $A/d" $OUTPUT_CONF
|
|
|
|
}
|
|
|
|
done
|
|
|
|
|
|
|
|
ANCHOR_LINE=`grep "^LoadModule .*" $OUTPUT_CONF | tail -n 1 | sed 's|\/|\\\\\/|g'`
|
|
|
|
|
|
|
|
#echo $ANCHOR_LINE
|
|
|
|
#exit 1
|
|
|
|
|
|
|
|
# adding new modules
|
|
|
|
for a in ${MODULE[*]}; do
|
2024-01-05 20:27:08 +01:00
|
|
|
[ ${a:0:4} == "mpm_" ] && continue
|
2024-01-05 20:27:07 +01:00
|
|
|
grep "^LoadModule .* $MODULES_APPEND/mod_$a.so" $OUTPUT_CONF >/dev/null || {
|
2024-01-05 20:27:08 +01:00
|
|
|
echo "Configuring module $a"
|
2024-01-05 20:27:07 +01:00
|
|
|
sed -i "/${ANCHOR_LINE}/a \
|
|
|
|
LoadModule ${a}_module $MODULES_APPEND\/mod_$a.so" $OUTPUT_CONF
|
|
|
|
ANCHOR_LINE=`echo "LoadModule ${a}_module $MODULES_APPEND/mod_$a.so" | sed 's|\/|\\\\\/|g'`
|
|
|
|
}
|
|
|
|
done
|
|
|
|
|
|
|
|
sed -i "s|/etc/httpd/ssl.conf|/etc/httpd/extra/httpd-ssl.conf|" $OUTPUT_CONF
|