Created
November 11, 2013 00:20
-
-
Save disusered/7405821 to your computer and use it in GitHub Desktop.
Update DNSimple with local IP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# JSON Parser | |
JSON=`curl -s -X GET http://jsonip.com/` | |
PROP='ip' | |
function jsonval { | |
temp=`echo $JSON | sed 's/\\\\\//\//g' | sed 's/[{}]//g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | sed 's/\"\:\"/\|/g' | sed 's/[\,]/ /g' | sed 's/\"//g' | grep -w $PROP` | |
echo ${temp##*|} | |
} | |
# Dnsimple values | |
REQUEST_IP=`jsonval` | |
TOKEN_TYPE="X-DNSimple-Domain-Token" | |
TOKEN="<TOKEN>" | |
DOMAIN_ID="<DOMAIN>" | |
curl -H "${TOKEN_TYPE}: ${TOKEN}" \ | |
-H "Accept: application/json" \ | |
-H "Content-Type: application/json" \ | |
-X PUT \ | |
-d "{\"record\": {\"content\": \"${REQUEST_IP}\"} }" \ | |
https://dnsimple.com/domains/:domain/records/${DOMAIN_ID} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment