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) ...@@ -72,6 +72,8 @@ function dnsmasq_configure_do($verbose = false)
"local-ttl" => "--local-ttl=1" "local-ttl" => "--local-ttl=1"
); );
_dnsmasq_dhcpleases_stop();
killbypid('/var/run/dnsmasq.pid', 'TERM', true); killbypid('/var/run/dnsmasq.pid', 'TERM', true);
if (!dnsmasq_enabled()) { if (!dnsmasq_enabled()) {
...@@ -178,23 +180,21 @@ function dnsmasq_configure_do($verbose = false) ...@@ -178,23 +180,21 @@ function dnsmasq_configure_do($verbose = false)
} }
$args .= ' ' . implode(' ', array_values($standard_args)); $args .= ' ' . implode(' ', array_values($standard_args));
_dnsmasq_add_host_entries();
mwexec("/usr/local/sbin/dnsmasq --all-servers {$dns_rebind} {$args}"); mwexec("/usr/local/sbin/dnsmasq --all-servers {$dns_rebind} {$args}");
_dnsmasq_dhcpleases_start();
if ($verbose) { if ($verbose) {
echo "done.\n"; echo "done.\n";
} }
} }
function dnsmasq_hosts_generate() function _dnsmasq_add_host_entries()
{ {
global $config; global $config;
killbypid('/var/run/dhcpleases.pid', 'TERM', true);
if (!dnsmasq_enabled()) {
return;
}
$dnsmasqcfg = $config['dnsmasq']; $dnsmasqcfg = $config['dnsmasq'];
$lhosts = ''; $lhosts = '';
$dhosts = ''; $dhosts = '';
...@@ -268,6 +268,11 @@ function dnsmasq_hosts_generate() ...@@ -268,6 +268,11 @@ function dnsmasq_hosts_generate()
} else { } else {
file_put_contents('/var/etc/dnsmasq-hosts', $lhosts . $dhosts); file_put_contents('/var/etc/dnsmasq-hosts', $lhosts . $dhosts);
} }
}
function _dnsmasq_dhcpleases_start()
{
global $config;
$leases = services_dhcpd_leasesfile(); $leases = services_dhcpd_leasesfile();
...@@ -281,6 +286,23 @@ function dnsmasq_hosts_generate() ...@@ -281,6 +286,23 @@ function dnsmasq_hosts_generate()
array($leases, $domain, '/var/run/dnsmasq.pid', '/var/etc/dnsmasq-hosts') 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'); 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