From d06bb19dfc568a9c36dd75647e12e12f478a215f Mon Sep 17 00:00:00 2001 From: luodanzhi Date: Tue, 31 Oct 2017 22:26:34 +0800 Subject: [PATCH] Update dnspod.sh Using dnspod_is_record_updated2() to check if domain is updated. dnspod_is_record_updated2() is added for get subdomain ip directly from dnsapi.cn/Record.List. --- ddns/dnspod.sh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/ddns/dnspod.sh b/ddns/dnspod.sh index ec1af39..df65ff7 100644 --- a/ddns/dnspod.sh +++ b/ddns/dnspod.sh @@ -39,6 +39,25 @@ dnspod_is_record_updated(){ fi } +parse_json(){ + value=`echo $1 | cat test.txt | sed 's/.*"value":"\([0-9.]*\)",.*/\1/g'` + echo $value +} + +dnspod_is_record_updated2(){ + options="login_email=${ACCOUNT}&login_password=${PASSWORD}&format=json"; + out=$(curl -s -k https://dnsapi.cn/Record.List -d "${options}&domain=${DOMAIN}&sub_domain=${SUBDOMAIN}") + #echo $out + resolve_ip=$(parse_json $out) + #current_ip=$(curl -s icanhazip.com) + current_ip=$(curl -s ip.xdty.org) + echo $resolve_ip + echo $current_ip + if [ "$resolve_ip" = "$current_ip" ]; then + echo "Record updated." + exit 0; + fi +} dnspod_domain_get_id(){ options="login_email=${ACCOUNT}&login_password=${PASSWORD}"; out=$(curl -s -k https://dnsapi.cn/Domain.List -d ${options}); @@ -84,7 +103,7 @@ dnspod_update_record_ip(){ main(){ dnspod_load_config $1 - dnspod_is_record_updated + dnspod_is_record_updated2 dnspod_domain_get_id dnspod_update_record_ip }