Skip to content

Instantly share code, notes, and snippets.

@tree-s
Last active August 21, 2024 00:10
Show Gist options
  • Save tree-s/d8af573fb5b5d232424c5d588d7b8ea7 to your computer and use it in GitHub Desktop.
Save tree-s/d8af573fb5b5d232424c5d588d7b8ea7 to your computer and use it in GitHub Desktop.
Applescript DDNS updater
property hostname : "__domain_name__.dyndns.org"
property dyndnsUsername : "__username__"
property dyndnsPassword : "__userpassword__"
property myLastIP : missing value
property myCurrentIP : missing value
property retryPeriodSeconds : 300
on idle
my updateDynDNS(myLastIP)
set myLastIP to result
return retryPeriodSeconds
end idle
on updateDynDNS(oldIP)
try
do shell script "dig +short myip.opendns.com @resolver1.opendns.com"
set myCurrentIP to result
on error errText number errNum
log {errText, errNum}
set myCurrentIP to missing value
end try
set myExternalIP to myCurrentIP
if myExternalIP is not equal to oldIP then
-- update dyndns
do shell script "curl -v -k -u " & dyndnsUsername & ":" & dyndnsPassword & " \"https://members.dyndns.org/nic/update?hostname=" & hostname & "&myip=" & myExternalIP & "\" >/dev/null"
return myExternalIP
else
return oldIP
end if
end updateDynDNS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment