aboutsummaryrefslogtreecommitdiffstats
path: root/unattended-lte-firmware-upgrade.rsc
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2023-03-07 10:57:42 +0100
committerGravatar Christian Hesse <mail@eworm.de>2023-03-07 22:26:01 +0100
commita832fd04ef085ef7e85000843a8e8fa59ce36dfb (patch)
treec977ca4b5167d8aa07dbe6bfe15fca8f467db0d9 /unattended-lte-firmware-upgrade.rsc
parent1e6e0646e256c4acb9f8470853d0699286af010e (diff)
rename scripts and add file extension ".rsc"change-95
No functional change for the user... The migration is done automatically.
Diffstat (limited to 'unattended-lte-firmware-upgrade.rsc')
-rw-r--r--unattended-lte-firmware-upgrade.rsc45
1 files changed, 45 insertions, 0 deletions
diff --git a/unattended-lte-firmware-upgrade.rsc b/unattended-lte-firmware-upgrade.rsc
new file mode 100644
index 0000000..eac65c3
--- /dev/null
+++ b/unattended-lte-firmware-upgrade.rsc
@@ -0,0 +1,45 @@
+#!rsc by RouterOS
+# RouterOS script: unattended-lte-firmware-upgrade
+# Copyright (c) 2018-2023 Christian Hesse <mail@eworm.de>
+# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
+#
+# schedule unattended lte firmware upgrade
+# https://git.eworm.de/cgit/routeros-scripts/about/doc/unattended-lte-firmware-upgrade.md
+
+:foreach Interface in=[ /interface/lte/find where running ] do={
+ :local Firmware;
+ :local IntName [ /interface/lte/get $Interface name ];
+ :do {
+ :set Firmware [ /interface/lte/firmware-upgrade $Interface once as-value ];
+ } on-error={
+ :log debug ("Could not get latest LTE firmware version for interface " . $IntName . ".");
+ }
+
+ :if ([ :typeof $Firmware ] = "array") do={
+ :if (($Firmware->"installed") != ($Firmware->"latest")) do={
+ :log info ("Scheduling LTE firmware upgrade for interface " . $IntName . ".");
+
+ :global LTEFirmwareUpgrade do={
+ :global LTEFirmwareUpgrade;
+ :set LTEFirmwareUpgrade;
+
+ /system/scheduler/remove ($1 . "-firmware-upgrade");
+ /interface/lte/firmware-upgrade $1 upgrade=yes;
+ :log info ("LTE firmware upgrade on '" . $1 . "' finished, waiting for reset.");
+ :delay 240s;
+ :local Firmware [ /interface/lte/firmware-upgrade $1 once as-value ];
+ :if (($Firmware->"installed") != ($Firmware->"latest")) do={
+ :log warning ("LTE firmware versions still differ. Resetting again...");
+ /interface/lte/at-chat $1 input="AT+RESET";
+ }
+ }
+
+ /system/scheduler/add name=($IntName . "-firmware-upgrade") start-time=startup interval=2s \
+ on-event=(":global LTEFirmwareUpgrade; \$LTEFirmwareUpgrade \"" . $IntName . "\";");
+ } else={
+ :log info ("The LTE firmware is up to date on interface " . $IntName . ".");
+ }
+ } else={
+ :log info ("No LTE firmware information available for interface " . $IntName . ".");
+ }
+}