20-firewall 498 B

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