script3.sh 866 B

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