Update ddnspod.sh
This commit is contained in:
1 parent
882e441909
commit
8edcd8db59
1 file changed
+19
-21
+19
-21
@@ -3,28 +3,26 @@
|
||||
|
||||
#################################################
|
||||
# AnripDdns v5.07.07
|
||||
# 基于DNSPod用户API实现的动态域名客户端
|
||||
# 作者: 若海[mail@anrip.com]
|
||||
# 介绍: http://www.anrip.com/ddnspod
|
||||
# 时间: 2015-07-07 10:25:00
|
||||
# Dynamic DNS using DNSPod API
|
||||
# Edited by ProfFan
|
||||
#################################################
|
||||
|
||||
# 全局变量表
|
||||
# Global Variables
|
||||
arPass=arMail=""
|
||||
|
||||
# 获得外网地址
|
||||
# Port IP
|
||||
arIpAdress() {
|
||||
ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1
|
||||
}
|
||||
|
||||
# 查询域名地址
|
||||
# 参数: 待查询域名
|
||||
# Get Domain IP
|
||||
# arg: domain
|
||||
arNslookup() {
|
||||
wget --quiet --output-document=- $inter$1
|
||||
}
|
||||
|
||||
# 读取接口数据
|
||||
# 参数: 接口类型 待提交数据
|
||||
# Get data
|
||||
# arg: type data
|
||||
arApiPost() {
|
||||
local agent="AnripDdns/5.07(mail@anrip.com)"
|
||||
local inter="https://dnsapi.cn/${1:?'Info.Version'}"
|
||||
@@ -32,31 +30,31 @@ arApiPost() {
|
||||
wget --quiet --no-check-certificate --output-document=- --user-agent=$agent --post-data $param $inter
|
||||
}
|
||||
|
||||
# 更新记录信息
|
||||
# 参数: 主域名 子域名
|
||||
# Update
|
||||
# arg: main domain sub domain
|
||||
arDdnsUpdate() {
|
||||
local domainID recordID recordRS recordCD myIP
|
||||
# 获得域名ID
|
||||
# Get domain ID
|
||||
domainID=$(arApiPost "Domain.Info" "domain=${1}")
|
||||
domainID=$(echo $domainID | sed 's/.\+{"id":"\([0-9]\+\)".\+/\1/')
|
||||
# 获得记录ID
|
||||
# Get Record ID
|
||||
recordID=$(arApiPost "Record.List" "domain_id=${domainID}&sub_domain=${2}")
|
||||
recordID=$(echo $recordID | sed 's/.\+\[{"id":"\([0-9]\+\)".\+/\1/')
|
||||
# 更新记录IP
|
||||
# Update IP
|
||||
myIP=$(arIpAdress)
|
||||
recordRS=$(arApiPost "Record.Modify" "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/')
|
||||
# 输出记录IP
|
||||
# Output IP
|
||||
if [ "$recordCD" == "1" ]; then
|
||||
echo $recordRS | sed 's/.\+,"value":"\([0-9\.]\+\)".\+/\1/'
|
||||
return 1
|
||||
fi
|
||||
# 输出错误信息
|
||||
# Echo error message
|
||||
echo $recordRS | sed 's/.\+,"message":"\([^"]\+\)".\+/\1/'
|
||||
}
|
||||
|
||||
# 动态检查更新
|
||||
# 参数: 主域名 子域名
|
||||
# DDNS Check
|
||||
# Arg: Main Sub
|
||||
arDdnsCheck() {
|
||||
local postRS
|
||||
local hostIP=$(arIpAdress)
|
||||
@@ -75,10 +73,10 @@ arDdnsCheck() {
|
||||
|
||||
###################################################
|
||||
|
||||
# 设置用户参数
|
||||
# User
|
||||
arMail="user@anrip.com"
|
||||
arPass="anrip.net"
|
||||
|
||||
# 检查更新域名
|
||||
# DDNS
|
||||
arDdnsCheck "anrip.com" "lab"
|
||||
arDdnsCheck "anrip.net" "lab"
|
||||
Reference in new issue
Block a user