diff options
author | Karel Kočí <cynerd@email.cz> | 2021-05-15 13:16:12 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2021-05-15 13:16:12 +0200 |
commit | 53f535f7ccfeaf191c11350f422b062b68870ae3 (patch) | |
tree | b552c105827df5d35661a83dc325ecdd6e2fa88d /firewall/files/firewall.init | |
parent | ef7468756e2e509c3972b95da934a02173c34a0a (diff) | |
download | openwrt-personal-pkgs-53f535f7ccfeaf191c11350f422b062b68870ae3.tar.gz openwrt-personal-pkgs-53f535f7ccfeaf191c11350f422b062b68870ae3.tar.bz2 openwrt-personal-pkgs-53f535f7ccfeaf191c11350f422b062b68870ae3.zip |
firewall: add to test
Diffstat (limited to 'firewall/files/firewall.init')
-rwxr-xr-x | firewall/files/firewall.init | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/firewall/files/firewall.init b/firewall/files/firewall.init new file mode 100755 index 0000000..ee3ed1a --- /dev/null +++ b/firewall/files/firewall.init @@ -0,0 +1,61 @@ +#!/bin/sh /etc/rc.common + +START=19 +USE_PROCD=1 +QUIET="" + +validate_firewall_redirect() +{ + uci_validate_section firewall redirect "${1}" \ + 'proto:or(uinteger, string)' \ + 'src:string' \ + 'src_ip:cidr' \ + 'src_dport:or(port, portrange)' \ + 'dest:string' \ + 'dest_ip:cidr' \ + 'dest_port:or(port, portrange)' \ + 'target:or("SNAT", "DNAT")' +} + +validate_firewall_rule() +{ + uci_validate_section firewall rule "${1}" \ + 'proto:or(uinteger, string)' \ + 'src:string' \ + 'dest:string' \ + 'src_port:or(port, portrange)' \ + 'dest_port:or(port, portrange)' \ + 'target:string' +} + +service_triggers() { + procd_add_reload_trigger firewall + + procd_open_validate + validate_firewall_redirect + validate_firewall_rule + procd_close_validate +} + +restart() { + fw3 restart +} + +start_service() { + fw3 ${QUIET} start +} + +stop_service() { + fw3 flush +} + +reload_service() { + fw3 reload +} + +boot() { + # Be silent on boot, firewall might be started by hotplug already, + # so don't complain in syslog. + QUIET=-q + start +} |