mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 16:14:40 +00:00
dnsmasq: refactor services_dhcpleases_configure() for #1266
This commit is contained in:
parent
8b61365fa6
commit
a5fc46bd97
@ -2879,7 +2879,6 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
|
||||
if ($interface == 'lan') {
|
||||
/* make new hosts file */
|
||||
system_hosts_generate();
|
||||
services_dhcpleases_configure();
|
||||
}
|
||||
|
||||
if ($reloadall == true) {
|
||||
|
||||
@ -270,3 +270,30 @@ function dnsmasq_hosts_generate()
|
||||
|
||||
return $lhosts . $dhosts;
|
||||
}
|
||||
|
||||
function dnsmasq_dhcpleases_stop()
|
||||
{
|
||||
killbypid('/var/run/dhcpleases.pid', 'TERM', true);
|
||||
}
|
||||
|
||||
function dnsmasq_dhcpleases_start()
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (!isset($config['dnsmasq']['enable']) || !isset($config['dnsmasq']['regdhcp'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$leases = services_dhcpd_leasesfile();
|
||||
if (!file_exists($leases)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* we can let the user choose a domain, but it can be only one */
|
||||
$domain = $config['system']['domain'];
|
||||
|
||||
mwexecf(
|
||||
'/usr/local/sbin/dhcpleases -l %s -d %s -p %s -h %s',
|
||||
array($leases, $domain, '/var/run/dnsmasq.pid', '/etc/hosts')
|
||||
);
|
||||
}
|
||||
|
||||
@ -314,31 +314,6 @@ function services_dhcpdv6_leasesfile()
|
||||
return "{$g['dhcpd_chroot_path']}/var/db/dhcpd6.leases";
|
||||
}
|
||||
|
||||
function services_dhcpleases_configure()
|
||||
{
|
||||
global $config, $g;
|
||||
|
||||
killbypid('/var/run/dhcpleases.pid', 'TERM', true);
|
||||
|
||||
if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcp'])) {
|
||||
mwexec("/bin/mkdir -p {$g['dhcpd_chroot_path']}/var/db");
|
||||
touch("{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases");
|
||||
if (isvalidpid('/var/run/dhcpleases.pid')) {
|
||||
killbypid('/var/run/dhcpleases.pid', 'HUP');
|
||||
} else {
|
||||
mwexecf(
|
||||
'/usr/local/sbin/dhcpleases -l %s -d %s -p %s -h %s',
|
||||
array(
|
||||
"{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases",
|
||||
$config['system']['domain'],
|
||||
'/var/run/dnsmasq.pid',
|
||||
'/etc/hosts'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function services_dhcpd_configure($family = 'all', $blacklist = array(), $verbose = false)
|
||||
{
|
||||
global $g;
|
||||
|
||||
@ -384,9 +384,9 @@ function system_hosts_generate()
|
||||
* Do not remove this because dhcpleases monitors with kqueue
|
||||
* it needs to be killed before writing to hosts files.
|
||||
*/
|
||||
killbypid('/var/run/dhcpleases.pid', 'TERM', true);
|
||||
|
||||
dnsmasq_dhcpleases_stop();
|
||||
file_put_contents('/etc/hosts', $hosts);
|
||||
dnsmasq_dhcpleases_start();
|
||||
}
|
||||
|
||||
function system_hostname_configure()
|
||||
@ -396,10 +396,9 @@ function system_hostname_configure()
|
||||
$syscfg = $config['system'];
|
||||
|
||||
/* set hostname */
|
||||
$status = mwexec("/bin/hostname " .
|
||||
escapeshellarg("{$syscfg['hostname']}.{$syscfg['domain']}"));
|
||||
$status = mwexecf('/bin/hostname %s', "{$syscfg['hostname']}.{$syscfg['domain']}");
|
||||
|
||||
/* Setup host GUID ID. This is used by ZFS. */
|
||||
/* Setup host GUID ID. This is used by ZFS. */
|
||||
mwexec("/etc/rc.d/hostid start");
|
||||
|
||||
return $status;
|
||||
|
||||
@ -135,7 +135,6 @@ function filter_configure_xmlrpc()
|
||||
system_routing_configure();
|
||||
setup_gateways_monitor();
|
||||
system_hosts_generate();
|
||||
services_dhcpleases_configure();
|
||||
local_sync_accounts();
|
||||
dnsmasq_configure_do();
|
||||
unbound_configure_do();
|
||||
|
||||
@ -140,9 +140,6 @@ openvpn_prepare_all();
|
||||
interfaces_configure();
|
||||
unmute_kernel_msgs();
|
||||
|
||||
/* re-make hosts file after configuring interfaces */
|
||||
system_hosts_generate();
|
||||
|
||||
/* start OpenVPN server & clients */
|
||||
echo "Syncing OpenVPN settings...";
|
||||
openvpn_resync_all();
|
||||
@ -180,7 +177,7 @@ system_routing_enable();
|
||||
dnsmasq_configure_do(true);
|
||||
unbound_configure_do(true);
|
||||
services_dhcpd_configure('all', array(), true);
|
||||
services_dhcpleases_configure();
|
||||
system_hosts_generate();
|
||||
services_dhcrelay_configure(true);
|
||||
services_dhcrelay6_configure(true);
|
||||
|
||||
|
||||
@ -139,7 +139,6 @@ if (!empty($bridgetmp)) {
|
||||
|
||||
/* make new hosts file */
|
||||
system_hosts_generate();
|
||||
services_dhcpleases_configure();
|
||||
|
||||
/* check tunneled IPv6 interface tracking */
|
||||
if (isset($config['interfaces'][$interface]['ipaddrv6'])) {
|
||||
|
||||
@ -48,7 +48,6 @@ system_login_configure();
|
||||
system_timezone_configure();
|
||||
system_hostname_configure();
|
||||
system_hosts_generate();
|
||||
services_dhcpleases_configure();
|
||||
system_resolvconf_generate();
|
||||
system_routing_enable();
|
||||
interfaces_configure();
|
||||
|
||||
@ -110,7 +110,6 @@ function reconfigure_dhcpd()
|
||||
dhcp_clean_leases();
|
||||
system_hosts_generate();
|
||||
clear_subsystem_dirty('hosts');
|
||||
services_dhcpleases_configure();
|
||||
services_dhcpd_configure();
|
||||
clear_subsystem_dirty('staticmaps');
|
||||
}
|
||||
|
||||
@ -118,7 +118,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
/* Update resolv.conf in case the interface bindings exclude localhost. */
|
||||
system_resolvconf_generate();
|
||||
system_hosts_generate();
|
||||
services_dhcpleases_configure();
|
||||
dnsmasq_configure_do();
|
||||
services_dhcpd_configure();
|
||||
clear_subsystem_dirty('hosts');
|
||||
|
||||
@ -251,7 +251,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
|
||||
system_login_configure();
|
||||
system_hosts_generate();
|
||||
services_dhcpleases_configure();
|
||||
dnsmasq_configure_do();
|
||||
unbound_configure_do();
|
||||
services_dhcpd_configure();
|
||||
|
||||
@ -224,7 +224,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
prefer_ipv4_or_ipv6();
|
||||
system_hostname_configure();
|
||||
system_hosts_generate();
|
||||
services_dhcpleases_configure();
|
||||
system_resolvconf_generate();
|
||||
dnsmasq_configure_do();
|
||||
unbound_configure_do();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user