#!/bin/sh
# vim: syntax=sh ts=4 sw=4 sts=4 sr noet
# postrm script for arno-iptables-firewall
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postrm> `remove'
#        * <postrm> `purge'
#        * <old-postrm> `upgrade' <new-version>
#        * <new-postrm> `failed-upgrade' <old-version>
#        * <new-postrm> `abort-install'
#        * <new-postrm> `abort-install' <old-version>
#        * <new-postrm> `abort-upgrade' <old-version>
#        * <disappearer's-postrm> `disappear' <overwriter>
#          <overwriter-version>
# for details, see https://www.debian.org/doc/debian-policy/ or
# the debian-policy package


# start up debconf here. 
# why? see https://manpages.debian.org/testing/debconf-doc/debconf-devel.7.en.html, paragraph HACKS. 
# plus automatically inserted code may be using debconf
# (in fact it does, and loads confmodule a little bit late IMHO)
. /usr/share/debconf/confmodule
db_version 2.0

case "$1" in
	purge)
		# when purging remove debconf managed config file
		if [ -e /etc/arno-iptables-firewall/conf.d/00debconf.conf ]; then
			rm -f /etc/arno-iptables-firewall/conf.d/00debconf.conf || true
		fi
	;;
	
	remove|disappear)
		update-rc.d -f arno-iptables-firewall remove >/dev/null || true
	;;

	upgrade|failed-upgrade|abort-install|abort-upgrade)
		# we don't stop on upgrades so that the firewall keeps operational.
		# this works since there's only a set of iptables rules, no real daemon.
		# eventually postinst configure replaces them with a new set of rules.
	;;

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

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
