ddns-script: add retry_max_count's upgrade script
authorFriesI23 Qin <FriesI23@outlook.com>
Sun, 9 Feb 2025 10:22:23 +0000 (18:22 +0800)
committerFlorian Eckert <Eckert.Florian@googlemail.com>
Thu, 13 Feb 2025 12:31:53 +0000 (13:31 +0100)
Signed-off-by: FriesI23 Qin <FriesI23@outlook.com>
net/ddns-scripts/Makefile
net/ddns-scripts/files/etc/uci-defaults/50-ddns-migrate-retry-count [new file with mode: 0644]

index 1a6eecc01c80a10cb07d725f47d35d6bc5e17505..9c41a86eb650c622eebf2477d814f59c599a4e0b 100644 (file)
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=ddns-scripts
 PKG_VERSION:=2.8.2
-PKG_RELEASE:=61
+PKG_RELEASE:=62
 
 PKG_LICENSE:=GPL-2.0
 
@@ -362,6 +362,10 @@ define Package/ddns-scripts/install
        $(INSTALL_DIR) $(1)/usr/bin
        $(INSTALL_BIN) ./files/usr/bin/ddns.sh \
                $(1)/usr/bin/ddns
+
+       $(INSTALL_DIR) $(1)/etc/uci-defaults
+       $(INSTALL_DATA) ./files/etc/uci-defaults/50-ddns-migrate-retry-count \
+               $(1)/etc/uci-defaults/
 endef
 
 define Package/ddns-scripts/postinst
diff --git a/net/ddns-scripts/files/etc/uci-defaults/50-ddns-migrate-retry-count b/net/ddns-scripts/files/etc/uci-defaults/50-ddns-migrate-retry-count
new file mode 100644 (file)
index 0000000..88fa0f5
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+. /lib/functions.sh
+
+upgrade_to_retry_max_count() {
+       local service=$1
+       local retry_count retry_max_count
+
+       config_get retry_max_count $service retry_max_count
+       config_get retry_count $service retry_count
+       if [ -z "$retry_max_count" ] && [ -n "$retry_count" ]; then
+               uci_set ddns $service retry_max_count $retry_count
+               uci_commit ddns
+       fi
+}
+
+config_load ddns
+config_foreach upgrade_to_retry_max_count service
+
+exit 0