#!/bin/sh
# Pre-release builds put the fw4 tun accept in chain-pre/forward_lan (lan
# zone only); it is back at the head of the forward chain (chain-pre/forward)
# so clients reaching the router through a WAN-zone port (drop-in gateway,
# WAN-port side router) keep working across a firewall reload. The
# apk/no-opkg installers only extract over old files: remove it here.
rm -f /usr/share/nftables.d/chain-pre/forward_lan/ednovas.nft
rmdir /usr/share/nftables.d/chain-pre/forward_lan 2>/dev/null
# Register the fw3 firewall include on iptables-only firmwares. fw4 systems
# use the nftables drop-in (/usr/share/nftables.d/chain-pre/forward) instead
# and would reject the legacy `reload` option, so skip them.
command -v fw4 >/dev/null 2>&1 && exit 0
uci -q get firewall.ednovas >/dev/null && exit 0
uci set firewall.ednovas=include
uci set firewall.ednovas.type='script'
uci set firewall.ednovas.path='/usr/share/ednovas/firewall.include.sh'
uci set firewall.ednovas.reload='1'
uci commit firewall
exit 0
