#!/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 '//,/<\/name>/p'`; domain_id=`echo "${out}"|grep -b1 "${domain}"|grep ' *'|sed 's/ \(.*\)<\/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>/p'` out=`echo "${out}"|grep -b3 '
a '`; for sub in ${subdomains}; do rec_id=`echo "${out}"|grep -b1 "${sub}"|grep '*'|sed 's/ \(.*\)<\/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
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....