Skip to content

Instantly share code, notes, and snippets.

@jgamblin
Created July 12, 2017 11:11
Show Gist options
  • Save jgamblin/fa60e453a6666fd4fc71632400ab9a82 to your computer and use it in GitHub Desktop.
Save jgamblin/fa60e453a6666fd4fc71632400ab9a82 to your computer and use it in GitHub Desktop.
Shell Script To Automatically Create A DNS A Record in Godaddy.
#!/bin/bash
DOMAIN=jgamblin.com
RECORD_NAME=newproject
GODADDY_API_KEY=(Get from devloper.godaddy.com)
GODADDY_API_SECRET=(Get from devloper.godaddy.com)
# Get IP Address
IP=`dig +short myip.opendns.com @resolver1.opendns.com`
# Create DNS A Record
curl -X PUT -H 'Content-Type: application/json' -H 'Accept: application/json' -H "Authorization: sso-key $GODADDY_API_KEY:$GODADDY_API_SECRET" "https://api.godaddy.com/v1/domains/$DOMAIN/records/A/$RECORD_NAME" -d "[{\"data\": \"$IP\"}]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment