diff options
author | Christian Hesse <mail@eworm.de> | 2019-07-24 10:59:53 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2019-07-24 11:01:45 +0200 |
commit | 9e3ee77a4a18badb17dfe5d199d40717cfc6036a (patch) | |
tree | 25d23730f9a58ec6d67b747b3f693a740b7a014a /check-routeros-update | |
parent | 6699545157e0ecdcdefdad0d6f133bf890612c9b (diff) |
check-routeros-update: get values into array
Diffstat (limited to 'check-routeros-update')
-rw-r--r-- | check-routeros-update | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/check-routeros-update b/check-routeros-update index 104567e..cae9212 100644 --- a/check-routeros-update +++ b/check-routeros-update @@ -10,7 +10,7 @@ :global SendNotification; -:local Update do={ +:local DoUpdate do={ :if ([ / system script print count-only where name="packages-update" ] > 0) do={ / system script run packages-update; } else={ @@ -28,11 +28,9 @@ } / system package update check-for-updates without-paging; -:local InstalledVersion [ / system package update get installed-version ]; -:local LatestVersion [ / system package update get latest-version ]; +:local Update [ / system package update get ]; -:if ($InstalledVersion != $LatestVersion) do={ - :local Channel [ / system package update get channel ]; +:if ($Update->"installed-version" != $Update->"latest-version") do={ :local BoardName [ / system resource get board-name ]; :local Model [ / system routerboard get model ]; :local SerialNumber [ / system routerboard get serial-number ]; @@ -41,32 +39,32 @@ :local Result; :do { :set Result [ / tool fetch check-certificate=yes-without-crl \ - ($SafeUpdateUrl . $Channel . "?installed=" . $InstalledVersion . \ - "&latest=" . $LatestVersion) output=user as-value ]; + ($SafeUpdateUrl . $Update->"channel" . "?installed=" . $Update->"installed-version" . \ + "&latest=" . $Update->"latest-version") output=user as-value ]; } on-error={ - :log warning ("Failed receiving safe version for " . $Channel . "."); + :log warning ("Failed receiving safe version for " . $Update->"channel" . "."); } - :if ($Result->"status" = "finished" && $Result->"data" = $LatestVersion) do={ - :log info ("Version " . $LatestVersion . " is considered safe, updating..."); + :if ($Result->"status" = "finished" && $Result->"data" = $Update->"latest-version") do={ + :log info ("Version " . $Update->"latest-version" . " is considered safe, updating..."); $SendNotification ("RouterOS update") \ - ("Version " . $LatestVersion . " is considered safe for " . $Channel . \ + ("Version " . $Update->"latest-version" . " is considered safe for " . $Update->"channel" . \ ", updating on " . $Identity . "..."); - $Update; + $DoUpdate; } } :if ([ / system script job print count-only where script="check-routeros-update" parent~"." ] > 0) do={ - :put ("Do you want to install RouterOS version " . $LatestVersion . "? [y/N]"); + :put ("Do you want to install RouterOS version " . $Update->"latest-version" . "? [y/N]"); :if ([ :terminal inkey timeout=60 ] = 121) do={ - $Update; + $DoUpdate; } else={ :put "Canceled..."; } } - :if ($SentRouterosUpdateNotification = $LatestVersion) do={ + :if ($SentRouterosUpdateNotification = $Update->"latest-version") do={ :log info ("Already sent the RouterOS update notification for version " . \ - $LatestVersion . "."); + $Update->"latest-version" . "."); :error "Already sent notification."; } @@ -76,9 +74,9 @@ "Model: " . $Model . "\n" . \ "Serial number: " . $SerialNumber . "\n" . \ "Hostname: " . $Identity . "\n" . \ - "Channel: " . $Channel . "\n" . \ - "Installed: " . $InstalledVersion . "\n" . \ - "Available: " . $LatestVersion . "\n\n" .\ - "https://mikrotik.com/download/changelogs/" . $Channel . "-release-tree"); - :set SentRouterosUpdateNotification $LatestVersion; + "Channel: " . $Update->"channel" . "\n" . \ + "Installed: " . $Update->"installed-version" . "\n" . \ + "Available: " . $Update->"latest-version" . "\n\n" .\ + "https://mikrotik.com/download/changelogs/" . $Update->"channel" . "-release-tree"); + :set SentRouterosUpdateNotification ($Update->"latest-version"); } |