Created
October 10, 2009 23:28
-
-
Save zed9h/207239 to your computer and use it in GitHub Desktop.
DreamHost Dynamic DNS script for OpenWRT
This file contains hidden or 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/sh | |
# DreamHost Dynamic DNS script for OpenWRT | |
# by Rodrigo Damazio <[email protected]> | |
# updated by Kyle Bassett <[email protected]> | |
# ported by Carlo 'zED' Caputo <[email protected]> | |
[email protected] | |
PASS=xxxxxx | |
ACCOUNT=123456 | |
HOST=www | |
DOMAIN=9hells.org | |
RECTYPE=A | |
IFACE=ppp0 | |
# to use this record update script, first create a record at: | |
# https://panel.dreamhost.com/index.cgi?tree=domain.manage¤t_step=Index&next_step=ShowZone&domain=$DOMAIN | |
RECVAL=`ifconfig $IFACE | sed -n 's/.*inet addr: *\([0-9.]*\) .*/\1/p'` | |
ACTVAL=`nslookup $HOST.$DOMAIN | sed -n 's/Address.*: *//p' | tail -1` | |
test "$RECVAL" = "$ACTVAL" && exit | |
HEADER=`mktemp -t` | |
rm /var/tmp.* # XXX hardcoded, cleanup loose mktemp | |
CURL_OPT="-m 15 --retry 3" | |
curl $CURL_OPT -s -k -D $HEADER "https://panel.dreamhost.com/" >/dev/null || exit | |
COOKIE="`sed -n 's/.*\(Cookie:.*\)/\1/p' $HEADER`" | |
echo "$COOKIE" | |
rm $HEADER | |
curl $CURL_OPT -s -k -H "$COOKIE" -d "Nscmd=Nlogin&username=$USER&password=$PASS" "https://panel.dreamhost.com/index.cgi" >/dev/null || exit | |
curl $CURL_OPT -s -k -H "$COOKIE" "https://panel.dreamhost.com/index.cgi?active_account=$ACCOUNT" >/dev/null || exit | |
curl $CURL_OPT -s -k -H "$COOKIE" "https://panel.dreamhost.com/index.cgi?tree=domain.manage¤t_step=Index&next_step=ShowZone&domain=$DOMAIN" | | |
grep "next_step=ShowRecord&editname=$HOST&editzone=$DOMAIN&edittype=$RECTYPE" | # grep -v `echo $RECVAL | sed 's/\./%2E/g'` | | |
sed 's/"><img.*//' | sed 's/.*href="//' | xargs curl $CURL_OPT -s -k -D $HEADER -H "$COOKIE" >/dev/null || exit | |
curl $CURL_OPT -s -k -H "$COOKIE" \ | |
-d "tree=domain.manage¤t_step=ShowRecord&next_step=EditRecord&newname=$HOST&newtype=$RECTYPE&newvalue=$RECVAL&newcomment=" \ | |
"https://panel.dreamhost.com/" | sed -n 's/.*\(Success!\).*/\1/p' || exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment