apache/httpd-update_httpdconf.sh

45 lines
1.3 KiB
Bash

#!/bin/bash
# update_httpdconf.sh - updates httpd.conf modules list
# Copyright (c) 2006 by Silvan Calarco <silvan.calarco@qilinux.it>
INPUT_CONF=/etc/httpd/httpd.conf.rpmnew
OUTPUT_CONF=/etc/httpd/httpd.conf
MODULES_PREFIX=/usr
MODULES_APPEND=lib/apache
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
grep "^LoadModule .* $MODULES_APPEND/mod_$a.so" $OUTPUT_CONF >/dev/null || {
#echo "Configuring module $a"
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