#! /bin/sh -e

mv_conffile() {
	if [ "`md5sum $1 2>/dev/null | cut -d ' ' -f 1`" = "$2" ] ; then
		echo Replacing $1 with new version ...
		mv $1 $1.dpkg-apache2.2-common.old
	fi
}

if [ -n "$2" ] && dpkg --compare-versions "$2" lt 2.2.4-2; then
	mv_conffile /etc/default/apache2 	9ac83f9132b78c3aa6dd4d7a583bf476
	mv_conffile /etc/default/apache2 	801eb5156368b54d92ecb578ce710836
	mv_conffile /etc/apache2/ports.conf	d5fcefc335117f400d451de47efeca87
	mv_conffile /etc/apache2/conf.d/charset 641239a7d2d172856cb1413a47d2e142
fi

if [ -n "$2" ] && dpkg --compare-versions "$2" lt 2.2.15-4~ ; then
	# The definition of other_vhosts_access.log has been moved from
	# apache2.conf to conf.d/other-vhosts-access-log. If the admin has
	# removed it from apache2.conf, mark it to be disabled in
	# conf.d/other-vhosts-access-log in the postinst.
	if ! egrep -q '^ *CustomLog.*other_vhosts_access.log vhost_combined$' /etc/apache2/apache2.conf
	then
		touch /etc/apache2/disable-other-vhost-access-log.dpkg-apache2.2-common
	fi
fi

dpkg-maintscript-helper rm_conffile /etc/apache2/mods-available/version.load 2.2.22-6~ -- "$@"

#DEBHELPER#
