Skip to content

Instantly share code, notes, and snippets.

@chiwanpark
Last active March 27, 2016 10:59
Show Gist options
  • Save chiwanpark/6f8a748415f5aa08ab37 to your computer and use it in GitHub Desktop.
Save chiwanpark/6f8a748415f5aa08ab37 to your computer and use it in GitHub Desktop.
Update DNSimple
#!/bin/bash
CURRENT_IP=`ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'`
curl -H 'X-DNSimple-Token: <EMAIL>:<API_TOKEN>' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-X PUT \
-d '{"record":{"name":"<DOMAIN_NAME>", "content":"'$CURRENT_IP'"}}' \
https://api.dnsimple.com/v1/domains/chiwanpark.com/records/<DNS_RECORD_ID> \
-o /tmp/update-dnsimple.log
@visar
Copy link

visar commented Mar 27, 2016

How can the curl command be translated to wget? (My router has no curl :( )
I tried this:

wget -S --header="Accept: application/json" --header="Content-Type: application/json" --header="X-DNSimple-Token: $LOGIN:$TOKEN" --post-data="{"record":{"content":"$IP"}}" "https://api.dnsimple.com/v1/domains/$DOMAIN_ID/records/$RECORD_ID"

but I'm getting 404 from wget.

--2016-03-27 12:37:19-- https://api.dnsimple.com/v1/domains/visar.me/records/5466221
Resolving api.dnsimple.com (api.dnsimple.com)... 208.93.64.253
Connecting to api.dnsimple.com (api.dnsimple.com)|208.93.64.253|:443... connected.
HTTP request sent, awaiting response...
HTTP/1.1 404 Not Found
Server: nginx
Date: Sun, 27 Mar 2016 10:38:32 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Status: 404 Not Found
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Authorization,Accepts,Content-Type,X-DNSimple-Token,X-DNSimple-Domain-Token,X-CSRF-Token,x-requested-with
Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS
X-Frame-Options: DENY
X-XSS-Protection: 1
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Permitted-Cross-Domain-Policies: none
Cache-Control: no-cache
X-Request-Id: 069fcacb-fcad-4c5f-a2ba-750d4c6dea81
X-Runtime: 0.007105
2016-03-27 12:37:20 ERROR 404: Not Found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment