2020-09-18 09:00:27 +00:00
|
|
|
#!rsc by RouterOS
|
2019-02-14 19:49:05 +00:00
|
|
|
# RouterOS script: capsman-rolling-upgrade
|
2023-01-02 22:33:49 +00:00
|
|
|
# Copyright (c) 2018-2023 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
|
|
|
|
2021-02-22 14:14:10 +00:00
|
|
|
:local 0 "capsman-rolling-upgrade";
|
2021-02-18 13:52:47 +00:00
|
|
|
:global GlobalFunctionsReady;
|
|
|
|
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
|
|
|
|
2021-02-22 14:14:10 +00:00
|
|
|
:global LogPrintExit2;
|
2019-12-05 08:50:44 +00:00
|
|
|
:global ScriptLock;
|
|
|
|
|
2021-02-22 18:52:20 +00:00
|
|
|
$ScriptLock $0;
|
2019-12-05 08:50:44 +00:00
|
|
|
|
2022-05-10 12:40:08 +00:00
|
|
|
:local InstalledVersion [ /system/package/update/get installed-version ];
|
2019-02-14 19:49:05 +00:00
|
|
|
|
2022-05-10 12:40:08 +00:00
|
|
|
:local RemoteCapCount [ :len [ /caps-man/remote-cap/find ] ];
|
2019-02-14 19:49:05 +00:00
|
|
|
:if ($RemoteCapCount > 0) do={
|
|
|
|
:local Delay (600 / $RemoteCapCount);
|
|
|
|
:if ($Delay > 120) do={ :set Delay 120; }
|
2022-05-10 12:40:08 +00:00
|
|
|
:foreach RemoteCap in=[ /caps-man/remote-cap/find where version!=$InstalledVersion ] do={
|
|
|
|
:local RemoteCapVal [ /caps-man/remote-cap/get $RemoteCap ];
|
2021-04-29 13:10:08 +00:00
|
|
|
:if ([ :len $RemoteCapVal ] > 1) do={
|
|
|
|
$LogPrintExit2 info $0 ("Starting upgrade for " . $RemoteCapVal->"name" . \
|
2020-04-03 15:26:35 +00:00
|
|
|
" (" . $RemoteCapVal->"identity" . ")...") false;
|
2022-05-10 12:40:08 +00:00
|
|
|
/caps-man/remote-cap/upgrade $RemoteCap;
|
2021-04-29 13:10:08 +00:00
|
|
|
} else={
|
|
|
|
$LogPrintExit2 warning $0 ("Remote CAP vanished, skipping upgrade.") false;
|
|
|
|
}
|
2019-02-14 19:49:05 +00:00
|
|
|
:delay ($Delay . "s");
|
|
|
|
}
|
|
|
|
}
|