#!/bin/sh
[ -n "$IPKG_INSTROOT" ] && exit 0
# Stop before the binary goes away, so the daemon gets its SIGTERM while it can
# still put the routing back. A removal that left the tunnel's rules behind
# would take the router off the network with no software left to fix it.
if [ -x /etc/init.d/meduzavpn ]; then
	/etc/init.d/meduzavpn stop >/dev/null 2>&1
	/etc/init.d/meduzavpn disable >/dev/null 2>&1
fi
# And take the firewall zone with it. A zone matching meduza+ left behind after
# the software is gone is a rule nobody can explain and nobody will delete.
if [ -x /usr/share/meduzavpn/firewall-zone.sh ]; then
	/usr/share/meduzavpn/firewall-zone.sh remove >/dev/null 2>&1
fi
exit 0
