# pacman install script of plinius-forward: applies /etc/plinius-forward.conf right away (the
# firewall's policy for forwarded traffic). On removal the policy goes back to the kernel's
# default (accept everything) and the chain "plinius-forward" leaves the mangle table, as it was
# without the package.

post_install() {
	/usr/lib/plinius-forward/plinius-forward-set apply || true
}

post_upgrade() {
	post_install
}

pre_remove() {
	local t
	for t in iptables-legacy ip6tables-legacy; do
		command -v "$t" >/dev/null || continue
		"$t" -w -P FORWARD ACCEPT 2>/dev/null || true
		while "$t" -w -t mangle -D FORWARD -j plinius-forward 2>/dev/null; do :; done
		"$t" -w -t mangle -F plinius-forward 2>/dev/null || true
		"$t" -w -t mangle -X plinius-forward 2>/dev/null || true
	done
	return 0
}
