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