#!/bin/sh

set -e

if [ "$1" = "purge" ]; then
	# Remove lease database
	rm -f /var/lib/dhcp/dhclient*.leases
	rm -f /var/lib/dhcp/dhclient*.lease

	# Try to remove directory
	if [ -d /var/lib/dhcp ]; then
		rmdir --ignore-fail-on-non-empty /var/lib/dhcp/
	fi

	rmdir --ignore-fail-on-non-empty /etc/dhcp

fi

# https://bugs.debian.org/1102626
if dpkg-maintscript-helper supports mv_conffile; then
dpkg-maintscript-helper mv_conffile \
    /etc/apparmor.d/sbin.dhclient /etc/apparmor.d/usr.sbin.dhclient 4.4.3-P1-7~ -- "$@"
fi

# Automatically added by dh_apparmor/4.1.0-1
if [ "$1" = "purge" ] && ! [ -e "/etc/apparmor.d/usr.sbin.dhclient" ] ; then
    rm -f "/etc/apparmor.d/disable/usr.sbin.dhclient" || true
    rm -f "/etc/apparmor.d/force-complain/usr.sbin.dhclient" || true
    rm -f "/etc/apparmor.d/local/usr.sbin.dhclient" || true
    rm -f /var/cache/apparmor/*/"usr.sbin.dhclient" || 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

