Add a check when updated IP is the same as what we updated.
I have look at the API doc, the value of IP is optional, So if we update some text the "code"s value will still return "1".
This commit is contained in:
1 parent
808066b5a3
commit
f471b3502b
1 file changed
+16
-7
+16
-7
@@ -152,7 +152,7 @@ arApiPost() {
|
|||||||
# Update
|
# Update
|
||||||
# arg: main domain sub domain
|
# arg: main domain sub domain
|
||||||
arDdnsUpdate() {
|
arDdnsUpdate() {
|
||||||
local domainID recordID recordRS recordCD myIP
|
local domainID recordID recordRS recordCD recordIP myIP
|
||||||
# Get domain ID
|
# Get domain ID
|
||||||
domainID=$(arApiPost "Domain.Info" "domain=${1}")
|
domainID=$(arApiPost "Domain.Info" "domain=${1}")
|
||||||
domainID=$(echo $domainID | sed 's/.*{"id":"\([0-9]*\)".*/\1/')
|
domainID=$(echo $domainID | sed 's/.*{"id":"\([0-9]*\)".*/\1/')
|
||||||
@@ -165,15 +165,21 @@ arDdnsUpdate() {
|
|||||||
myIP=$(arIpAddress)
|
myIP=$(arIpAddress)
|
||||||
recordRS=$(arApiPost "Record.Ddns" "domain_id=${domainID}&record_id=${recordID}&sub_domain=${2}&record_type=A&value=${myIP}&record_line=默认")
|
recordRS=$(arApiPost "Record.Ddns" "domain_id=${domainID}&record_id=${recordID}&sub_domain=${2}&record_type=A&value=${myIP}&record_line=默认")
|
||||||
recordCD=$(echo $recordRS | sed 's/.*{"code":"\([0-9]*\)".*/\1/')
|
recordCD=$(echo $recordRS | sed 's/.*{"code":"\([0-9]*\)".*/\1/')
|
||||||
|
recordIP=$(echo $recordRS | sed 's/.*,"value":"\([0-9\.]*\)".*/\1/')
|
||||||
|
|
||||||
# Output IP
|
# Output IP
|
||||||
if [ "$recordCD" = "1" ]; then
|
if [ "$recordIP" = "$myIP" ]; then
|
||||||
echo $recordRS | sed 's/.*,"value":"\([0-9\.]*\)".*/\1/'
|
if [ "$recordCD" = "1" ]; then
|
||||||
return 0
|
echo $recordIP
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
# Echo error message
|
||||||
|
echo $recordRS | sed 's/.*,"message":"\([^"]*\)".*/\1/'
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
echo "Update Failed! Please check your network."
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
# Echo error message
|
|
||||||
echo $recordRS | sed 's/.*,"message":"\([^"]*\)".*/\1/'
|
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# DDNS Check
|
# DDNS Check
|
||||||
@@ -192,6 +198,9 @@ arDdnsCheck() {
|
|||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "postRS: ${postRS}"
|
echo "postRS: ${postRS}"
|
||||||
return 0
|
return 0
|
||||||
|
else
|
||||||
|
echo ${postRS}
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo "Last IP is the same as current IP!"
|
echo "Last IP is the same as current IP!"
|
||||||
|
|||||||
Reference in new issue
Block a user