#!/bin/sh

# unfortunately, UCI doesn't provide a nice way to add an anonymous section only if it doesn't already exist
if ! uci show firewall | grep -q firewall.fail2ban; then
  name="$(uci add firewall include)"
  uci set "firewall.${name}.path=/etc/firewall.fail2ban"
  uci set "firewall.${name}.enabled=1"
  uci set "firewall.${name}.reload=1"
  echo -e "Adding the following UCI config:\n $(uci changes)"
  uci commit
fi

exit 0
