/tool fetch url="https://wtfismyip.com/text" mode=https ascii=yes keep-result=yes dst-path=myfile
:global myip [ :file get myfile contents ]
:global ip [ :pick [ :tostr "$myip" ] 0 [ :find "$myip" "\n" ] ]
:put "$ip"
:global ddnsuser "USERNAME"
:global ddnspass "PASSWORD"
:global theinterface "ether1"
:global ddnshost "DDNS DOMAIN"
:global ipddns [:resolve $ddnshost];
:global ipfresh $ip
:if ([ :typeof $ipfresh ] = nil ) do={
:log info ("dynu: No ip address on $theinterface .")
} else={
:for i from=( [:len $ipfresh] - 1) to=0 do={
:if ( [:pick $ipfresh $i] = "/") do={
:set ipfresh [:pick $ipfresh 0 $i];
}
}
:if ($ipddns != $ipfresh) do={
:log info ("dynu: IP-dynu = $ipddns")
:log info ("dynu: IP-Fresh = $ipfresh")
:log info "dynu: Update IP needed, Sending UPDATE...!"
:global str "/nic/update?hostname=$ddnshost&myip=$ipfresh"
/tool fetch address=api.dynu.com src-path=$str mode=http user=$ddnsuser password=$ddnspass dst-path=("/Dynu.".$ddnshost)
:delay 1
:global str [/file find name="Dynu.$ddnshost"];
/file remove $str
:global ipddns $ipfresh
:log info "dynu: IP updated to---------> $ipfresh!"
} else={
:log info "dynu: dont need changes";
}
}