From 32c68874c5f3b82aa968f27c05e4f0462de73d57 Mon Sep 17 00:00:00 2001 From: alento-group <42585319+alento-group@users.noreply.github.com> Date: Sun, 30 Oct 2022 13:16:03 +0100 Subject: [PATCH] Fix NSD not restarting (#2182) A previous commit (0a970f4bb2dba052ce1c321dd8b4e9f016a56550) broke nsd restarting. This fixes that change by reverting it. Josh added: Use nsd-control with reconfig and reload if they succeed and only fall back to restarting nsd if they fail Co-authored-by: Joshua Tauberer --- management/dns_update.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/management/dns_update.py b/management/dns_update.py index 1567371a..2bfc104f 100755 --- a/management/dns_update.py +++ b/management/dns_update.py @@ -98,7 +98,16 @@ def do_dns_update(env, force=False): # Tell nsd to reload changed zone files. if len(updated_domains) > 0: - shell('check_call', ["/usr/sbin/nsd-control", "reload"]) + # 'reconfig' is needed if there are added or removed zones, but + # it may not reload existing zones, so we call 'reload' too. If + # nsd isn't running, nsd-control fails, so in that case revert + # to restarting nsd to make sure it is running. Restarting nsd + # should also refresh everything. + try: + shell('check_call', ["/usr/sbin/nsd-control", "reconfig"]) + shell('check_call', ["/usr/sbin/nsd-control", "reload"]) + except: + shell('check_call', ["/usr/sbin/service", "nsd", "restart"]) # Write the OpenDKIM configuration tables for all of the mail domains. from mailconfig import get_mail_domains