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>
This commit is contained in:
parent
bf27d977f0
commit
7cdf74e163
|
@ -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)
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue