From 74683b3fc8571a684c6a781e2325253eed4736ae Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 14 Feb 2019 20:49:05 +0100 Subject: [PATCH] capsman-download-packages: split off capsman-rolling-upgrade --- capsman-download-packages | 13 +++++-------- capsman-rolling-upgrade | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 capsman-rolling-upgrade diff --git a/capsman-download-packages b/capsman-download-packages index d11dae3..7462699 100644 --- a/capsman-download-packages +++ b/capsman-download-packages @@ -30,13 +30,10 @@ } } -:local RemoteCapCount [ /caps-man remote-cap print count-only ]; -:if ($Updated = true && $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={ - :log debug ("Starting upgrade for CAP " . [ / caps-man remote-cap get $RemoteCap name ] . "..."); - / caps-man remote-cap upgrade $RemoteCap; - :delay ($Delay . "s"); +:if ($Updated = true) do={ + :if ([ / system script print count-only where name="capsman-rolling-upgrade" ] > 0) do={ + / system script run capsman-rolling-upgrade; + } else={ + / caps-man remote-cap upgrade [ find where version!=$InstalledVersion ]; } } diff --git a/capsman-rolling-upgrade b/capsman-rolling-upgrade new file mode 100644 index 0000000..431ac02 --- /dev/null +++ b/capsman-rolling-upgrade @@ -0,0 +1,20 @@ +#!rsc +# RouterOS script: capsman-rolling-upgrade +# Copyright (c) 2018-2019 Christian Hesse +# Michael Gisbers +# +# upgrade CAPs one after another + +: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={ + :local RemoteCapName [ / caps-man remote-cap get $RemoteCap name ]; + :log debug ("Starting upgrade for CAP " . $RemoteCapName . "..."); + / caps-man remote-cap upgrade $RemoteCap; + :delay ($Delay . "s"); + } +}