Skip to content

Instantly share code, notes, and snippets.

@ntalbott
Created August 25, 2012 19:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save ntalbott/3469900 to your computer and use it in GitHub Desktop.
Save ntalbott/3469900 to your computer and use it in GitHub Desktop.
A DNSimple DDNS updater for DD-WRT
#!/bin/sh
EMAIL=
API_TOKEN=
DOMAIN_ID=
RECORD_ID=
IP=$( nvram get wan_ipaddr )
OUTPUT='-s -o /dev/null'
usage()
{
cat << EOF
usage: $(basename $0) -e EMAIL -t APITOKEN -d DOMAINID -r RECORDID
OPTIONS:
-v Be verbose
-h Show this message
EOF
}
while getopts "he:t:d:r:v" OPTION
do
case $OPTION in
h)
usage
exit 1
;;
e)
EMAIL=$OPTARG
;;
t)
API_TOKEN=$OPTARG
;;
d)
DOMAIN_ID=$OPTARG
;;
r)
RECORD_ID=$OPTARG
;;
v)
OUTPUT='-s -i -v -o /dev/stderr'
;;
?)
usage
exit 1
;;
esac
done
if [[ -z $EMAIL ]] || [[ -z $API_TOKEN ]] || [[ -z $DOMAIN_ID ]] || [[ -z $RECORD_ID ]]
then
usage
exit 1
fi
echo "Updating with IP: $IP"
RESULT=$(curl -H "Accept: application/json" \
-H "X-DNSimple-Token: $EMAIL:$API_TOKEN" \
-H "Content-Type: application/json" \
-X PUT https://DNSimple.com/domains/$DOMAIN_ID/records/$RECORD_ID.json \
-d "{\"record\":{\"content\":\"$IP\"}}" \
-k \
-w "%{http_code}" \
$OUTPUT)
if [ "$RESULT" = "200" ]; then
exit 0
else
exit 1
fi
@banderson5144
Copy link

Hey this looks really good. Do you just go into the administration tab, go to commands, and save as a startup script?

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