#!/bin/sh

set -e

#DEBHELPER#

case "$1" in
    purge)
        # Remove generated config and log files.
	rm -f /etc/owncloud/config.php
	rm -f /var/log/owncloud.log*
	CONF="owncloud"
	COMMON_STATE=$(dpkg-query -f '${Status}' -W 'apache2.2-common' 2>/dev/null | awk '{print $3}' || true)
	if [ -e /usr/share/apache2/apache2-maintscript-helper ] && [ -e /etc/apache2/conf-enabled/$CONF.conf ] ; then
		. /usr/share/apache2/apache2-maintscript-helper
		apache2_invoke disconf $CONF  || exit $?
	elif [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then
		[ -L /etc/apache2/conf.d/$CONF.conf ] && rm /etc/apache2/conf.d/$CONF.conf
	fi
    ;;

    remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
    ;;

    *)
        echo "postrm called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

exit 0
