1
0

firewall.init 997 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/sh /etc/rc.common
  2. START=19
  3. USE_PROCD=1
  4. QUIET=""
  5. validate_firewall_redirect()
  6. {
  7. uci_validate_section firewall redirect "${1}" \
  8. 'proto:or(uinteger, string)' \
  9. 'src:string' \
  10. 'src_ip:cidr' \
  11. 'src_dport:or(port, portrange)' \
  12. 'dest:string' \
  13. 'dest_ip:cidr' \
  14. 'dest_port:or(port, portrange)' \
  15. 'target:or("SNAT", "DNAT")'
  16. }
  17. validate_firewall_rule()
  18. {
  19. uci_validate_section firewall rule "${1}" \
  20. 'proto:or(uinteger, string)' \
  21. 'src:string' \
  22. 'dest:string' \
  23. 'src_port:or(port, portrange)' \
  24. 'dest_port:or(port, portrange)' \
  25. 'target:string'
  26. }
  27. service_triggers() {
  28. procd_add_reload_trigger firewall
  29. procd_open_validate
  30. validate_firewall_redirect
  31. validate_firewall_rule
  32. procd_close_validate
  33. }
  34. restart() {
  35. fw3 restart
  36. }
  37. start_service() {
  38. fw3 ${QUIET} start
  39. }
  40. stop_service() {
  41. fw3 flush
  42. }
  43. reload_service() {
  44. fw3 reload
  45. }
  46. boot() {
  47. # Be silent on boot, firewall might be started by hotplug already,
  48. # so don't complain in syslog.
  49. QUIET=-q
  50. start
  51. }