#!/bin/sh # 参考资料: # https://github.com/openwrt/packages/blob/master/net/ddns-scripts/samples/update_sample.sh # https://github.com/anjianshi/cloudxns-ddns/blob/master/cloudxns.sh # # Requirements: # curl [ -z "$domain" ] && write_log 14 "Service section not configured correctly! Missing 'domain'" [ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing 'username'" [ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing 'password'" API_URL="https://api.cloudflare.com/client/v4/" API_EMAIL=$username API_KEY=$password API_ZONE_ID="{zone_id}" API_DNS_RECORD_ID="{dns_record_id" RESULT=$(curl -X PUT "${API_URL}/zones/${API_ZONE_ID}/dns_records/${API_DNS_RECORD_ID}" \ -H "Content-Type: application/json" \ -H "X-Auth-Email: ${API_EMAIL}" \ -H "X-Auth-Key: ${API_KEY}" \ --data '{"type":"A","name":"'${API_DOMAIN}'","content":"'${__IP}'","ttl":120,"proxied":false}') write_log 7 "answered:\n$RESULT" if [ $(echo -n "$RESULT"|grep -o "\"success\":true"|wc -l) = 1 ];then return 0 else return 1 fi