summaryrefslogtreecommitdiffstats
path: root/debian/get_kaspdb
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 10:36:23 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 10:36:23 +0000
commit3050ea58ec5f7f1d5a3d70a080a9cb9dceadda38 (patch)
treeb57c014754c37f359e87a796a2bc2859572b6612 /debian/get_kaspdb
parentAdding upstream version 3.0.5. (diff)
downloadknot-debian/3.0.5-1+deb11u1.tar.xz
knot-debian/3.0.5-1+deb11u1.zip
Adding debian version 3.0.5-1+deb11u1.debian/3.0.5-1+deb11u1debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-xdebian/get_kaspdb59
1 files changed, 59 insertions, 0 deletions
diff --git a/debian/get_kaspdb b/debian/get_kaspdb
new file mode 100755
index 0000000..088c2d1
--- /dev/null
+++ b/debian/get_kaspdb
@@ -0,0 +1,59 @@
+#!/usr/bin/python3
+
+import yaml, os.path, sys
+
+conf_file = '/etc/knot/knot.conf' if len(sys.argv) < 2 else sys.argv[1]
+ip_fields = ['listen', 'address', 'via', 'whitelist', 'network']
+
+try:
+ conf = yaml.load(open(conf_file, 'r'), Loader=yaml.FullLoader)
+except (yaml.scanner.ScannerError, yaml.parser.ParserError):
+ conf = False
+
+if not conf:
+ import io
+ conf_io = io.StringIO()
+ with open(conf_file) as f:
+ for line in f:
+ if line.split(':')[0].strip() not in ip_fields:
+ conf_io.write(line)
+ conf_io.seek(0)
+ try:
+ conf = yaml.load(conf_io, Loader=yaml.FullLoader)
+ except (yaml.scanner.ScannerError, yaml.parser.ParserError):
+ sys.exit(1)
+
+dirs = set()
+# if we have valid yaml use it
+if "template" in conf and conf["template"]:
+
+ for template in conf["template"]:
+ if "kasp-db" in template:
+ kasp_db = template["kasp-db"]
+ else:
+ continue
+
+ if not os.path.isabs(kasp_db):
+ if "storage" in template:
+ kasp_db = os.path.join(template["storage"], kasp_db)
+ else:
+ continue
+ dirs.add(kasp_db)
+
+if "zone" in conf and conf["zone"]:
+
+ for domain in conf["zone"]:
+ if "kasp-db" in domain:
+ kasp_db = domain["kasp-db"]
+ else:
+ continue
+
+ if not os.path.isabs(kasp_db):
+ if "storage" in kaspdomain:
+ kasp_db = os.path.join(domain["storage"], kasp_db)
+ else:
+ continue
+ dirs.add(kasp_db)
+
+for dir in dirs:
+ print(dir)