From 9a4ceabb01eca7ad9726ea1168210c0e85185267 Mon Sep 17 00:00:00 2001
From: Pawel Krawczyk
Date: Wed, 31 Dec 2014 17:34:16 +0000
Subject: [PATCH] only create set if it does not exist
---
blacklist.sh | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/blacklist.sh b/blacklist.sh
index 636e863..a56bd29 100644
--- a/blacklist.sh
+++ b/blacklist.sh
@@ -66,8 +66,11 @@ for url in $urls; do
new_list_size=$(wc -l "${sorted_blocklist}" | awk '{print $1;}' )
hash_size=$(expr $new_list_size / 2)
+ if ! ipset -q list ${set_name} >/dev/null ; then
+ ipset create ${set_name} hash:net family inet
+ fi
+
# start writing new set file
- echo "create ${set_name} hash:net family inet" >>"${new_set_file}"
echo "create ${tmp_set_name} hash:net family inet hashsize ${hash_size} maxelem ${new_list_size}" >>"${new_set_file}"
# convert list of IPs to ipset statements