#!/bin/sh
#
# Debian prerm script for dwww.
# "@(#)dwww:$Id: dwww.prerm,v 1.3 2005-09-15 22:30:26 robert Exp $"
#

set -e

#DEBHELPER#

if [ "X$1" = "Xremove" ] ; then
	rm -rf /var/lib/dwww
	rm -rf /var/cache/dwww

	if [ -r /etc/dwww/dwww.conf ]; then
		set +e
		. /etc/dwww/dwww.conf

		if [ -n "$DWWW_CGIDIR" ] && [ -x "$DWWW_CGIDIR/dwww" ] ; then
			rm -f "$DWWW_CGIDIR/dwww"
		fi

		if [ -n "$DWWW_DOCROOTDIR" ] && [ -L "$DWWW_DOCROOTDIR/dwww" ] ; then
			rm -f "$DWWW_DOCROOTDIR/dwww"
		fi
	fi

	for apache in "apache" "apache-perl" "apache-ssl" "apache2"; do
		cfile="/etc/$apache/conf.d/dwww"
		dwwwf="/etc/dwww/apache.conf"
		if [ -L "$cfile" ] && [ x`realpath "$cfile"` = x"$dwwwf" ]; then
			rm -f "$cfile"
		elif [ -e "$cfile" ]; then
			echo "$cfile exists, but it isn't symlinked to $dwwwf. Not removing"
		fi
	done		
		
fi

exit 0
