From e1353f46cf116481322673403cfa7044ed5f0b8f Mon Sep 17 00:00:00 2001 From: fbt Date: Thu, 13 Mar 2014 01:08:12 +0400 Subject: [PATCH] configcheck for iptables --- init.d/iptables | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/init.d/iptables b/init.d/iptables index c3275ca..97e3ce8 100755 --- a/init.d/iptables +++ b/init.d/iptables @@ -7,8 +7,16 @@ cfg_ip6dump='/etc/iptables/ip6.rules' start() { watchman.msg "Restoring netfilter rules..." - [[ -f "$cfg_ip4dump" ]] && { /usr/bin/iptables-restore < "$cfg_ip4dump"; } - [[ -f "$cfg_ip6dump" ]] && { /usr/bin/ip6tables-restore < "$cfg_ip6dump"; } + + [[ -f "$cfg_ip4dump" ]] && { + iptables-restore -t < "$cfg_ip4dump" || return 1 + iptables-restore < "$cfg_ip4dump" + } + + [[ -f "$cfg_ip6dump" ]] && { + ip6tables-restore -t < "$cfg_ip6dump" || return 1 + ip6tables-restore < "$cfg_ip6dump" + } } stop() { @@ -17,13 +25,8 @@ stop() { iptables-save | sed -re 's/(:[A-Z]+\s+)[A-Z]+/\1ACCEPT/g' -e '/-.+/d' | iptables-restore ip6tables-save | sed -re 's/(:[A-Z]+\s+)[A-Z]+/\1ACCEPT/g' -e '/-.+/d' | ip6tables-restore - [[ -f '/proc/net/ip_tables_names' ]] && { - while read line; do iptables -t "$line" -X; done < /proc/net/ip_tables_names - } - - [[ -f '/proc/net/ip6_tables_names' ]] && { - while read line; do iptables -t "$line" -X; done < /proc/net/ip6_tables_names - } + for i in $(iptables-save | grep -E '^\*'); do iptables -t "${i//\*/}" -X; done + for i in $(ip6tables-save | grep -E '^\*'); do ip6tables -t "${i//\*/}" -X; done } save() {