Commit 5fa2d2dc authored by Franco Fichtner's avatar Franco Fichtner

services: dns servers restart alignment

So that DHCP isn't restarted up to three times...
parent d090ccc3
......@@ -95,8 +95,8 @@ function convert_128bit_to_ipv6($ip6bin)
function match_wireless_interface($int)
{
$wireless_regex = '/^(ndis|wi|ath|an|ral|ural|iwi|wlan|rum|run|bwn|zyd|mwl|bwi|ipw|iwn|malo|uath|upgt|urtw|wpi)/';
return preg_match($wireless_regex, $int);
$wireless_regex = '/^(ndis|wi|ath|an|ral|ural|iwi|wlan|rum|run|bwn|zyd|mwl|bwi|ipw|iwn|malo|uath|upgt|urtw|wpi)/';
return preg_match($wireless_regex, $int);
}
function interfaces_bring_up($interface)
......@@ -153,9 +153,9 @@ function interface_netgraph_needed($interface)
case 'pppoe':
case 'l2tp':
case 'pptp':
return true;
return true;
default:
break;
break;
}
}
......@@ -1138,15 +1138,12 @@ function interfaces_configure()
/* reload IPsec tunnels */
ipsec_configure();
/* restart dns servers (defering dhcp restart) */
services_dnsmasq_configure(false);
services_unbound_configure(false);
/* reload dhcpd (interface enabled/disabled status may have changed) */
services_dhcpd_configure();
/* restart dnsmasq or unbound */
if (isset($config['dnsmasq']['enable'])) {
services_dnsmasq_configure();
} elseif (isset($config['unbound']['enable'])) {
services_unbound_configure();
}
}
return 0;
......@@ -2952,7 +2949,7 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
array_walk($grouptmp, 'interface_group_add_member');
}
if ($interface == "lan") {
if ($interface == 'lan') {
/* make new hosts file */
system_hosts_generate();
}
......@@ -2964,12 +2961,12 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
/* reload ipsec tunnels */
ipsec_configure();
/* restart dnsmasq or unbound */
if (isset($config['dnsmasq']['enable'])) {
services_dnsmasq_configure();
} elseif (isset($config['unbound']['enable'])) {
services_unbound_configure();
}
/* restart dns servers (defering dhcp restart) */
services_dnsmasq_configure(false);
services_unbound_configure(false);
/* reload dhcpd (interface enabled/disabled status may have changed) */
services_dhcpd_configure();
/* update dyndns */
configd_run("dyndns reload {$interface}");
......@@ -2977,6 +2974,7 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
}
interfaces_staticarp_configure($interface);
return 0;
}
......
......@@ -1829,7 +1829,7 @@ function dyndnsCheckIP($int)
return $ip_address;
}
function services_dnsmasq_configure()
function services_dnsmasq_configure($dhcp_reload = true)
{
global $config;
......@@ -1840,14 +1840,11 @@ function services_dnsmasq_configure()
"local-ttl" => "--local-ttl=1"
);
/* kill any running dnsmasq */
killbypid('/var/run/dnsmasq.pid');
killbypid('/var/run/dnsmasq.pid', 'TERM', true);
if (isset($config['dnsmasq']['enable'])) {
if (file_exists("/var/run/booting")) {
echo gettext("Starting DNS forwarder...");
} else {
sleep(1);
}
$args = "";
......@@ -1977,44 +1974,41 @@ function services_dnsmasq_configure()
}
}
if (!file_exists("/var/run/booting")) {
if (services_dhcpd_configure()!=0) {
return 1;
}
/*
* XXX this is overly convoluted, potentiall
* restarting all of dhcp up to three times ;)
*/
if (!file_exists("/var/run/booting") && $dhcp_reload) {
services_dhcpd_configure();
}
return 0;
}
function services_unbound_configure()
function services_unbound_configure($dhcp_reload = true)
{
global $config;
$return = 0;
// kill any running Unbound instance
killbypid('/var/run/unbound.pid');
killbypid('/var/run/unbound.pid', 'TERM', true);
if (isset($config['unbound']['enable'])) {
if (file_exists("/var/run/booting")) {
echo gettext("Starting DNS Resolver...");
} else {
sleep(1);
}
sync_unbound_service();
system_dhcpleases_configure();
if (file_exists("/var/run/booting")) {
echo gettext("done.") . "\n";
}
}
if (!file_exists("/var/run/booting")) {
if (services_dhcpd_configure()!=0) {
$return = 1;
}
/*
* XXX this is overly convoluted, potentially
* restarting all of dhcp up to three times ;)
*/
if (!file_exists("/var/run/booting") && $dhcp_reload) {
services_dhcpd_configure();
}
return $return;
}
function services_snmpd_configure()
......
......@@ -42,25 +42,18 @@ require_once("services.inc");
*/
function reconfigure_dhcpd()
{
/* services_dnsmasq_configure calls services_dhcpd_configure */
if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic'])) {
$retvaldns = services_dnsmasq_configure();
if ($retvaldns == 0) {
clear_subsystem_dirty('hosts');
clear_subsystem_dirty('staticmaps');
}
/* services_unbound_configure calls services_dhcpd_configure */
} elseif (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcpstatic'])) {
$retvaldns = services_unbound_configure();
if ($retvaldns == 0) {
clear_subsystem_dirty('unbound');
}
} else {
$retvaldhcp = services_dhcpd_configure();
if ($retvaldhcp == 0) {
clear_subsystem_dirty('staticmaps');
}
services_dnsmasq_configure(false);
clear_subsystem_dirty('hosts');
}
if (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcpstatic'])) {
services_unbound_configure(false);
clear_subsystem_dirty('unbound');
}
services_dhcpd_configure();
clear_subsystem_dirty('staticmaps');
}
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
......
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