#!/bin/sh
#
# Debian prerm script for dwww.
# "@(#)dwww:$Id: dwww.prerm,v 1.5 2007-01-01 10:42:36 robert Exp $"
#

set -e

#DEBHELPER#

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

	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`readlink -f "$cfile"` = x"$dwwwf" ]; then
			rm -f "$cfile"
		elif [ -e "$cfile" ]; then
			echo "$cfile exists, but isn't symlinked to $dwwwf. Not removing"
		fi
	done		


	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" ] && [ -d "$DWWW_DOCROOTDIR/dwww" ]; then
			rm -rf "$DWWW_DOCROOTDIR/dwww"
		fi
	fi
fi

exit 0
