From: Michael Tremer Date: Fri, 11 Feb 2022 17:14:02 +0000 (+0000) Subject: export: Make ipset files easily reloadable X-Git-Tag: 0.9.10~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1b759b42aad7493e32a058d4f7645dff966b8633;p=people%2Fms%2Flibloc.git export: Make ipset files easily reloadable This change allows to "restore" a file multiple times without problems. If the set already exists, the create command will skip it and we will flush any existing content to load the new one. Signed-off-by: Stefan Schantl Signed-off-by: Michael Tremer --- diff --git a/src/python/export.py b/src/python/export.py index 3b9e1e0..a9774e8 100644 --- a/src/python/export.py +++ b/src/python/export.py @@ -90,7 +90,8 @@ class IpsetOutputWriter(OutputWriter): suffix = "ipset" def _write_header(self): - self.f.write("create %s hash:net family inet hashsize 1024 maxelem 65536\n" % self.prefix) + self.f.write("create %s hash:net family inet hashsize 1024 maxelem 65536 -exist\n" % self.prefix) + self.f.write("flush %s\n" % self.prefix) def write(self, network): self.f.write("add %s %s\n" % (self.prefix, network))