2019-02-14 19:49:05 +00:00
|
|
|
#!rsc
|
|
|
|
# RouterOS script: capsman-rolling-upgrade
|
2020-01-01 16:00:39 +00:00
|
|
|
# Copyright (c) 2018-2020 Christian Hesse <mail@eworm.de>
|
2019-02-14 19:49:05 +00:00
|
|
|
# Michael Gisbers <michael@gisbers.de>
|
2020-06-19 20:17:42 +00:00
|
|
|
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
|
2019-02-14 19:49:05 +00:00
|
|
|
#
|
|
|
|
# upgrade CAPs one after another
|
2020-03-27 20:40:16 +00:00
|
|
|
# https://git.eworm.de/cgit/routeros-scripts/about/doc/capsman-rolling-upgrade.md
|
2019-02-14 19:49:05 +00:00
|
|
|
|
2020-04-03 15:26:35 +00:00
|
|
|
:global LogPrintExit;
|
2019-12-05 08:50:44 +00:00
|
|
|
:global ScriptLock;
|
|
|
|
|
|
|
|
$ScriptLock "capsman-rolling-upgrade";
|
|
|
|
|
2019-02-14 19:49:05 +00:00
|
|
|
:local InstalledVersion [ / system package update get installed-version ];
|
|
|
|
|
|
|
|
:local RemoteCapCount [ /caps-man remote-cap print count-only ];
|
|
|
|
:if ($RemoteCapCount > 0) do={
|
|
|
|
:local Delay (600 / $RemoteCapCount);
|
|
|
|
:if ($Delay > 120) do={ :set Delay 120; }
|
|
|
|
:foreach RemoteCap in=[ / caps-man remote-cap find where version!=$InstalledVersion ] do={
|
2019-07-08 13:49:00 +00:00
|
|
|
:local RemoteCapVal [ / caps-man remote-cap get $RemoteCap ];
|
2020-04-03 15:26:35 +00:00
|
|
|
$LogPrintExit info ("Starting upgrade for " . $RemoteCapVal->"name" . \
|
|
|
|
" (" . $RemoteCapVal->"identity" . ")...") false;
|
2019-08-29 05:54:00 +00:00
|
|
|
/ caps-man remote-cap upgrade [ find where name=$RemoteCapVal->"name" ];
|
2019-02-14 19:49:05 +00:00
|
|
|
:delay ($Delay . "s");
|
|
|
|
}
|
|
|
|
}
|