Community discussions

MikroTik App
 
OKNET
Member
Member
Topic Author
Posts: 353
Joined: Mon Jun 22, 2015 9:22 am

CAPsMAN how to keep .npk updated ? (Cap Manager auto-update)

Mon Feb 19, 2018 11:15 am

With CAP "require same version" upgrade policy, how can I keep .npk files for APs, AUTOMATICALLY updated to same version (latest) before I update manager ?

Thanks
Last edited by OKNET on Wed May 02, 2018 11:28 am, edited 1 time in total.
 
gustavomam
Trainer
Trainer
Posts: 287
Joined: Tue Jul 23, 2013 6:29 pm
Location: Spain
Contact:

Re: CAPsMAN how to keep .npk updated ?

Tue Mar 13, 2018 5:34 pm

Hi
I don't understand your request.

If you want to use upgrade policy require same version, is because you will put in manager files the latest version of RouterOS
/caps-man manager
set enabled=yes package-path=/upgrade/routeros-mipsbe-6.41.3.npk

Important create a folder where you will upload the file, it won't work from root folder.

Regards.
 
OKNET
Member
Member
Topic Author
Posts: 353
Joined: Mon Jun 22, 2015 9:22 am

Re: CAPsMAN how to keep .npk updated ?

Wed May 02, 2018 11:27 am

Basically I need to update .npk file for APs AUTOMATICALLY before Manager upgrade.
Copying and mixing parts from some sources and wiki I'm ended with this simple working script :


############# create ap file directory: "apdir"

############# create the update schedule:

/system scheduler
add name=AutoUpdate start-date=apr/25/1970 start-time=04:00:00 interval=1d on-event=Update

#############   name the following script: "Update"   

/system package update
check-for-updates once

:delay 3s;

:if ( [get status] = "New version is available") do={ 

:local newVer [get latest-version]
/tool fetch address="download.mikrotik.com" mode=https src-path="/routeros/$newVer/routeros-mipsbe-$newVer.npk" dst-path="/apdir"
/tool e-mail send to="user@domain" subject="Upgrading RouterOS on router $[/system identity get name]" body="Upgrading RouterOS on router $[/system identity get name] from $[/system package update get installed-version] to $[/system package update get latest-version] (channel:$[/system package update get channel])"
   
:delay 5s;
   
install

} else={

/system routerboard

:if ( [get current-firmware] != [get upgrade-firmware]) do={ 

/tool e-mail send to="user@domain" subject="Upgrading firmware on router $[/system identity get name]" body="Upgrading firmware on router $[/system identity get name] from $[/system routerboard get current-firmware] to $[/system routerboard get upgrade-firmware]"
      
:delay 5s;

upgrade

:delay 5s;

/system reboot

}
}
Script does also a firmware check and upgrade if package is already updated.
I don't know if pauses are really needed...
Once manager has rebooted with newest version, the relative file for APs is present on the "apdir" directory (that must be declared in /caps-man manager set package-path) and all APs will upgrade accordingly.
The downloaded file must match the APs architecture that can be different from Manager one.

Any suggestion or modification is well accepted :D
Last edited by OKNET on Thu May 03, 2018 9:01 pm, edited 1 time in total.
 
User avatar
Petri
Frequent Visitor
Frequent Visitor
Posts: 97
Joined: Mon Dec 05, 2016 1:55 pm
Location: Helsinki, Finland
Contact:

Re: CAPsMAN how to keep .npk updated ? (Cap Manager auto-update)

Thu May 03, 2018 10:43 am

I am wary of automatic upgrades, I have been bitten more than once. I am no scripting guru either, that's mostly why took a look at your script. Two observations:
  1. The last closing brace doesn't have a pair.
  2. With your logic the firmware will be updated on the next run (24h hours later) - unless there is a new package update. I don't follow the reasoning for the else clause.
 
OKNET
Member
Member
Topic Author
Posts: 353
Joined: Mon Jun 22, 2015 9:22 am

Re: CAPsMAN how to keep .npk updated ? (Cap Manager auto-update)

Thu May 03, 2018 8:56 pm

Very probably I'm less expert in scripting than you... :D
A said , I've copied some sources, and that sequence was done that way , probably , yes , it can be modified to do a firmware check and upgrade once routerboard has rebooted after a package upgrade (so I don't bother so much....new package today ? we will check firmware tomorrow..... :lol: )
Unless it is so important to have firmware upgraded before package , someone experienced will tell us.

Braces are paired this way:

else={
/system routerboard
:if ( [get current-firmware] != [get upgrade-firmware]) do={

blablabla

}
}


About automatic update, yes one has to rely in mikrotik staff hard work.
As the main goal is to have APs .npk file updated before the manager is (mandatory in case of "require same version") , it can be ran manually when needed, simply by omitting schedule.
 
stormeporm
newbie
Posts: 44
Joined: Sun Dec 30, 2012 12:39 pm

Re: CAPsMAN how to keep .npk updated ? (Cap Manager auto-update)

Mon Dec 21, 2020 1:24 pm

I've added some code to remove the old file so you wont accumulate npk's until your disk is full
Execute it before you download the new npk

:local oldNpk [file find name ~"routeros-"]
/file remove $oldNpk

Who is online

Users browsing this forum: No registered users and 16 guests