unattended-lte-firmware-upgrade: convert to function

This commit is contained in:
Christian Hesse 2020-10-13 18:52:01 +02:00
parent e11e6b4658
commit 370d7c1a58

View file

@ -17,14 +17,17 @@
:if (($Firmware->"installed") != ($Firmware->"latest")) do={ :if (($Firmware->"installed") != ($Firmware->"latest")) do={
:log info ("Scheduling LTE firmware upgrade for interface " . $IntName . "."); :log info ("Scheduling LTE firmware upgrade for interface " . $IntName . ".");
/ system script add name=($IntName . "-firmware-upgrade") source=("# unattended-lte-firmware-upgrade\n" . \ :global LTEFirmwareUpgrade do={
"/ system scheduler remove " . $IntName . "-firmware-upgrade;\n" . \ :global LTEFirmwareUpgrade;
"/ system script remove " . $IntName . "-firmware-upgrade;\n" . \ :set LTEFirmwareUpgrade;
"/ interface lte firmware-upgrade " . $IntName . " upgrade=yes;\n" . \ / system scheduler remove ($1 . "-firmware-upgrade");
":log info (\"LTE firmware upgrade finished, waiting for installation before reset.\");\n" . \ / interface lte firmware-upgrade $1 upgrade=yes;
":delay 150s;\n" . \ :log info ("LTE firmware upgrade finished, waiting for installation before reset.");
"/ interface lte at-chat " . $IntName . " input=\"AT+RESET\";"); :delay 150s;
/ system scheduler add name=($IntName . "-firmware-upgrade") \ / interface lte at-chat $1 input="AT+RESET";
on-event=("/ system script run " . $IntName . "-firmware-upgrade;") interval=1m; :log info ("Reset device, waiting to finish and reconnect.");
}
/ system scheduler add name=($IntName . "-firmware-upgrade") start-time=startup interval=2s \
on-event=(":global LTEFirmwareUpgrade; \$LTEFirmwareUpgrade \"" . $IntName . "\";");
} }
} }