aboutsummaryrefslogtreecommitdiffstats
path: root/firmware-upgrade-reboot.rsc
diff options
context:
space:
mode:
Diffstat (limited to 'firmware-upgrade-reboot.rsc')
-rw-r--r--firmware-upgrade-reboot.rsc24
1 files changed, 15 insertions, 9 deletions
diff --git a/firmware-upgrade-reboot.rsc b/firmware-upgrade-reboot.rsc
index 169a2e0..e3ca55b 100644
--- a/firmware-upgrade-reboot.rsc
+++ b/firmware-upgrade-reboot.rsc
@@ -1,17 +1,18 @@
#!rsc by RouterOS
# RouterOS script: firmware-upgrade-reboot
-# Copyright (c) 2022-2024 Christian Hesse <mail@eworm.de>
-# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
+# Copyright (c) 2022-2025 Christian Hesse <mail@eworm.de>
+# https://rsc.eworm.de/COPYING.md
#
-# requires RouterOS, version=7.13
+# requires RouterOS, version=7.15
#
# install firmware upgrade, and reboot
-# https://git.eworm.de/cgit/routeros-scripts/about/doc/firmware-upgrade-reboot.md
+# https://rsc.eworm.de/doc/firmware-upgrade-reboot.md
-:global GlobalFunctionsReady;
-:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-
-:do {
+:local ExitOK false;
+:onerror Err {
+ :global GlobalConfigReady; :global GlobalFunctionsReady;
+ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
+ do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50;
:local ScriptName [ :jobname ];
:global LogPrint;
@@ -19,6 +20,7 @@
:global VersionToNum;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -26,10 +28,12 @@
:if ($RouterBoard->"current-firmware" = $RouterBoard->"upgrade-firmware") do={
$LogPrint info $ScriptName ("Current and upgrade firmware match with version " . \
$RouterBoard->"current-firmware" . ".");
+ :set ExitOK true;
:error true;
}
:if ([ $VersionToNum ($RouterBoard->"current-firmware") ] > [ $VersionToNum ($RouterBoard->"upgrade-firmware") ]) do={
$LogPrint info $ScriptName ("Different firmware version is available, but it is a downgrade. Ignoring.");
+ :set ExitOK true;
:error true;
}
@@ -51,4 +55,6 @@
$LogPrint info $ScriptName ("Firmware upgrade successful, rebooting.");
/system/reboot;
-} on-error={ }
+} do={
+ :global ExitError; $ExitError $ExitOK [ :jobname ] $Err;
+}