[admin@test] > /system package update set channel=long-term
[admin@test] > :put [/system package update check-for-updates as-value]
channel=long-term;installed-version=6.48.4;latest-version=6.48.5;status=New version is available
This can be saved to an variable, and then you can test: if installed-version!=latest-version do something
This is not about doing it automatically.
All I want to know from my script is whether or not upgrade has been performed already and just a reboot is pending.
When the RouterOS upgrade, there will always be a boot firmware upgrade, and when there are no new RouterOS upgrade, there will not be a boot firmware upgrade, since the now follow each other 100%. Or I am wrong?
I still not understand what the goal is.
When your script sees a new updated RouterOS, then script upgrade it.
After upgrade/reboot, always upgrade firmware/reboot.
Not sure what you like to test for and why.
Would you like to test if boot firmware is change from before to after upgrade?
As I have written before, script should never ever do an upgrade by it self just because there there are a new RouterOS or boot firmware.
Test locally, test more, and even som more, read forum, wait some weeks ++. Then you can make a script start by looking at a web page and if web page says yes, do the upgrade.
What’s the added value besides the fact you DO have the ability to know that Upgrade+Reboot is needed (or possible instead of needed, depending on who’s looking at it) ?
Upgrade and Reboot is to be considered here as an entity. I agree it should be possible to have those two as separate status, but what’s the point ?
Not OP but I’ll add on to this.
Not everybody uses their routers the same way so it doesn’t really matter what the point of doing it is. The point is to learn how to do it.
In my case I’m going to have a lot of these routers in the field and I don’t want to have to log into each of them individually to see if a reboot is pending.
I’ll create a script that reports to my monitoring system which will tell me if a unit needs a reboot.
To answer OP’s question, there’s no elegant way to do it, but there is this:
{
/system/routerboard/print file=test;
:global x [/file get test.txt contents];
:if ([:find $x "please reboot"]) do={:put "yes";}
}
Note that $x in this case will be type nil if “please reboot” is not found, otherwise it will be number.