Skip to content

Instantly share code, notes, and snippets.

@floodkoff
Created December 23, 2016 18:14
Show Gist options
  • Save floodkoff/ab8c5d69bccc725a345ddf97aaea7219 to your computer and use it in GitHub Desktop.
Save floodkoff/ab8c5d69bccc725a345ddf97aaea7219 to your computer and use it in GitHub Desktop.
Updates DNS record of Digitalocean managed domain
#!/bin/bash
API_KEY="ALLWORKANDNOPLAYMAKESJACKADULLBOYALLWORKANDNOPLAYMAKESJACKADULLB"
RECORD_ID="66666666"
DOMAIN="example.com"
ADDR=$(curl http://ipecho.net/plain)
# To get record ID for $DOMAIN
#curl \
# -H "Authorization: Bearer $API_KEY" \
# -H "Content-Type: application/json" \
# -X PUT 'https://api.digitalocean.com/v2/domains/$DOMAIN/records
echo "Updading IP to '$ADDR'"
echo $(\
curl \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-X PUT "https://api.digitalocean.com/v2/domains/$DOMAIN/records/$RECORD_ID" \
-d "{\"data\": \"$ADDR\"}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment