check-routeros-update: support installing updates automatically if seen in neighbor list

This commit is contained in:
Christian Hesse 2020-11-01 21:48:03 +01:00
parent 7f356d76bf
commit 98c132105d
6 changed files with 19 additions and 5 deletions

View file

@ -7,8 +7,9 @@
# https://git.eworm.de/cgit/routeros-scripts/about/doc/check-routeros-update.md
:global Identity;
:global SafeUpdateUrl;
:global SafeUpdateNeighbor;
:global SafeUpdatePatch;
:global SafeUpdateUrl;
:global SentRouterosUpdateNotification;
:global DeviceInfo;
@ -57,6 +58,15 @@
$DoUpdate;
}
:if ($SafeUpdateNeighbor = true && [ :len [ / ip neighbor find where \
version=($Update->"latest-version" . " (" . $Update->"channel" . ")") ] ] > 0) do={
$LogPrintExit info ("Seen a neighbor running version " . $Update->"latest-version" . ", updating...") false;
$SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \
("Seen a neighbor running version " . $Update->"latest-version" . " from " . $Update->"channel" . \
", updating on " . $Identity . "...") "" "true";
$DoUpdate;
}
:if ([ :len $SafeUpdateUrl ] > 0) do={
:local Result;
:do {

View file

@ -34,9 +34,10 @@ Configuration is required only if you want to control update process with
safe versions from a web server. The configuration goes to
`global-config-overlay`, this is the parameter:
* `SafeUpdateNeighbor`: install updates automatically if seen in neighbor list
* `SafeUpdatePatch`: install patch updates automatically
* `SafeUpdateUrl`: url to check for safe update, the channel (`long-term`,
`stable` or `testing`) is appended
* `SafeUpdatePatch`: install patch updates automatically
Usage and invocation
--------------------

View file

@ -8,7 +8,7 @@
# Make sure all configuration properties are up to date and this
# value is in sync with value in script 'global-functions'!
:global GlobalConfigVersion 35;
:global GlobalConfigVersion 36;
# This is used for DNS and backup file.
:global Domain "example.com";
@ -62,6 +62,8 @@
#:global SafeUpdateUrl "https://example.com/ros/safe-update/";
# Allow to install patch updates automatically.
:global SafeUpdatePatch false;
# Allow to install updates automatically if seen in neighbor list.
:global SafeUpdateNeighbor false;
# These thresholds control when to send health notification
# on temperature and voltage.

View file

@ -9,7 +9,7 @@
# Make sure all configuration properties are up to date and this
# value is in sync with value in script 'global-functions'!
# Comment or remove to disable change notifications.
:global GlobalConfigVersion 35;
:global GlobalConfigVersion 36;
# Copy configuration from global-config here and modify it.

View file

@ -39,4 +39,5 @@
33="Added configurable deviation on health temperature recovery threshold against notification flooding.";
34="Introduced script 'ospf-to-leds' to visualize OSPF instance state via LEDs.";
35="Implemented visual feedback for 'mode-button' with configurable LED.";
36="Added support for installing updates automatically if seen in neighbor list.";
};

View file

@ -8,7 +8,7 @@
# https://git.eworm.de/cgit/routeros-scripts/about/
# expected configuration version
:global ExpectedConfigVersion 35;
:global ExpectedConfigVersion 36;
# global variables not to be changed by user
:global GlobalFunctionsReady false;