Commits (4)
config.ini
serial.json
**/__pycache__/**
**.zone
**.reverse
......@@ -48,7 +48,7 @@ template_sshfp = "{hostname} SSHFP {algo} {type} {fp}"
template_ds = "{subzone} {ttl} IN DS {id} {algo} {type} {fp}"
template_zone = (
"$TTL 2D\n"
"$TTL 3600\n"
"{soa}\n"
"\n"
"{originv4}\n"
......@@ -76,7 +76,7 @@ template_zone = (
)
template_reverse = (
"$TTL 2D\n"
"$TTL 3600\n"
"{soa}\n"
"\n"
"{ns_records}\n"
......@@ -97,6 +97,9 @@ zone_names = []
def write_dns_file(zone, verbose=False):
global serial
if verbose:
print("serial = {}".format(serial))
zone_name = zone['name'][1:]
now = datetime.datetime.now(datetime.timezone.utc)
......@@ -164,7 +167,7 @@ def write_dns_file(zone, verbose=False):
txt_records = "\n".join(
template_txt.format(
field1=x['field1'],
field2=x['field2']
field2=x['field2'].replace("\r", "")
)
for x in zone['txt_records']
)
......@@ -218,10 +221,11 @@ def write_dns_file(zone, verbose=False):
)
if zone['name'][1:] == "crans.org":
ds_records = ""
for extension in filter(lambda zone: zone.endswith('.crans.org'), zone_names):
for ds in knot.get_ds(extension, verbose):
ds_records += template_ds.format(**ds) + "\n"
# ds_records = ""
# for extension in filter(lambda zone: zone.endswith('.crans.org'), zone_names):
# for ds in knot.get_ds(extension, verbose):
# ds_records += template_ds.format(**ds) + "\n"
ds_records = "\n"
else:
ds_records = "\n"
......@@ -453,7 +457,7 @@ if __name__ == '__main__':
json.dump(serial + 1, serial_json)
if not args.no_reload:
error = os.system('/usr/sbin/knotc zone-reload >/dev/null 2>&1')
error = os.system('/usr/sbin/rndc reload >/dev/null 2>&1')
if error:
# reload again and display the error message
os.system('/usr/sbin/knotc zone-reload')
os.system('/usr/sbin/rndc reload')