diff options
author | Mathias Kresin <dev@kresin.me> | 2022-05-04 21:50:41 +0200 |
---|---|---|
committer | Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk> | 2022-11-06 19:47:13 +0000 |
commit | 7cdf74e163d8da8bf143c1ddd128f636e8e5afde (patch) | |
tree | fba2c017e74a3f889c0693c6ba8d2b8e062a7aa2 /package/network/services | |
parent | bf27d977f037794e6f26a87bc3d65d1690721e64 (diff) | |
download | upstream-7cdf74e163d8da8bf143c1ddd128f636e8e5afde.tar.gz upstream-7cdf74e163d8da8bf143c1ddd128f636e8e5afde.tar.bz2 upstream-7cdf74e163d8da8bf143c1ddd128f636e8e5afde.zip |
dnsmasq: add uci-defaults script for ipset migration
When running sysupgrade from an existing configuration, move existing
ipset definitions to a dedicated config section. Later on, it will allow
to serve ipset as well as nftable sets from the same configuration.
Signed-off-by: Mathias Kresin <dev@kresin.me>
Diffstat (limited to 'package/network/services')
-rw-r--r-- | package/network/services/dnsmasq/Makefile | 1 | ||||
-rwxr-xr-x | package/network/services/dnsmasq/files/50-dnsmasq-migrate-ipset.sh | 32 |
2 files changed, 33 insertions, 0 deletions
diff --git a/package/network/services/dnsmasq/Makefile b/package/network/services/dnsmasq/Makefile index 2a2d4fae79..e2902ed875 100644 --- a/package/network/services/dnsmasq/Makefile +++ b/package/network/services/dnsmasq/Makefile @@ -182,6 +182,7 @@ define Package/dnsmasq/install $(INSTALL_DATA) ./files/dnsmasq_acl.json $(1)/usr/share/acl.d/ $(INSTALL_DIR) $(1)/etc/uci-defaults $(INSTALL_BIN) ./files/50-dnsmasq-migrate-resolv-conf-auto.sh $(1)/etc/uci-defaults + $(INSTALL_BIN) ./files/50-dnsmasq-migrate-ipset.sh $(1)/etc/uci-defaults endef Package/dnsmasq-dhcpv6/install = $(Package/dnsmasq/install) diff --git a/package/network/services/dnsmasq/files/50-dnsmasq-migrate-ipset.sh b/package/network/services/dnsmasq/files/50-dnsmasq-migrate-ipset.sh new file mode 100755 index 0000000000..aba73e7dd4 --- /dev/null +++ b/package/network/services/dnsmasq/files/50-dnsmasq-migrate-ipset.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +ipsets=$(uci -q get dhcp.@dnsmasq[0].ipset) +[ -z "$ipsets" ] && exit 0 + +for ipset in $ipsets; do + names=${ipset##*/} + domains=${ipset%/*} + + [ -z "$names" ] || [ -z "$domains" ] && continue + + uci add dhcp ipset + + OLDIFS="$IFS" + + IFS="," + for name in $names; do + uci add_list dhcp.@ipset[-1].name="$name" + done + + IFS="/" + for domain in ${domains:1}; do + uci add_list dhcp.@ipset[-1].domain="$domain" + done + + IFS="$OLDIFS" + + uci del_list dhcp.@dnsmasq[0].ipset="$ipset" +done + +uci commit dhcp +exit 0 |