Commit 4a7ff245 authored by Franco Fichtner's avatar Franco Fichtner

unbound: simply reload on /etc/hosts change

parent c8236eec
......@@ -416,9 +416,7 @@ EOF;
file_put_contents("{$g['unbound_chroot_path']}/remotecontrol.conf", $remotcfg);
// Generate our keys
unbound_execute("unbound-control-setup");
unbound_execute('unbound-control-setup');
}
}
......@@ -426,7 +424,7 @@ function unbound_configure_do($verbose = false)
{
global $config;
killbypid('/var/run/unbound.pid', 'TERM', true);
unbound_execute('stop');
if (!isset($config['unbound']['enable'])) {
return;
......@@ -448,7 +446,6 @@ function unbound_configure_do($verbose = false)
}
}
// Execute commands as the user unbound
function unbound_execute($cmd)
{
global $g, $config;
......@@ -456,16 +453,19 @@ function unbound_execute($cmd)
switch ($cmd) {
case 'start':
$local_domain = !empty($config['system']['domain']) ? $config['system']['domain'] : "local";
killbypid('/var/run/unbound_dhcpd.pid');
killbypid('/var/run/unbound_dhcpd.pid', 'TERM', true);
if (isset($config['unbound']['regdhcp'])) {
mwexec('/usr/local/opnsense/scripts/dns/unbound_dhcpd.py /domain "'.$local_domain.'"');
}
mwexec("/usr/local/sbin/unbound -c {$g['unbound_chroot_path']}/unbound.conf");
break;
case 'stop':
killbypid('/var/run/unbound_dhcpd.pid');
killbypid('/var/run/unbound_dhcpd.pid', 'TERM', true);
mwexec("chroot -u unbound -g unbound / /usr/local/sbin/unbound-control stop", true);
break;
case 'reload':
killbypid('/var/run/unbound.pid', 'HUP');
break;
case 'unbound-anchor':
mwexec("chroot -u unbound -g unbound / /usr/local/sbin/unbound-anchor -a {$g['unbound_chroot_path']}/root.key", true);
break;
......@@ -648,36 +648,9 @@ function unbound_add_host_entries()
file_put_contents("{$g['unbound_chroot_path']}/host_entries.conf", $unbound_entries);
}
function unbound_control($action)
{
global $config, $g;
switch ($action) {
case "start":
// Start Unbound
if ($config['unbound']['enable'] == "on") {
if (!is_process_running("unbound")) {
unbound_execute("start");
}
}
break;
case "stop":
if ($config['unbound']['enable'] == "on") {
unbound_execute("stop");
}
break;
case "reload":
if ($config['unbound']['enable'] == "on") {
unbound_execute("reload");
}
break;
default:
break;
}
}
// Generation of Unbound statistics
function unbound_statistics() {
function unbound_statistics()
{
global $config;
if ($config['stats'] == "on") {
......@@ -765,6 +738,5 @@ function unbound_hosts_generate()
}
unbound_add_host_entries();
/* XXX this doesn't exist! */
unbound_control("reload");
unbound_execute('reload');
}
......@@ -111,13 +111,6 @@ function reconfigure_dhcpd()
system_hosts_generate();
clear_subsystem_dirty('hosts');
services_dhcpleases_configure();
if (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcpstatic'])) {
/* XXX we're calling unbound for regdhcpstatic, but restart the whole thing? */
unbound_configure_do();
clear_subsystem_dirty('unbound');
}
services_dhcpd_configure();
clear_subsystem_dirty('staticmaps');
}
......@@ -516,13 +509,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (!empty($config['dhcpd'][$if]['staticmap'][$_POST['id']])) {
unset($config['dhcpd'][$if]['staticmap'][$_POST['id']]);
write_config();
if(isset($config['dhcpd'][$if]['enable'])) {
if (isset($config['dhcpd'][$if]['enable'])) {
mark_subsystem_dirty('staticmaps');
if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic'])) {
mark_subsystem_dirty('hosts');
} elseif (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcpstatic'])) {
mark_subsystem_dirty('unbound');
}
mark_subsystem_dirty('hosts');
}
}
header(url_safe('Location: /services_dhcp.php?if=%s', array($if)));
......
......@@ -287,11 +287,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
write_config();
if (isset($config['dhcpd'][$if]['enable'])) {
mark_subsystem_dirty('staticmaps');
if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic']))
mark_subsystem_dirty('staticmaps');
mark_subsystem_dirty('hosts');
if (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcpstatic']))
mark_subsystem_dirty('unbound');
}
header(url_safe('Location: /services_dhcp.php?if=%s', array($if)));
......
......@@ -41,13 +41,6 @@ function reconfigure_dhcpd()
{
system_hosts_generate();
clear_subsystem_dirty('hosts');
if (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcpstatic'])) {
/* XXX we're calling unbound for regdhcpstatic, but restart the whole thing? */
unbound_configure_do();
clear_subsystem_dirty('unbound');
}
services_dhcpd_configure();
clear_subsystem_dirty('staticmaps');
}
......@@ -327,9 +320,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
write_config();
if (isset($config['dhcpdv6'][$if]['enable'])) {
mark_subsystem_dirty('staticmapsv6');
if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic'])) {
mark_subsystem_dirty('hosts');
}
mark_subsystem_dirty('hosts');
}
}
exit;
......
......@@ -136,12 +136,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (isset($config['dhcpdv6'][$if]['enable'])) {
mark_subsystem_dirty('staticmaps');
if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic'])) {
mark_subsystem_dirty('hosts');
}
if (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcpstatic'])) {
mark_subsystem_dirty('unbound');
}
mark_subsystem_dirty('hosts');
}
header(url_safe('Location: /services_dhcpv6.php?if=%s', array($if)));
......
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