]> git.ipfire.org Git - thirdparty/suricata-update.git/commitdiff
remove sources that an enabled one replaces 13/head
authorJason Ish <ish@unx.ca>
Mon, 4 Dec 2017 20:01:29 +0000 (14:01 -0600)
committerJason Ish <ish@unx.ca>
Mon, 4 Dec 2017 20:01:29 +0000 (14:01 -0600)
For example, when enabling et/pro, if et/open is enabled,
remove it, as its replaced by et/pro

suricata/update/commands/enablesource.py

index 316494493d911253d1acb8114b918578f90ad2cd..aa1113cfc3aa3a8446011eb42c52d53ff63b6a1f 100644 (file)
@@ -119,6 +119,16 @@ def enable_source(config):
     write_source_config(new_source, True)
     logger.info("Source %s enabled", new_source.name)
 
+    if "replaces" in source:
+        for replaces in source["replaces"]:
+            filename = sources.get_enabled_source_filename(replaces)
+            if os.path.exists(filename):
+                logger.info(
+                    "Removing source %s as its replaced by %s", replaces,
+                    new_source.name)
+                logger.debug("Deleting %s", filename)
+                os.unlink(filename)
+
 def write_source_config(config, enabled):
     if enabled:
         filename = sources.get_enabled_source_filename(config.name)