Community discussions

MikroTik App
 
User avatar
mrmut
Member Candidate
Member Candidate
Topic Author
Posts: 199
Joined: Mon May 18, 2009 2:10 pm

How to auto upgrade to long term versions of ROS?

Tue Jan 22, 2019 4:18 pm

I am building a network of about 20 Mikrotik devices, so was thinking that setting up auto upgrade is prudent.

However, I would like to skip regular versions, and have the system update only to long term versions of ROS.

I found this upgrade script here: https://wiki.mikrotik.com/wiki/Manual:U ... ic_upgrade
/system package update
check-for-updates once
:delay 3s;
:if ( [get status] = "New version is available") do={ install }
Is there a way to do something like that with script?

The reason I ask is that first time I tried entering the command manually, I got a response that an update is available, regardless the router being set to LT channel. I wouldn't want non LT stuff on production network.

EDIT: when I try entering the
check-for-update once
manually in terminal, it seems that the command gets stuck, I only get
status: finding out latest version...
. Does this work normally in script? (If I issue just
check-for-update
in terminal, I get normal response.)
 
User avatar
vecernik87
Forum Veteran
Forum Veteran
Posts: 882
Joined: Fri Nov 10, 2017 8:19 am

Re: How to auto upgrade to long term versions of ROS?  [SOLVED]

Fri Jan 25, 2019 6:14 am

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
:put [get status]
(in script you don't need the
:put
)
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
/log
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
check-for-updates
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
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: How to auto upgrade to long term versions of ROS?

Fri Jan 25, 2019 8:38 am

Take care of setting up auto upgrade for long term (or any other) releases.
In latest upgrade 6.43.7 -> 6.43.8 and 6.43.10 -> 6,43.11 Mikrotik changed som region settings on the wifi to comply with some county.
This did brake wifi communication for several users. Yes the users has not setup their boxes correct for their country so they did go down.
Mikrotik should not make such change lin long term release, but in new trains and in beta version.

So you should look at how to mass upgrade on commando, not auto upgrade.
Read carefully all release notes.
Wait some days after a new OS is released and see if some gets into trouble.
The do the upgrade.

Just read these two threads to see the problem this change caused.
v6.42.11 [long-term] is released!
v6.43.8 [stable] is released!
 
User avatar
mrmut
Member Candidate
Member Candidate
Topic Author
Posts: 199
Joined: Mon May 18, 2009 2:10 pm

Re: How to auto upgrade to long term versions of ROS?

Fri Jan 25, 2019 10:59 am

So you should look at how to mass upgrade on commando, not auto upgrade.
Read carefully all release notes.
Wait some days after a new OS is released and see if some gets into trouble.
The do the upgrade.
Thanks. In the end, I set up all the routers with auto upgrade scripts on schedule, but disabled them by default, leaving an option to turn them on later.

As for the mass auto-upgrade, did you mean over Dude? Or you had something else in mind?
 
User avatar
mrmut
Member Candidate
Member Candidate
Topic Author
Posts: 199
Joined: Mon May 18, 2009 2:10 pm

Re: How to auto upgrade to long term versions of ROS?

Fri Jan 25, 2019 11:01 am

Thank you very much for the updated script! It looks great, and is exactly what I needed.

It seems that the message on update was some kind of glitch. I updated all other routers, and everything was OK. It might be that I erroneously left the router on wrong channel.
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
:put [get status]
(in script you don't need the
:put
)
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
/log
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
check-for-updates
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

Who is online

Users browsing this forum: netmas and 74 guests