From c4a5f8787a57836bb3e8463cdda6cab6043b0169 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 22 Mar 2022 22:33:46 +0100 Subject: 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. --- capsman-download-packages | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'capsman-download-packages') diff --git a/capsman-download-packages b/capsman-download-packages index 6f4642c..ac5ec0e 100644 --- a/capsman-download-packages +++ b/capsman-download-packages @@ -50,6 +50,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; -- cgit v1.2.3-70-g09d2