dnsmasq: migrate to rc.d scripting

This commit is contained in:
Franco Fichtner 2025-02-24 23:51:32 +01:00
parent d1b4277047
commit b94578935f
5 changed files with 14 additions and 5 deletions

1
plist
View File

@ -1395,6 +1395,7 @@
/usr/local/opnsense/service/templates/OPNsense/Cron/user.cron
/usr/local/opnsense/service/templates/OPNsense/Dnsmasq/+TARGETS
/usr/local/opnsense/service/templates/OPNsense/Dnsmasq/dnsmasq.conf
/usr/local/opnsense/service/templates/OPNsense/Dnsmasq/rc.conf.d
/usr/local/opnsense/service/templates/OPNsense/Filter/+TARGETS
/usr/local/opnsense/service/templates/OPNsense/Filter/filter_geoip.conf
/usr/local/opnsense/service/templates/OPNsense/Filter/filter_tables.conf

View File

@ -49,7 +49,7 @@ function dnsmasq_services()
{
$services = [];
if (!dnsmasq_enabled() && !isvalidpid('/var/run/dnsmasq.pid')) {
if (!dnsmasq_enabled()) {
return $services;
}
@ -63,6 +63,7 @@ function dnsmasq_services()
$pconfig['description'] = gettext('Dnsmasq DNS');
$pconfig['php']['restart'] = ['dnsmasq_configure_do'];
$pconfig['php']['start'] = ['dnsmasq_configure_do'];
$pconfig['configd']['stop'] = ['dnsmasq stop'];
$pconfig['pidfile'] = '/var/run/dnsmasq.pid';
$services[] = $pconfig;
@ -139,7 +140,7 @@ function dnsmasq_configure_do($verbose = false)
global $config;
killbypid('/var/run/dnsmasq_dhcpd.pid');
killbypid('/var/run/dnsmasq.pid');
mwexec('/usr/local/etc/rc.d/dnsmasq stop');
if (!dnsmasq_enabled()) {
return;
@ -149,7 +150,7 @@ function dnsmasq_configure_do($verbose = false)
_dnsmasq_add_host_entries();
mwexec("/usr/local/sbin/dnsmasq");
mwexec('/usr/local/etc/rc.d/dnsmasq start');
if (!empty($config['dnsmasq']['regdhcp'])) {
/* XXX: deprecate when moving ISC to plugins ? */

View File

@ -4,7 +4,7 @@ type:script
message:Starting Dnsmasq
[stop]
command:/usr/local/sbin/pluginctl -s dnsmasq stop
command:/usr/local/etc/rc.d/dnsmasq stop
type:script
message:Stopping Dnsmasq
@ -15,7 +15,7 @@ message:Restarting Dnsmasq
description:Restart Dnsmasq DNS service
[status]
command:/usr/local/sbin/pluginctl -s dnsmasq status
command:/usr/local/etc/rc.d/dnsmasq status; exit 0
type:script_output
message:Request Dnsmasq status

View File

@ -1 +1,2 @@
dnsmasq.conf:/usr/local/etc/dnsmasq.conf
rc.conf.d:/etc/rc.conf.d/dnsmasq

View File

@ -0,0 +1,6 @@
{% if not helpers.empty('dnsmasq.enable') %}
dnsmasq_enable="YES"
dnsmasq_skip="YES"
{% else %}
dnsmasq_enable="NO"
{% endif %}