diff options
author | Mohit Mehta <mohit.mehta@vyatta.com> | 2009-01-30 11:11:02 -0800 |
---|---|---|
committer | Mohit Mehta <mohit.mehta@vyatta.com> | 2009-01-30 11:11:02 -0800 |
commit | afa2f490828504606859f503972ef611f342b1f7 (patch) | |
tree | 25da0314bea15d30eadbb207832f7edf1ca06670 | |
parent | 9e1e38ba7c5f536d35aa5ff39d6b8e0583fd9509 (diff) | |
download | vyatta-op-firewall-afa2f490828504606859f503972ef611f342b1f7.tar.gz vyatta-op-firewall-afa2f490828504606859f503972ef611f342b1f7.zip |
clear out counters for all iptable rules that correspond to a CLI rule
-rw-r--r-- | templates/clear/firewall/name/node.tag/rule/node.tag/counters/node.def | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/templates/clear/firewall/name/node.tag/rule/node.tag/counters/node.def b/templates/clear/firewall/name/node.tag/rule/node.tag/counters/node.def index 2171060..c960e9e 100644 --- a/templates/clear/firewall/name/node.tag/rule/node.tag/counters/node.def +++ b/templates/clear/firewall/name/node.tag/rule/node.tag/counters/node.def @@ -7,11 +7,16 @@ run: if [ $result != 0 ]; then echo Invalid firewall name \'$firewall_name\' else - iptables_rule_num=`sudo /sbin/iptables -L $firewall_name -xvn --line-numbers \ - | grep "/\* $firewall_name-$cli_rule_num " | awk '{ print $1 }'` - if [ -n "$iptables_rule_num" ]; then - sudo /sbin/iptables -Z "$firewall_name" "$iptables_rule_num" - else - echo No \'rule $cli_rule_num\' under firewall name \'$firewall_name\' - fi + iptables_rule_num=( `sudo /sbin/iptables -L $firewall_name --line-numbers \ + | grep "/\* $firewall_name-$cli_rule_num " | awk '{ print $1 }'` ) + num_iptables_rules=${#iptables_rule_num[*]} + if [ $num_iptables_rules != 0 ]; then + i=0 + while [ $i -lt $num_iptables_rules ]; do + sudo /sbin/iptables -Z "$firewall_name" "${iptables_rule_num[$i]}" + let i++ + done + else + echo No \'rule $cli_rule_num\' under firewall name \'$firewall_name\' fi + fi |