For retrieve version number from MikroTik:
Why you useless download the file on the board without simply read the value inside the file on the url?
{
Actually the returned data end with \n. If for some reason on future \n is correctly removed, this prevent the script fail.
:local vchannel "stable" ; # can be: [long-term | stable | testing | development]
:local lastv7 ("$([/tool fetch url="https://upgrade.mikrotik.com//routeros/NEWESTa7.$vchannel" as-value output=user]->"data")\n")
:local lastv7ver [:pick $lastv7 0 [:find $lastv7 "_" -1]]
:local currver [/system/package get [find where name="routeros"] version]
:if ($lastv7ver != $currver) do={
:local lastv7build [:totime [:pick $lastv7 ([:find $lastv7 "_" -1] + 1) [:find $lastv7 "\n" -1]]]
:local currtime [:timestamp]
:local daysdiff ($currtime - $lastv7build)
:local vdays 30d
:put "The Installed version is $currver and the Latest version $lastv7ver is old $daysdiff days"
:if ($daysdiff > $vdays) do={
:put "Performing update: Latest is older than $vdays days"
# /sys pack up; check; in
} else={
:put "Not updated: Waiting Latest for be older than $vdays days"
}
} else={
:put "The Installed and Latest version are the same $currver"
}
}