Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ echo "arDdnsCheck test.org subdomain" >> ./ardnspod

# 最近更新

2025/3/19
- 支持删除记录,方便管理

2025/2/21

- 支持创建记录,当记录不存在时创建
Expand Down
46 changes: 46 additions & 0 deletions ardnspod
Original file line number Diff line number Diff line change
Expand Up @@ -469,4 +469,50 @@ arDdnsCreate() {

}

# Delete Record
# Args: domain subdomain recordType

arDdnsDelete() {

local errCode
local recordId
local recordType
local recordCd
local recordRs

arLog "=== Delete $2.$1 ==="

if [ "$3" = "6" ]; then
recordType=AAAA
else
recordType=A
fi

arLog "> Record Type: $recordType"

arLog "Fetching RecordId"
recordId=$(arDdnsLookup "$1" "$2" "$recordType")

errCode=$?
if [ $errCode -eq 0 ]; then
arLog "> Record Id: $recordId"
else
return $errCode
fi

arLog "Deleting Record"
recordRs=$(arDdnsApi "Record.Remove" "domain=$1&record_id=$recordId")

# check result
recordCd=$(echo $recordRs | sed 's/.*{"code":"\([0-9]*\)".*/\1/')
if [ "$recordCd" != "1" ]; then
errMsg=$(echo $recordRs | sed 's/.*,"message":"\([^"]*\)".*/\1/')
arLog "> arDdnsDelete - error: $errMsg"
return 1
fi

arLog "> arDdnsDelete - successful"

}

################################################################### end ##