mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-27 19:23:24 +02:00
unbound-dhcp-leases-bridge: Reload on SIGHUP
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
@@ -90,11 +90,8 @@ class UnboundDHCPLeasesBridge(object):
|
|||||||
self.unbound = UnboundConfigWriter(unbound_leases_file)
|
self.unbound = UnboundConfigWriter(unbound_leases_file)
|
||||||
self.running = False
|
self.running = False
|
||||||
|
|
||||||
# Read all static hosts
|
# Load all required data
|
||||||
self.hosts = self.read_static_hosts()
|
self.reload()
|
||||||
|
|
||||||
# Unconditionally update all leases and reload Unbound
|
|
||||||
self.update_dhcp_leases()
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
log.info("Unbound DHCP Leases Bridge started on %s" % self.leases_file)
|
log.info("Unbound DHCP Leases Bridge started on %s" % self.leases_file)
|
||||||
@@ -214,6 +211,13 @@ class UnboundDHCPLeasesBridge(object):
|
|||||||
|
|
||||||
return hosts
|
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):
|
def terminate(self, *args, **kwargs):
|
||||||
# Close the socket
|
# Close the socket
|
||||||
if self.socket:
|
if self.socket:
|
||||||
@@ -610,7 +614,7 @@ if __name__ == "__main__":
|
|||||||
detach_process=args.daemon,
|
detach_process=args.daemon,
|
||||||
stderr=None if args.daemon else sys.stderr,
|
stderr=None if args.daemon else sys.stderr,
|
||||||
signal_map = {
|
signal_map = {
|
||||||
signal.SIGHUP : bridge.update_dhcp_leases,
|
signal.SIGHUP : bridge.reload,
|
||||||
signal.SIGINT : bridge.terminate,
|
signal.SIGINT : bridge.terminate,
|
||||||
signal.SIGTERM : bridge.terminate,
|
signal.SIGTERM : bridge.terminate,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user