Skip to content

Instantly share code, notes, and snippets.

@166MMX
Created April 19, 2013 19:21
Show Gist options
  • Save 166MMX/5422564 to your computer and use it in GitHub Desktop.
Save 166MMX/5422564 to your computer and use it in GitHub Desktop.
#!/bin/sh
dnsName=
dnsServer=
checkUrl=
refreshUrl=
nsResult=$(nslookup -querytype=A "${dnsName}" "${dnsServer}" \
| sed -n '
/^Address:/ {
s/^.*:\s*// p
}
' \
| tail --lines=1 \
)
checkResult=$(curl --fail --silent --no-keepalive --retry 0 "${checkUrl}" \
| sed -n '
s|.*<body>Current IP Address: \(.*\)</body>.*|\1| p
' \
)
[ "$nsResult" != "$checkResult" ] \
&& curl --fail --silent --no-keepalive --retry 0 "${refreshUrl}" \
1> /dev/null
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment