dhcp: reload action for cron; closes #5410

Change the structure a little to support reloading either all
dhcp-related services or only a certain address family through
optional parameter: "inet" for IPv4 and "inet6" for IPv6.

The issue with the original proposal was that although dhcpd6
was restarted we also need to restart radvd since it is affected
by the same bug #4691 and still seems to be happening in the wild
in FreeBSD 13.

While here expand to full path of pluginctl in an unrelated file.
This commit is contained in:
Franco Fichtner 2022-04-07 16:22:38 +02:00
parent 8ea40560df
commit 80ba04f721
3 changed files with 14 additions and 7 deletions

View File

@ -575,7 +575,7 @@ function dhcpd_radvd_configure($verbose = false, $blacklist = array())
}
}
function dhcpd_dhcp_configure($verbose = false, $family = 'all', $blacklist = array())
function dhcpd_dhcp_configure($verbose = false, $family = null, $blacklist = [])
{
$dirs = array('/dev', '/etc', '/lib', '/run', '/usr', '/usr/local/sbin', '/var/db', '/var/run');
@ -589,11 +589,11 @@ function dhcpd_dhcp_configure($verbose = false, $family = 'all', $blacklist = ar
mwexecf('/usr/sbin/chown -R dhcpd:dhcpd %s', '/var/dhcpd');
if ($family == 'all' || $family == 'inet') {
if ($family == null || $family == 'inet') {
dhcpd_dhcp4_configure($verbose);
}
if ($family == 'all' || $family == 'inet6') {
if ($family == null || $family == 'inet6') {
dhcpd_dhcp6_configure($verbose, $blacklist);
dhcpd_radvd_configure($verbose, $blacklist);
}
@ -1682,13 +1682,13 @@ EOD;
}
}
function dhcpd_dhcrelay_configure($verbose = false, $family = 'all')
function dhcpd_dhcrelay_configure($verbose = false, $family = null)
{
if ($family == 'all' || $family == 'inet') {
if ($family == null || $family == 'inet') {
dhcpd_dhcrelay4_configure($verbose);
}
if ($family == 'all' || $family == 'inet6') {
if ($family == null || $family == 'inet6') {
dhcpd_dhcrelay6_configure($verbose);
}
}

View File

@ -1,5 +1,5 @@
[restart]
command:pluginctl -s cron restart
command:/usr/local/sbin/pluginctl -s cron restart
parameters:
type:script
message:restarting cron

View File

@ -9,3 +9,10 @@ command:/usr/local/opnsense/scripts/dhcp/prefixes.php
parameters:
type:script
message:update IPv6 prefixes
[restart]
command:/usr/local/sbin/pluginctl dhcp
parameters:%s
type:script
message:restarting %s dhcpd
description:Restart DHCPd