#!/bin/sh
set -e

if [ "$1" = remove ]; then
    rm -rf /var/lib/unbound
fi

if [ "$1" = purge ]; then
    rm -f /etc/unbound/unbound_control.key \
        /etc/unbound/unbound_control.pem \
        /etc/unbound/unbound_server.key \
        /etc/unbound/unbound_server.pem
    rm -f /var/lib/unbound/root.key
fi

# Automatically added by dh_installinit/13.11.4
if [ "$1" = "remove" ] && [ -x "/etc/init.d/unbound" ] ; then
	chmod -x "/etc/init.d/unbound" >/dev/null || true
fi
if [ -z "${DPKG_ROOT:-}" ] && [ "$1" = "purge" ] ; then
	update-rc.d unbound remove >/dev/null
fi
# End automatically added section
# Automatically added by dh_installdeb/13.11.4
dpkg-maintscript-helper rm_conffile /etc/unbound/unbound.conf.d/qname-minimisation.conf 1.9.6-2\~ -- "$@"
# End automatically added section
# Automatically added by dh_installsystemd/13.11.4
if [ "$1" = remove ] && [ -d /run/systemd/system ] ; then
	systemctl --system daemon-reload >/dev/null || true
fi
# End automatically added section
# Automatically added by dh_installsystemd/13.11.4
if [ "$1" = "purge" ]; then
	if [ -x "/usr/bin/deb-systemd-helper" ]; then
		deb-systemd-helper purge 'unbound-resolvconf.service' >/dev/null || true
	fi
fi
# End automatically added section
# Automatically added by dh_installsystemd/13.11.4
if [ "$1" = remove ] && [ -d /run/systemd/system ] ; then
	systemctl --system daemon-reload >/dev/null || true
fi
# End automatically added section
# Automatically added by dh_installsystemd/13.11.4
if [ "$1" = "purge" ]; then
	if [ -x "/usr/bin/deb-systemd-helper" ]; then
		deb-systemd-helper purge 'unbound.service' >/dev/null || true
	fi
fi
# End automatically added section
# Automatically added by dh_apparmor/3.0.8-3
if [ "$1" = "purge" ] && ! [ -e "/etc/apparmor.d/usr.sbin.unbound" ] ; then
    rm -f "/etc/apparmor.d/disable/usr.sbin.unbound" || true
    rm -f "/etc/apparmor.d/force-complain/usr.sbin.unbound" || true
    rm -f "/etc/apparmor.d/local/usr.sbin.unbound" || true
    rm -f /var/cache/apparmor/*/"usr.sbin.unbound" || true
    rmdir /etc/apparmor.d/disable 2>/dev/null || true
    rmdir /etc/apparmor.d/local   2>/dev/null || true
    rmdir /etc/apparmor.d         2>/dev/null || true
fi
# End automatically added section

