2024/APs/etc/hotplug.d/iface/20-firewall

19 lines
515 B
Bash

#!/bin/sh
has_zone() {
fw4 -q network "$INTERFACE" >/dev/null && return 0
eval $(ubus call "network.interface.$INTERFACE" status | jsonfilter -e 'ZONE=@.data.zone')
fw4 -q zone "$ZONE" >/dev/null
}
[ "$ACTION" = ifup -o "$ACTION" = ifupdate ] || exit 0
[ "$ACTION" = ifupdate -a -z "$IFUPDATE_ADDRESSES" -a -z "$IFUPDATE_DATA" ] && exit 0
/etc/init.d/firewall enabled || exit 0
has_zone || exit 0
logger -t firewall "Reloading firewall due to $ACTION of $INTERFACE ($DEVICE)"
fw4 -q reload
/etc/fw_mod.sh &