#!/bin/sh

local ql_cust_firewall_config=$(uci get ql_cust_config.@qcmap_configs[0].firewall_config)

[ "$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

fw3 -q network "$INTERFACE" >/dev/null || exit 0

#rico-20240826, add for firewall feature preconfiguration.
if [[ -z $ql_cust_firewall_config ]] || [ $ql_cust_firewall_config -eq 1 ]; then
  logger -t firewall "Reloading firewall due to $ACTION of $INTERFACE ($DEVICE)"
  fw3 -q reload
else
  logger -t firewall "Do Not Reloading firewall due to $ACTION of $INTERFACE ($DEVICE)"
fi

