You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.1 KiB

  1. #!/bin/sh
  2. [ "$ACTION" == "ifup" -o "$ACTION" == "ifdown" ] || exit 1
  3. [ -n "$INTERFACE" ] || exit 2
  4. if [ "$ACTION" == "ifup" ]; then
  5. [ -n "$DEVICE" ] || exit 3
  6. fi
  7. [ -x /usr/bin/ip ] || exit 4
  8. [ -x /usr/sbin/ipset ] || exit 5
  9. [ -x /usr/sbin/iptables ] || exit 6
  10. [ -x /usr/sbin/ip6tables ] || exit 7
  11. [ -x /usr/bin/logger ] || exit 8
  12. . /lib/functions.sh
  13. . /lib/functions/network.sh
  14. . /lib/mwan3/mwan3.sh
  15. config_load mwan3
  16. config_get enabled $INTERFACE enabled 0
  17. [ "$enabled" == "1" ] || exit 0
  18. $LOG notice "$ACTION interface $INTERFACE (${DEVICE:-unknown})"
  19. mwan3_set_connected_iptables
  20. case "$ACTION" in
  21. ifup)
  22. mwan3_set_general_rules
  23. mwan3_set_general_iptables
  24. mwan3_create_iface_rules $INTERFACE $DEVICE
  25. mwan3_create_iface_iptables $INTERFACE $DEVICE
  26. mwan3_create_iface_route $INTERFACE $DEVICE
  27. mwan3_track $INTERFACE $DEVICE
  28. mwan3_set_user_rules
  29. ;;
  30. ifdown)
  31. mwan3_delete_iface_rules $INTERFACE
  32. mwan3_delete_iface_iptables $INTERFACE
  33. mwan3_delete_iface_route $INTERFACE
  34. mwan3_delete_iface_ipset_entries $INTERFACE
  35. ;;
  36. esac
  37. config_foreach mwan3_create_policies_iptables policy
  38. exit 0