Skip to content

Instantly share code, notes, and snippets.

@599316527
Last active October 18, 2019 08:32
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save 599316527/f802c7b908f7c33aa594 to your computer and use it in GitHub Desktop.
Save 599316527/f802c7b908f7c33aa594 to your computer and use it in GitHub Desktop.
asuswrt-merlin custom ddns script for dnspod
#!/bin/sh
# This file should be placed in /jffs/scripts/ folder.
# 后台申请token
# https://support.dnspod.cn/Kb/showarticle/tsid/227/
login_token='xxxxxxx,yyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
# 先调 Domain.List 和 Record.List 接口取得 id
# https://www.dnspod.cn/docs/domains.html#domain-list
# https://www.dnspod.cn/docs/records.html#record-list
domain_id='12345678'
record_id='987654321'
################################################################
api_url='https://dnsapi.cn/Record.Modify'
log_path='/tmp/ddns-start.log'
sub_domain='www'
value="$1"
record_type='A'
record_line='%E9%BB%98%E8%AE%A4' # 默认
form_data="format=json\
&login_token=${login_token}\
&domain_id=${domain_id}\
&record_id=${record_id}\
&sub_domain=${sub_domain}\
&value=${value}\
&record_type=${record_type}\
&record_line=${record_line}"
curl -v -d $form_data -o $log_path $api_url
if [ $? -eq 0 ]; then
/sbin/ddns_custom_updated 1
else
/sbin/ddns_custom_updated 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment