aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2022-03-22 22:33:46 +0100
committerGravatar Christian Hesse <mail@eworm.de>2022-03-25 11:24:36 +0100
commitd21cd2271f0032984d23e1c5b6cfe8f2ade59363 (patch)
tree6e1dd7e647b6f5a13b9e1bef0e99c19054f9f5b7
parent0695c9931824bd9f1a1b858cce2e06934738d285 (diff)
capsman-download-packages: get info from log
Relying on older packages in local storage may be problematic due to size constraints. Let's check the log for required packages. (cherry picked from commit c4a5f8787a57836bb3e8463cdda6cab6043b0169)
-rw-r--r--capsman-download-packages19
-rw-r--r--doc/capsman-download-packages.md15
2 files changed, 22 insertions, 12 deletions
diff --git a/capsman-download-packages b/capsman-download-packages
index 333f01b..64b6304 100644
--- a/capsman-download-packages
+++ b/capsman-download-packages
@@ -53,6 +53,25 @@ $WaitFullyConnected;
}
}
+:if ($Updated = false && [ / system resource get uptime ] < 2m) do={
+ $LogPrintExit2 info $0 ("No packages downloaded, yet. Delaying for logs.") false;
+ :delay 2m;
+}
+
+:foreach Log in=[ / log find where topics=({"caps", "error"}) \
+ message~("upgrade status: failed, failed to download file '.*-" . $InstalledVersion . "-.*\\.npk', no such file") ] do={
+ :local Message [ / log get $Log message ];
+ :local Package [ :pick $Message \
+ ([ :find $Message "'" ] + 1) \
+ [ :find $Message ("-" . $InstalledVersion . "-") ] ];
+ :local Arch [ :pick $Message \
+ ([ :find $Message ("-" . $InstalledVersion . "-") ] + 2 + [ :len $InstalledVersion ]) \
+ [ :find $Message ".npk" ] ];
+ :if ([ $DownloadPackage $Package $InstalledVersion $Arch $PackagePath ] = true) do={
+ :set Updated true;
+ }
+}
+
:if ($Updated = true) do={
:if ([ :len [ / system script find where name="capsman-rolling-upgrade" ] ] > 0) do={
/ system script run capsman-rolling-upgrade;
diff --git a/doc/capsman-download-packages.md b/doc/capsman-download-packages.md
index 9cee6e6..bac8a3c 100644
--- a/doc/capsman-download-packages.md
+++ b/doc/capsman-download-packages.md
@@ -26,18 +26,9 @@ Optionally add a scheduler to run after startup:
/ system scheduler add name=capsman-download-packages on-event="/ system script run capsman-download-packages;" start-time=startup;
-Only packages available in older version are downloaded. For initial setup
-place the required packages to CAPsMAN package path (see
-`/ caps-man manager`). The packages can be downloaded from device with
-function `$DownloadPackage`, use something like this to download latest
-packages to directory `routeros`:
-
- $DownloadPackage system "" arm routeros;
- $DownloadPackage security "" arm routeros;
- [...]
- $DownloadPackage system "" mipsbe routeros;
- $DownloadPackage security "" mipsbe routeros;
- [...]
+Packages available in local storage in older version are downloaded
+unconditionally. The script tries to download missing packages by guessing
+from system log.
Usage and invocation
--------------------