From: Justin Wind <justin.wind+git@gmail.com>
Date: Thu, 20 Apr 2017 16:59:48 +0000 (-0700)
Subject: uniq cidrs
X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=bcdd193ba6483f09284ccc79a76db3d95f709e83;p=firewall-squeep

uniq cidrs
---

diff --git a/common.sh b/common.sh
index c4da5fd..5c2ed1a 100644
--- a/common.sh
+++ b/common.sh
@@ -92,7 +92,7 @@ function ipset_restore_from_cidr(){
 		# extract existing set configuration to create temporary set
 		(set -o pipefail; $IPSET save "${set_name}${v}" 2>/dev/null | grep -m 1 '^create ' | sed "s/\(create ${set_name}${v}\)/\1-tmp/") || continue
 		# populate with new data
-		decommentcat "${set_name}.cidr" "${set_name}.cidr.$(hostname -s)" 2>/dev/null | sed -n 's/\(.*'"${vmatch}"'.*\)/add '"${set_name}${v}-tmp"' \1/p'
+		decommentcat "${set_name}.cidr" "${set_name}.cidr.$(hostname -s)" 2>/dev/null | sed -n 's/\(.*'"${vmatch}"'.*\)/add '"${set_name}${v}-tmp"' \1/p' | sort -n | uniq
 	done
 }