From: Michael Tremer Date: Fri, 10 May 2024 13:29:31 +0000 (+0100) Subject: unbound-dhcp-leases-bridge: Reload on SIGHUP X-Git-Tag: v2.29-core188~10^2~86^2~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=193638f078a398dc7fa67fef78d63eb2a16fcde8;p=ipfire-2.x.git unbound-dhcp-leases-bridge: Reload on SIGHUP Signed-off-by: Michael Tremer --- diff --git a/config/unbound/unbound-dhcp-leases-bridge b/config/unbound/unbound-dhcp-leases-bridge index 8a6a3d8f8f..f8f64b6549 100644 --- a/config/unbound/unbound-dhcp-leases-bridge +++ b/config/unbound/unbound-dhcp-leases-bridge @@ -90,11 +90,8 @@ class UnboundDHCPLeasesBridge(object): self.unbound = UnboundConfigWriter(unbound_leases_file) self.running = False - # Read all static hosts - self.hosts = self.read_static_hosts() - - # Unconditionally update all leases and reload Unbound - self.update_dhcp_leases() + # Load all required data + self.reload() def run(self): log.info("Unbound DHCP Leases Bridge started on %s" % self.leases_file) @@ -214,6 +211,13 @@ class UnboundDHCPLeasesBridge(object): return hosts + def reload(self, *args, **kwargs): + # Read all static hosts + self.hosts = self.read_static_hosts() + + # Unconditionally update all leases and reload Unbound + self.update_dhcp_leases() + def terminate(self, *args, **kwargs): # Close the socket if self.socket: @@ -610,7 +614,7 @@ if __name__ == "__main__": detach_process=args.daemon, stderr=None if args.daemon else sys.stderr, signal_map = { - signal.SIGHUP : bridge.update_dhcp_leases, + signal.SIGHUP : bridge.reload, signal.SIGINT : bridge.terminate, signal.SIGTERM : bridge.terminate, },