aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2020-07-07 00:21:47 +0200
committerGravatar Christian Hesse <mail@eworm.de>2020-07-07 00:21:47 +0200
commit2907dbe18f0ac17b9fcae5df56b673d129839d66 (patch)
tree8a7fb322a494f2186abf5ab4c1a2cdae34d91b28
parentd8b2055fbce578884dfac36fca372101c14cd8af (diff)
check-routeros-update: support installing patch updates automatically
-rw-r--r--check-routeros-update14
-rw-r--r--global-config2
2 files changed, 16 insertions, 0 deletions
diff --git a/check-routeros-update b/check-routeros-update
index 9109e1d..931c32f 100644
--- a/check-routeros-update
+++ b/check-routeros-update
@@ -8,12 +8,14 @@
:global Identity;
:global SafeUpdateUrl;
+:global SafeUpdatePatch;
:global SentRouterosUpdateNotification;
:global DeviceInfo;
:global LogPrintExit;
:global ScriptFromTerminal;
:global SendNotification;
+:global VersionToNum;
:local DoUpdate do={
:if ([ / system script print count-only where name="packages-update" ] > 0) do={
@@ -43,6 +45,18 @@
}
:if ($Update->"installed-version" != $Update->"latest-version") do={
+ :local NumInstalled [ $VersionToNum ($Update->"installed-version") ];
+ :local NumLatest [ $VersionToNum ($Update->"latest-version") ];
+
+ :if ($SafeUpdatePatch = true && $NumInstalled < $NumLatest && \
+ ($NumInstalled & 0xffff0000) = ($NumLatest & 0xffff0000)) do={
+ $LogPrintExit info ("Version " . $Update->"latest-version" . " is a patch release, updating...") false;
+ $SendNotification ("RouterOS update") \
+ ("Version " . $Update->"latest-version" . " is a patch update for " . $Update->"channel" . \
+ ", updating on " . $Identity . "...") "" "true";
+ $DoUpdate;
+ }
+
:if ([ :len $SafeUpdateUrl ] > 0) do={
:local Result;
:do {
diff --git a/global-config b/global-config
index 5f22b6b..3976e69 100644
--- a/global-config
+++ b/global-config
@@ -46,6 +46,8 @@
# The configured channel (bugfix, current, release-candidate) is appended.
:global SafeUpdateUrl "";
#:global SafeUpdateUrl "https://example.com/ros/safe-update/";
+# Allow to install patch updates automatically.
+:global SafeUpdatePatch false;
# These thresholds control when to send health notification
# on temperature and voltage.