uniq cidrs
authorJustin Wind <justin.wind+git@gmail.com>
Thu, 20 Apr 2017 16:59:48 +0000 (09:59 -0700)
committerJustin Wind <justin.wind+git@gmail.com>
Thu, 20 Apr 2017 16:59:48 +0000 (09:59 -0700)
common.sh

index c4da5fdfa43c8e41ed6e5abf9c9cdc54a665c19e..5c2ed1a56e052dc5b53a08e20dfeb4e4099e49d0 100644 (file)
--- 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
 }