command
/system package update check-for-updates once
works on background. It will show you only first output and does not wait for end of process. To retrieve status later in CLI, use command
(in script you don't need the
)
If you want to do this in one step, simply run the command in foreground:
/system package update check-for-updates
This command in my case give following result:
[j****n@JAC-PAVEL-HAP] /system package update> check-for-updates
channel: long-term
current-version: 6.42.11
latest-version: 6.42.11
status: System is already up to date
Now back to your main issue - the code should work as it is but is not ideal. Router remembers which channel is selected and it will look for new versions only from selected channel. If you are set to long-term and your router says there is new version, then most likely there really is new long-term vesion.
for debugging purposes, i would suggest to use command
which will allow you to monitor progress of the script even if you dont run it in CLI.
For example following script will show you all info in log (so no need to do it manually in CLI):
/log warning ("looking for update in channel: " . [/system package update get channel])
/log warning ("current version: " . [/system package update get installed-version])
/system package update check-for-updates
/log warning ("latest version: " . [/system package update get latest-version])
/log warning ("status: " . [/system package update get status])
:if ( [/system package update get status] = "New version is available") do={
/log warning "Will install the update now ..."
# uncomment following line only if you are ready to use the script!
# /system package update install
}
I believe this approach is better as script will not wait for exact 3 seconds as original script. Instead, it will wait indefinitely, until the
is finished. If you wait for exact 3 seconds, there is a chance the result will be not downloaded within that period of time.
Once you are happy with the result. you can uncomment the install command.
However, keep in mind that autoupdate can be dangerous as there may be BC break and the last thing you want is your network getting broken when you are on holidays...
ps: if you are already on 6.42.11 and you are set for long-term channel and still get a "update available" result, please post here what does it exactly show when you do
/system package update check-for-updates