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"
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.
#
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."
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
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.
#