X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=debian%2Fpostinst;h=cd51a84f0e56a5a3446ff836a22dcb848a07939d;hb=01292feb10ab9abeb7955f5108458c7d786452ec;hp=abc7092b70792813d078733e5606f3fcee5a8422;hpb=8a4e09dd5d133cc1a4ae4d74bedd499fc71e8ed0;p=apache2-cn.git diff --git a/debian/postinst b/debian/postinst index abc7092..cd51a84 100755 --- a/debian/postinst +++ b/debian/postinst @@ -2,28 +2,13 @@ set -e +[ "$1" = "configure" ] || exit 0 [ "$DEBIAN_SCRIPT_DEBUG" ] && set -vx -# Source debconf library. +# Load Debconf . /usr/share/debconf/confmodule -case "$1" in - configure) - # continue below - ;; - - abort-upgrade|abort-remove|abort-deconfigure) - exit 0 - ;; - - *) - echo "postinst called with unknown argument \`$1'" >&2 - exit 0 - ;; -esac - - -# Include CARNet functions. +# Load CARNet Tools . /usr/share/carnet-tools/functions.sh PKG="apache2-cn" @@ -395,6 +380,25 @@ rename_conf () { fi } +# listconffiles() +# +# Recursively walks /etc/apache2/apache2.conf for Include and +# IncludeOptional directives. +# Prints all configfiles so defined. +# +listconffiles () { + local i incs + local base_dir="`dirname $1`" + + incs=`awk 'tolower($1) ~ /include(optional)?/ { sub("/$","/*",$2); print $2; }' $1` + incs=`echo "$incs" | sed -r "s#^([^/])#${base_dir}/\1#"` + if [ -n "$incs" ]; then + for i in $incs; do + if [ -e "$i" ]; then echo "`readlink -m -q $i`"; listconffiles "$i"; fi + done + fi +} + # Set trap for deleting all temp files. # @@ -417,7 +421,7 @@ backup_conf $CONFDIR/sites-available cp_echo "CN: Backup is located in directory: $BACKUPDIR/" -# Enable Apache2 web server modules (mpm_prefork, cgi, rewrite, userdir, suexec, php5, ssl). +# Enable Apache2 web server modules (mpm_prefork, cgi, rewrite, userdir, suexec, php7.0, ssl). # if [ -e "$CONF" ]; then cp_echo "CN: Enabling the prefork Apache2 MPM." @@ -432,7 +436,7 @@ if [ -e "$CONF" ]; then a2enmod -m -q rewrite a2enmod -m -q userdir a2enmod -m -q suexec - a2enmod -m -q php5 + a2enmod -m -q php7.0 a2enmod -m -q ssl fi @@ -480,6 +484,43 @@ if [ -e "$CONF" ]; then rm -f "$CONFTMP" fi +# Remove deprecated directives. Add default Mutex if not defined. +# +if [ -e "$CONF" ]; then + + ( listconffiles "$CONF"; echo "$CONF" ) | while read -r a2cfile; do + + a2cfiletmp=`mktemp $a2cfile.tmp.XXXXXX` + temp_files="${temp_files} ${a2cfiletmp}" + cp "$a2cfile" "$a2cfiletmp" + + if egrep -iq "^[[:space:]]*NameVirtualHost[[:space:]]+" "$a2cfiletmp"; then + cp_echo "CN: Removing deprecated NameVirtualHost from $a2cfile" + sed -r -i '/^[[:space:]]*NameVirtualHost[[:space:]]+/Id' \ + "$a2cfiletmp" + fi + + if egrep -iq "^[[:space:]]*SSLMutex[[:space:]]+" "$a2cfiletmp"; then + cp_echo "CN: Removing deprecated SSLMutex from $a2cfile" + sed -r -i '/^[[:space:]]*SSLMutex[[:space:]]+/Id' \ + "$a2cfiletmp" + fi + + if [ "$a2cfile" = "$CONF" ]; then + if ! egrep -iq "^[[:space:]]*Mutex[[:space:]]+" "$a2cfiletmp"; then + cp_echo "CN: Adding default Mutex to $a2cfile" + echo 'Mutex file:${APACHE_LOCK_DIR} default' >> "$a2cfiletmp" + fi + fi + + if ! cmp -s "$a2cfiletmp" "$a2cfile"; then + cp_mv "$a2cfiletmp" "$a2cfile" + need_restart=1 + fi + rm -f "$a2cfiletmp" + done +fi + # Install CARNet specific configuration file. #