非常抱歉回复晚了

原荒野无灯的脚本修改返回值,脚本如下:


#!/bin/sh

#################################################
# AnripDdns v5.08
# 基于DNSPod用户API实现的动态域名客户端
# 作者: 若海[mail@anrip.com]
# 介绍: http://www.anrip.com/ddnspod
# 时间: 2016-02-24 16:25:00
# Mod: 荒野无灯 http://ihacklog.com  2016-03-16
#################################################

# 使用Token认证(推荐) 请去 https://www.dnspod.cn/console/user/security 获取
arToken="**************************"
# 使用邮箱和密码认证
arMail=""
arPass=""

# 获得外网地址
arIpAdress() {
local inter=`nvram get wan0_ipaddr`
echo $inter
}

# 查询域名地址
# 参数: 待查询域名
arNslookup() {
local inter="http://119.29.29.29/d?dn="
wget --quiet --output-document=- $inter$1
}

# 读取接口数据
# 参数: 接口类型 待提交数据
arApiPost() {
local agent="AnripDdns/5.07(mail@anrip.com)"
local inter="https://dnsapi.cn/${1:?'Info.Version'}"
if [ "x${arToken}" = "x" ]; then # undefine token
local param="login_email=${arMail}&login_password=${arPass}&format=json&${2}"
else
local param="login_token=${arToken}&format=json&${2}"
fi
wget --quiet --no-check-certificate --output-document=- --user-agent=$agent --post-data $param $inter
}

# 更新记录信息
# 参数: 主域名 子域名
arDdnsUpdate() {
local domainID recordID recordRS recordCD
# 获得域名ID
domainID=$(arApiPost "Domain.Info" "domain=${1}")
domainID=$(echo $domainID | sed 's/.\+{"id":"\([0-9]\+\)".\+/\1/')
# 获得记录ID
recordID=$(arApiPost "Record.List" "domain_id=${domainID}&sub_domain=${2}")
recordID=$(echo $recordID | sed 's/.\+\[{"id":"\([0-9]\+\)".\+/\1/')
# 更新记录IP
recordRS=$(arApiPost "Record.Ddns" "domain_id=${domainID}&record_id=${recordID}&sub_domain=${2}&record_line=默认")
recordCD=$(echo $recordRS | sed 's/.\+{"code":"\([0-9]\+\)".\+/\1/')
# 输出记录IP
if [ "$recordCD" == "1" ]; then
echo $recordRS | sed 's/.\+,"value":"\([0-9\.]\+\)".\+/\1/'
return 1
fi
# 输出错误信息
echo $recordRS | sed 's/.\+,"message":"\([^"]\+\)".\+/\1/'
}

# 动态检查更新
# 参数: 主域名 子域名
arDdnsCheck() {
local postRS
local hostIP=$(arIpAdress)
local lastIP=$(arNslookup "${2}.${1}")
echo "hostIP: ${hostIP}"
echo "lastIP: ${lastIP}"
if [ "$lastIP" != "$hostIP" ]; then
postRS=$(arDdnsUpdate $1 $2)
echo "postRS: ${postRS}"
if [ $? -ne 1 ]; then
return 1
fi
fi
return 0
}

###################################################
# 检查更新域名

arDdnsCheck "" ""

if [ $? -eq 1 ]; then
/sbin/ddns_custom_updated 1
else
/sbin/ddns_custom_updated 0
fi