Skip to content

Instantly share code, notes, and snippets.

@chmouel
Created October 10, 2017 14:06
Show Gist options
  • Select an option

  • Save chmouel/d29b71355e8c6e7ff19b510ad0183c59 to your computer and use it in GitHub Desktop.

Select an option

Save chmouel/d29b71355e8c6e7ff19b510ad0183c59 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
# Set those!!
APIKEY=""
DOMAIN=""
RECORD=""
URL=https://dns.api.gandi.net/api/v5/domains/${DOMAIN}/records/${RECORD}/A
DNSIP=$(curl -s -H "X-Api-Key: $APIKEY" ${URL}| jq --raw-output '.rrset_values[0]')
NEWIP=$(curl -s http://icanhazip.com/)
[[ ${DNSIP} == ${NEWIP} ]] && exit 0
curl -s -X PUT -H "Content-Type: application/json" \
-H "X-Api-Key: $APIKEY" \
-d "{\"rrset_values\": [\"${NEWIP}\"]}" $URL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment