Commit 7526194b authored by Franco Fichtner's avatar Franco Fichtner

dnsmasq: reload dhcpleases on reconfigure; closes #1250

Private functions get "_" prefix, easy to spot from elsewhere
if needed.  Yes, someone will try this eventually.  ;)
parent 33c41b16
......@@ -72,6 +72,8 @@ function dnsmasq_configure_do($verbose = false)
"local-ttl" => "--local-ttl=1"
);
_dnsmasq_dhcpleases_stop();
killbypid('/var/run/dnsmasq.pid', 'TERM', true);
if (!dnsmasq_enabled()) {
......@@ -178,23 +180,21 @@ function dnsmasq_configure_do($verbose = false)
}
$args .= ' ' . implode(' ', array_values($standard_args));
_dnsmasq_add_host_entries();
mwexec("/usr/local/sbin/dnsmasq --all-servers {$dns_rebind} {$args}");
_dnsmasq_dhcpleases_start();
if ($verbose) {
echo "done.\n";
}
}
function dnsmasq_hosts_generate()
function _dnsmasq_add_host_entries()
{
global $config;
killbypid('/var/run/dhcpleases.pid', 'TERM', true);
if (!dnsmasq_enabled()) {
return;
}
$dnsmasqcfg = $config['dnsmasq'];
$lhosts = '';
$dhosts = '';
......@@ -268,6 +268,11 @@ function dnsmasq_hosts_generate()
} else {
file_put_contents('/var/etc/dnsmasq-hosts', $lhosts . $dhosts);
}
}
function _dnsmasq_dhcpleases_start()
{
global $config;
$leases = services_dhcpd_leasesfile();
......@@ -281,6 +286,23 @@ function dnsmasq_hosts_generate()
array($leases, $domain, '/var/run/dnsmasq.pid', '/var/etc/dnsmasq-hosts')
);
}
}
function _dnsmasq_dhcpleases_stop()
{
killbypid('/var/run/dhcpleases.pid', 'TERM', true);
}
function dnsmasq_hosts_generate()
{
_dnsmasq_dhcpleases_stop();
if (!dnsmasq_enabled()) {
return;
}
_dnsmasq_add_host_entries();
_dnsmasq_dhcpleases_start();
killbypid('/var/run/dnsmasq.pid', 'HUP');
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment