[openwrt/openwrt] dnsmasq: add 'extraconftext' parameter
LEDE Commits
lede-commits at lists.infradead.org
Sun Oct 20 12:57:17 PDT 2024
hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/bd81d97e19e6cc6e33dc5ff852ece95bbc6be01e
commit bd81d97e19e6cc6e33dc5ff852ece95bbc6be01e
Author: Paul Donald <newtwen+github at gmail.com>
AuthorDate: Sat Apr 6 19:44:19 2024 +0200
dnsmasq: add 'extraconftext' parameter
Users can now freely add new dnsmasq parameters (i.e. a whole config)
via extraconf. This means users can add their own parameters without
changes to init or GUI.
Co-opted the default of confdir also to include the instance name.
This way each instance gets its own .d directory (and separate instances
do not all inherit the same 'extraconftext').
Usage:
config dnsmasq 'config'
...
option extraconftext 'cache-size=2048\nlog-async=20'
config dnsmasq 'blah'
...
option extraconftext 'cache-size=128\nlog-async=5'
or even (which would produce staggered output but still valid)
config dnsmasq 'blah'
...
option extraconftext 'cache-size=128
log-async=5'
See https://forum.openwrt.org/t/add-dnsmasq-custom-options-field-in-luci-gui/193184
Tested on: 23.05.3, 22.03.6
Signed-off-by: Paul Donald <newtwen+github at gmail.com>
Tested-by: Vladimir Kochkovski <ask at getvladimir.com>
Link: https://github.com/openwrt/openwrt/pull/14975
Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
package/network/services/dnsmasq/files/dnsmasq.init | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init
index 7ef4df3ba6..dee921258f 100755
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -12,6 +12,7 @@ ADD_WAN_FQDN=0
ADD_LOCAL_FQDN=""
BASECONFIGFILE="/var/etc/dnsmasq.conf"
+EXTRACONFFILE="extraconfig.conf"
BASEHOSTFILE="/tmp/hosts/dhcp"
TRUSTANCHORSFILE="/usr/share/dnsmasq/trust-anchors.conf"
TIMEVALIDFILE="/var/state/dnsmasqsec"
@@ -1121,14 +1122,19 @@ dnsmasq_start()
xappend "--dhcp-broadcast=tag:needs-broadcast"
- config_get dnsmasqconfdir "$cfg" confdir "/tmp/dnsmasq.d"
+ # Create a dnsmasq.d dir for each instance
+ config_get dnsmasqconfdir "$cfg" confdir "/tmp/dnsmasq${cfg:+.$cfg}.d"
xappend "--conf-dir=$dnsmasqconfdir"
dnsmasqconfdir="${dnsmasqconfdir%%,*}"
- [ ! -d "$dnsmasqconfdir" ] && mkdir -p $dnsmasqconfdir
+ [ ! -d "$dnsmasqconfdir" ] && mkdir -p "$dnsmasqconfdir"
xappend "--user=dnsmasq"
xappend "--group=dnsmasq"
echo >> $CONFIGFILE_TMP
+ # EXTRACONFFILE allows new dnsmasq parameters before they are natively handled in this init file
+ config_get extraconftext "$cfg" extraconftext
+ [ -n "$extraconftext" ] && echo -e "$extraconftext" > "$dnsmasqconfdir"/"$EXTRACONFFILE"
+
config_get_bool enable_tftp "$cfg" enable_tftp 0
[ "$enable_tftp" -gt 0 ] && {
config_get tftp_root "$cfg" tftp_root
More information about the lede-commits
mailing list