通过 https://developer.godaddy.com/keys 创建环境为Production的key和Secret并记录下来
cat list
abc:dfg.xyz:6x.2xx.1xx.1xx
abc:ert.xyz:6x.2xx.1xx.1xx
abc:ers.xyz:6x.2xx.1xx.1xx
abc:vgb.xyz:6x.2xx.1xx.1xx
cat godaddy.sh
#! /bin/bash
apikey="你的key:你的Secret"
for i in `cat list`
do
name=`echo $i|awk -F: '{print $1}'`
domain=`echo $i|awk -F: '{print $2}'`
ip=`echo $i|awk -F: '{print $3}'`
curl -X PUT "https://api.godaddy.com/v1/domains/${domain}/records/A/${name}" -H "accept: application/json" -H "Content-Type: application/json" -H "Authorization: sso-key ${apikey}" -d "[ { \"data\": \"${ip}\", \"ttl\": 600, \"type\": \"A\" }]"
sleep 2
done
https://developer.godaddy.com/doc/endpoint/domains#/v1/recordReplaceTypeName 在这里可以自定义生成
这里是生成mx记录更改
curl -X PUT "https://api.godaddy.com/v1/domains/${domain}/records/MX/${name}" -H "accept: application/json" -H "Content-Type: application/json" -H "Authorization: sso-key UzQxLikm_46KxDFnbjN7cQjmw6wocia:46L26ydpkwMaKZV6uVdDWe" -d "[ { \"data\": \"${ip}\", \"priority\": 5, \"ttl\": 600, \"type\": \"MX\" }]"
priority是优先级
删除记录 A记录和MX记录
curl -X DELETE "https://api.godaddy.com/v1/domains/abc.com/records/A/bagorium" -H "accept: application/json" -H "Authorization: sso-key UzQxLikm_46KxDFnbjN7cQjmw6wocia:46L26ydpkwMaKZV6uVdDWe"
curl -X DELETE "https://api.godaddy.com/v1/domains/abc.com/records/MX/bagorium" -H "accept: application/json" -H "Authorization: sso-key UzQxLikm_46KxDFnbjN7cQjmw6wocia:46L26ydpkwMaKZV6uVdDWe"