dnsmasq: add uci-defaults script for config migration
authorDaniel Golle <daniel@makrotopia.org>
Thu, 9 Jan 2020 13:32:12 +0000 (15:32 +0200)
committerDaniel Golle <daniel@makrotopia.org>
Thu, 9 Jan 2020 13:37:53 +0000 (15:37 +0200)
When running sysupgrade from an existing configuration, UCI option
dhcp.@dnsmasq[0].resolvfile needs to be modified in case it has not
been changed from it's original value.
Accomplish that using a uci-defaults script.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
package/network/services/dnsmasq/Makefile
package/network/services/dnsmasq/files/50-dnsmasq-migrate-resolv-conf-auto.sh [new file with mode: 0755]

index d1e0c34e97b3981b93a26caed2d883e2f02543d3..60d16f349638305edf7c2c38619b6c51e23e6adb 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 PKG_NAME:=dnsmasq
 PKG_UPSTREAM_VERSION:=2.80
 PKG_VERSION:=$(subst test,~~test,$(subst rc,~rc,$(PKG_UPSTREAM_VERSION)))
-PKG_RELEASE:=17
+PKG_RELEASE:=18
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_UPSTREAM_VERSION).tar.xz
 PKG_SOURCE_URL:=http://thekelleys.org.uk/dnsmasq
@@ -178,6 +178,8 @@ define Package/dnsmasq/install
        $(INSTALL_BIN) ./files/dhcp-script.sh $(1)/usr/lib/dnsmasq/dhcp-script.sh
        $(INSTALL_DIR) $(1)/usr/share/acl.d
        $(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
 endef
 
 Package/dnsmasq-dhcpv6/install = $(Package/dnsmasq/install)
diff --git a/package/network/services/dnsmasq/files/50-dnsmasq-migrate-resolv-conf-auto.sh b/package/network/services/dnsmasq/files/50-dnsmasq-migrate-resolv-conf-auto.sh
new file mode 100755 (executable)
index 0000000..c78faa1
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+[ "$(uci get dhcp.@dnsmasq[0].resolvfile)" = "/tmp/resolv.conf.auto" ] && {
+       uci set dhcp.@dnsmasq[0].resolvfile="/tmp/resolv.conf.d/resolv.conf.auto"
+       uci commit dhcp
+}