Commit 1b759b42 authored by Michael Tremer's avatar Michael Tremer

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: default avatarStefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: default avatarMichael Tremer <michael.tremer@ipfire.org>
parent 38d0faea
......@@ -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))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment