I get a script error only when running a script during startup. When it runs on a scheduled run after, it is fine. The error is:
script,error router atl: script error: action timed out - try again, if error continues contact MikroTik support and send a supout file (13)
The script is as follows:
:local maticuser "user"
:local maticpass "pass"
:local matichost "host"
:local currentIPFile disk1/dnsomatic-current-ipv4.txt
:local logFile disk1/dnsomatic-log.txt
:global dnsomaticPreviousIP
:log info "DNSoMatic: fetching current IP"
:do {
/tool fetch url="http://myip.dnsomatic.com/" mode=http dst-path=$currentIPFile
} on-error={ :local error "DNSoMatic: failed to get IP"; :log error $error; :error $error }
:local currentIP [/file get $currentIPFile contents]
:if ($currentIP != $dnsomaticPreviousIP) do={
:log info "DNSoMatic: new=$currentIP, old=$dnsomaticPreviousIP, trying update"
:do {
/tool fetch url="http://updates.dnsomatic.com/nic/update\3Fmyip=$currentIP&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG&hostname=$matichost" user=$maticuser password=$maticpass mode=http dst-path=$logFile
} on-error={ :local error "DNSoMatic: failed to update"; :log error $error; :error $error }
:log info ("DNSoMatic: response: " . [/file get $logFile contents])
:log info "DNSoMatic: new=$currentIP, old=$dnsomaticPreviousIP"
:set dnsomaticPreviousIP $currentIP
} else={
:log info "DNSoMatic: no change"
}
This runs on as schedule from startup and every 15 minutes. I’ve tried a delay of 30s, 5m, etc but it will still error out the first time and only the first time.
It always times out at the fetch line, it does log this right before:
:log info "DNSoMatic: new=$currentIP, old=$dnsomaticPreviousIP, trying update"
It does not hit my error catch.
Any ideas on how to make this script work on startup with erroring?