1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
| #!/bin/bash source ./cloudflare.env
for DOMAIN in $(cat $PWD/domain_list.txt) do curl -X POST -H "X-Auth-Key: ${CF_API_KEY}" \ -H "X-Auth-Email: ${CF_API_EMAIL}" \ -H "Content-Type: application/json" "https://api.cloudflare.com/client/v4/zones" \ --data '{"name":"'"${DOMAIN}"'","jump_start":true,"organization":{"name":"'"${ORGANIZATION_NAME}"'","id":"'"${ORGANIZATION_ID}"'"}}' >> $PWD/get_zone_id.cf ECHO -e "\n" >> $PWD/get_zone_id.cf done
$PYTHON $PWD/filter_zone_id.py
while read line do ZONE_NAME=$(ECHO "$line" | awk '{print $1}') ZONE_ID=$(ECHO "$line" | awk '{print $2}') curl -X GET "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records" \ -H "X-Auth-Email: ${CF_API_EMAIL}" -H "X-Auth-Key: ${CF_API_KEY}" \ -H "Content-Type: application/json" >> $PWD/get_dns_id.cf ECHO -e "\n" >> $PWD/get_dns_id.cf done < $PWD/zone_id.cf
$PYTHON $PWD/filter_dns_id.py
while read zone do ZONE_NAME=$(ECHO "$zone" | awk '{print $1}') ZONE_ID=$(ECHO "$zone" | awk '{print $2}') while read dns do DNS_NAME=$(ECHO "$dns" | awk '{ print $1 }') DNS_ID=$(ECHO "$dns" | awk '{ print $2 }') if [[ "*$DNS_NAME" =~ "$ZONE_NAME" ]] then curl -X DELETE "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${DNS_ID}" \ -H "X-Auth-Email:${CF_API_EMAIL}" \ -H "X-Auth-Key:${CF_API_KEY}" \ -H "Content-Type:application/json" fi done < $PWD/dns_id.cf done < $PWD/zone_id.cf
while read line do ZONE_NAME=$(ECHO "$line" | awk '{print $1}') ZONE_ID=$(ECHO "$line" | awk '{print $2}') curl -X POST "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records" \ -H "X-Auth-Email:${CF_API_EMAIL}" \ -H "X-Auth-Key:${CF_API_KEY}" \ -H "Content-Type:application/json" \ --data '{"type":"A","name":"@","content":"'"${CONTENT_A}"'","ttl":1,"priority":10,"proxied":true}'
curl -X POST "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records" \ -H "X-Auth-Email:${CF_API_EMAIL}" \ -H "X-Auth-Key:${CF_API_KEY}" \ -H "Content-Type:application/json" \ --data '{"type":"CNAME","name":"www","content":"'"${CONTENT_CNAME}"'","ttl":1,"priority":10,"proxied":false}'
curl -X POST "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records" \ -H "X-Auth-Email:${CF_API_EMAIL}" \ -H "X-Auth-Key:${CF_API_KEY}" \ -H "Content-Type:application/json" \ --data '{"type":"CNAME","name":"m","content":"'"${CONTENT_CNAME}"'","ttl":1,"priority":10,"proxied":false}' done < $PWD/zone_id.cf
|