Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[24.10] ddns-scripts: backport updates to 24.10 branch #26033

Merged
merged 12 commits into from
Feb 24, 2025
Merged
38 changes: 37 additions & 1 deletion net/ddns-scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk

PKG_NAME:=ddns-scripts
PKG_VERSION:=2.8.2
PKG_RELEASE:=52
PKG_RELEASE:=64

PKG_LICENSE:=GPL-2.0

Expand Down Expand Up @@ -155,6 +155,17 @@ define Package/ddns-scripts-dnspod/description
endef


define Package/ddns-scripts-dnspod-v3
$(call Package/ddns-scripts/Default)
TITLE:=Extension for dnspod.tencentcloudapi.com (aka: dnspod.cn) API v3
DEPENDS:=ddns-scripts +curl +openssl-util
endef

define Package/ddns-scripts-dnspod-v3/description
Dynamic DNS Client scripts extension for dnspod.tencentcloudapi.com API v3 (require curl)
endef


define Package/ddns-scripts-noip
$(call Package/ddns-scripts/Default)
TITLE:=Extension for no-ip.com
Expand Down Expand Up @@ -351,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
Expand Down Expand Up @@ -385,6 +400,7 @@ define Package/ddns-scripts-services/install
rm $(1)/usr/share/ddns/default/godaddy.com-v1.json
rm $(1)/usr/share/ddns/default/digitalocean.com-v2.json
rm $(1)/usr/share/ddns/default/dnspod.cn.json
rm $(1)/usr/share/ddns/default/dnspod.cn-v3.json
rm $(1)/usr/share/ddns/default/no-ip.com.json
rm $(1)/usr/share/ddns/default/bind-nsupdate.json
rm $(1)/usr/share/ddns/default/route53-v1.json
Expand Down Expand Up @@ -541,6 +557,25 @@ exit 0
endef


define Package/ddns-scripts-dnspod-v3/install
$(INSTALL_DIR) $(1)/usr/lib/ddns
$(INSTALL_BIN) ./files/usr/lib/ddns/update_dnspod_cn_v3.sh \
$(1)/usr/lib/ddns

$(INSTALL_DIR) $(1)/usr/share/ddns/default
$(INSTALL_DATA) ./files/usr/share/ddns/default/dnspod.cn-v3.json \
$(1)/usr/share/ddns/default/
endef

define Package/ddns-scripts-dnspod-v3/prerm
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
/etc/init.d/ddns stop
fi
exit 0
endef


define Package/ddns-scripts-noip/install
$(INSTALL_DIR) $(1)/usr/lib/ddns
$(INSTALL_BIN) ./files/usr/lib/ddns/update_no-ip_com.sh \
Expand Down Expand Up @@ -760,6 +795,7 @@ $(eval $(call BuildPackage,ddns-scripts-freedns))
$(eval $(call BuildPackage,ddns-scripts-godaddy))
$(eval $(call BuildPackage,ddns-scripts-digitalocean))
$(eval $(call BuildPackage,ddns-scripts-dnspod))
$(eval $(call BuildPackage,ddns-scripts-dnspod-v3))
$(eval $(call BuildPackage,ddns-scripts-noip))
$(eval $(call BuildPackage,ddns-scripts-nsupdate))
$(eval $(call BuildPackage,ddns-scripts-route53))
Expand Down
Original file line number Diff line number Diff line change
@@ -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
13 changes: 5 additions & 8 deletions net/ddns-scripts/files/usr/lib/ddns/update_cloudflare_com_v4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@
[ $use_https -eq 0 ] && use_https=1 # force HTTPS

# used variables
local __HOST __DOMAIN __TYPE __URLBASE __PRGBASE __RUNPROG __DATA __IPV6 __ZONEID __RECID __PROXIED
local __HOST __DOMAIN __TYPE __URLBASE __PRGBASE __RUNPROG __DATA __IPV6 __ZONEID __RECID
local __URLBASE="https://api.cloudflare.com/client/v4"
local __TTL=120

# split __HOST __DOMAIN from $domain
# given data:
Expand Down Expand Up @@ -97,8 +96,8 @@ __PRGBASE="$CURL -RsS -o $DATFILE --stderr $ERRFILE"
# force network/interface-device to use for communication
if [ -n "$bind_network" ]; then
local __DEVICE
network_get_physdev __DEVICE $bind_network || \
write_log 13 "Can not detect local device using 'network_get_physdev $bind_network' - Error: '$?'"
network_get_device __DEVICE $bind_network || \
write_log 13 "Can not detect local device using 'network_get_device $bind_network' - Error: '$?'"
write_log 7 "Force communication via device '$__DEVICE'"
__PRGBASE="$__PRGBASE --interface $__DEVICE"
fi
Expand Down Expand Up @@ -186,16 +185,14 @@ __DATA=$(grep -o '"content":\s*"[^"]*' $DATFILE | grep -o '[^"]*$' | head -1)

# update is needed
# let's build data to send
# set proxied parameter
__PROXIED=$(grep -o '"proxied":\s*[^",]*' $DATFILE | grep -o '[^:]*$')

# use file to work around " needed for json
cat > $DATFILE << EOF
{"id":"$__ZONEID","type":"$__TYPE","name":"$__HOST","content":"$__IP","ttl":$__TTL,"proxied":$__PROXIED}
{"content":"$__IP"}
EOF

# let's complete transfer command
__RUNPROG="$__PRGBASE --request PUT --data @$DATFILE '$__URLBASE/zones/$__ZONEID/dns_records/$__RECID'"
__RUNPROG="$__PRGBASE --request PATCH --data @$DATFILE '$__URLBASE/zones/$__ZONEID/dns_records/$__RECID'"
cloudflare_transfer || return 1

return 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
json_init
json_add_string name "$username"
json_add_string data "$__IP"
[ $use_ipv6 -ne 0 ] && json_add_string type "AAAA" || json_add_string type "A"

__STATUS=$(curl -Ss -X PUT "https://api.digitalocean.com/v2/domains/${domain}/records/${param_opt}" \
-H "Authorization: Bearer ${password}" \
Expand Down
2 changes: 1 addition & 1 deletion net/ddns-scripts/files/usr/lib/ddns/update_dnspod_cn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ build_command() {
# bind host/IP
if [ -n "$bind_network" ]; then
local __DEVICE
network_get_physdev __DEVICE $bind_network || write_log 13 "Can not detect local device using 'network_get_physdev $bind_network' - Error: '$?'"
network_get_device __DEVICE $bind_network || write_log 13 "Can not detect local device using 'network_get_device $bind_network' - Error: '$?'"
write_log 7 "Force communication via device '$__DEVICE'"
__CMDBASE="$__CMDBASE --interface $__DEVICE"
fi
Expand Down
Loading
Loading