1234567891011121314 |
- #!/usr/bin/env bash
- ZONE=$'cat /srv/ipingus6/zone.conf'
- EMAIL=$'cat /srv/ipingus6/email.conf'
- AUTHKEY=$'cat /srv/ipingus6/authkey.conf'
- DOMAIN=$'cat /srv/ipingus6/domain.conf'
- IP=$(ip a | grep 2001 | awk '{print $2}' | awk -F '/' '{print $1}')
- ID=$(curl -sX GET "https://api.cloudflare.com/client/v4/zones/$ZONE/dns_records" \
- -H "X-Auth-Email: $EMAIL" -H "X-Auth-Key: $AUTHKEY" -H "Content-Type: application/json" | awk \
- -F '","zone_id":"'$ZONE'","zone_name":"'$DOMAIN'","name":"'$DOMAIN'"' '{print $1}')
- NUM1=$(echo $ID | wc -c) && NUM2=$(($NUM1-32)) && DNS=$(echo $ID | cut -b $NUM2-$NUM1)
- curl -sX PUT "https://api.cloudflare.com/client/v4/zones/$ZONE/dns_records/$DNS" \
- -H "X-Auth-Email: $EMAIL" -H "X-Auth-Key: $AUTHKEY" -H "Content-Type: application/json" \
- -d '{"type":"AAAA","name":"'$DOMAIN'","content":"'$IP'","ttl":1,"proxied":false}' > /dev/null 2>&1
|