清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
#!/bin/sh # usage: ./dnspod.sh ddns.conf # # # # ACCOUNT="" PASSWORD="" DOMAIN="" SUBDOMAINS="" RECORD_LINE="" DOMAIN_ID="" RECORD_LIST="" #更新记录id的ip地址 #curl -k https://dnsapi.cn/Record.Ddns -d "login_email=${ACCOUNT}&login_password=${PASSWORD}&domain_id=${DOMAIN_ID}&record_id=${REC_BBS}&sub_domain=${SUB_BBS}&record_line=${RECORD_LINE}" #获得域名id #curl -k https://dnsapi.cn/Domain.List -d "login_email=${ACCOUNT}&login_password=${PASSWORD}" #获得域名id下的记录列表 #curl -k https://dnsapi.cn/Record.List -d "login_email=${ACCOUNT}&login_password=${PASSWORD}&domain_id=${DOMAIN_ID}" dnspod_load_config(){ cfg=$1; content=`cat ${cfg}`; ACCOUNT=`echo "${content}" |grep 'ACCOUNT'| sed 's/^ACCOUNT=[\"]\(.*\)[\"]/\1/'`; PASSWORD=`echo "${content}" |grep 'PASSWORD'| sed 's/^PASSWORD=[\"]\(.*\)[\"]/\1/'`; DOMAIN=`echo "${content}" |grep 'DOMAIN'| sed 's/^DOMAIN=[\"]\(.*\)[\"]/\1/'`; SUBDOMAINS=`echo "${content}" |grep 'SUBDOMAINS'| sed 's/^SUBDOMAINS=[\"]\(.*\)[\"]/\1/'`; RECORD_LINE=`echo "${content}" |grep 'RECORD_LINE'| sed 's/^RECORD_LINE=[\"]\(.*\)[\"]/\1/'`; } dnspod_domain_get_id(){ options="login_email=${ACCOUNT}&login_password=${PASSWORD}"; cmd="curl -s -k https://dnsapi.cn/Domain.List -d ${options}"; out=`${cmd}|sed -n '/<id>/,/<\/name>/p'`; DOMAIN_ID=`echo "${out}"|grep -B1 "${DOMAIN}"|grep '<id>*'|sed 's/<id>\(.*\)<\/id>/\1/'` RECORD_LIST=`curl -s -k https://dnsapi.cn/Record.List -d "${options}&domain_id=${DOMAIN_ID}"` } dnspod_update_record_ip(){ html=$1; out=`echo "${html}"|sed -n '/<item>/,/<\/item>/p'` out=`echo "${out}"|grep -B3 '<type>A</type>'`; for sub in ${SUBDOMAINS}; do rec_id=`echo "${out}"|grep -B1 "${sub}"|grep '<id>*'|sed 's/<id>\(.*\)<\/id>/\1/'` curl -k https://dnsapi.cn/Record.Ddns -d "login_email=${ACCOUNT}&login_password=${PASSWORD}&domain_id=${DOMAIN_ID}&record_id=${rec_id}&sub_domain=${sub}&record_line=${RECORD_LINE}" done } main(){ dnspod_load_config $1 dnspod_domain_get_id dnspod_update_record_ip "${RECORD_LIST}" } main $1