dhcp_host_domain_ng.py ignores dhcp.@dnsmasq[0].leasefile setting
When I change dhcp.@dnsmasq[0].leasefile
to point to /srv/dhcp.leases
to get a persistent database, script dhcp_host_domain_ng.py
still expects the default /tmp/dhcp.leases
file.
This can be fixed by the following change to the end of the file (I could not fork the project, so I'm sending the fix here):
if __name__ == "__main__":
leases = uci_get("dhcp.@dnsmasq[0].leasefile")
if len(sys.argv) == 2 and sys.argv[1] == "ipv6":
log("DHCPv6 leases not supported now", LOG_WARNING)
elif len(sys.argv) > 4:
log("DHCPv4 new lease", LOG_INFO)
sys_op = sys.argv[1]
mac = sys.argv[2]
ipv4 = sys.argv[3]
hostname = sys.argv[4]
dd = DHCPv4(leases)
dd.update_dhcp(sys_op, hostname, ipv4)
dd.save_leases()
dd.refresh_resolver()
else:
# get env variables in case of
# call from dnsmasq dhcp-script.sh
sys_op = os.environ.get('ACTION')
mac = os.environ.get('MACADDR')
ipv4 = os.environ.get('IPADDR')
hostname = os.environ.get('HOSTNAME')
dd = DHCPv4(leases)
if sys_op and hostname and ipv4:
dd.update_dhcp(sys_op, hostname, ipv4)
dd.save_leases()
dd.refresh_resolver()