From 80ba04f7216d433f6ddd397db603f63cb0479170 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Thu, 7 Apr 2022 16:22:38 +0200 Subject: [PATCH] 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. --- src/etc/inc/plugins.inc.d/dhcpd.inc | 12 ++++++------ .../service/conf/actions.d/actions_cron.conf | 2 +- .../service/conf/actions.d/actions_dhcpd.conf | 7 +++++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/etc/inc/plugins.inc.d/dhcpd.inc b/src/etc/inc/plugins.inc.d/dhcpd.inc index 10d1e5fd0..f243b5527 100644 --- a/src/etc/inc/plugins.inc.d/dhcpd.inc +++ b/src/etc/inc/plugins.inc.d/dhcpd.inc @@ -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); } } diff --git a/src/opnsense/service/conf/actions.d/actions_cron.conf b/src/opnsense/service/conf/actions.d/actions_cron.conf index 04f60e6bb..2bee04a8e 100644 --- a/src/opnsense/service/conf/actions.d/actions_cron.conf +++ b/src/opnsense/service/conf/actions.d/actions_cron.conf @@ -1,5 +1,5 @@ [restart] -command:pluginctl -s cron restart +command:/usr/local/sbin/pluginctl -s cron restart parameters: type:script message:restarting cron diff --git a/src/opnsense/service/conf/actions.d/actions_dhcpd.conf b/src/opnsense/service/conf/actions.d/actions_dhcpd.conf index 5848795f2..f1c12ba71 100644 --- a/src/opnsense/service/conf/actions.d/actions_dhcpd.conf +++ b/src/opnsense/service/conf/actions.d/actions_dhcpd.conf @@ -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