Skip to content

Instantly share code, notes, and snippets.

@digitaljhelms
Created April 7, 2014 21:42
Show Gist options
  • Save digitaljhelms/10063643 to your computer and use it in GitHub Desktop.
Save digitaljhelms/10063643 to your computer and use it in GitHub Desktop.
DNSimple hostname updater on OS X (prior to Yosemite)
#!/bin/bash
. /etc/rc.common
AUTH_EMAIL='' # dnsimple account email address
AUTH_TOKEN='' # dnsimple api token
DOMAIN_ID='' # domain name or id
RECORD_ID='' # record id to update
IP="`curl http://icanhazip.com/`"
foo ()
{
curl -H "X-DNSimple-Token: $AUTH_EMAIL:$AUTH_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-X PUT \
-d "{\"record\":{\"content\":\"$IP\"}}" \
https://api.dnsimple.com/v1/domains/$DOMAIN_ID/records/$RECORD_ID
}
StartService ()
{
foo
}
# StopService ()
# {
# }
RestartService ()
{
foo
}
RunService "$1"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Description</key>
<string>DNSimple Dynamic Local IP Updater</string>
<key>OrderPreference</key>
<string>None</string>
<key>Provides</key>
<array>
<string>DNSimpleUpdater</string>
</array>
</dict>
</plist>
@digitaljhelms
Copy link
Author

  1. Fork this gist
  2. Edit variables
  3. cd /Library/StartupItems
  4. Clone fork to a directory named "DNSimpleUpdater"
  5. sudo /sbin/SystemStarter start "DNSimpleUpdater"
  6. Verify results on DNSimple website

@digitaljhelms
Copy link
Author

OS X Yosemite removed the SystemStarter executable; this approach has been deprecated and https://gist.github.com/digitaljhelms/a1f1d9e2d8aaa3838571 should be used on systems running OS X Yosemite and higher.

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