mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-09 17:44:29 +02:00
introduce firmware-upgrade-reboot
(cherry picked from commit 3c358980cb
)
This commit is contained in:
parent
c95e816148
commit
32cc55f7d2
9 changed files with 75 additions and 3 deletions
|
@ -204,6 +204,7 @@ Available scripts
|
|||
* [Use wireless network with daily psk](doc/daily-psk.md)
|
||||
* [Comment DHCP leases with info from access list](doc/dhcp-lease-comment.md)
|
||||
* [Create DNS records for DHCP leases](doc/dhcp-to-dns.md)
|
||||
* [Automatically upgrade firmware and reboot](doc/firmware-upgrade-reboot.md)
|
||||
* [Wait for global functions und modules](doc/global-wait.md)
|
||||
* [Send GPS position to server](doc/gps-track.md)
|
||||
* [Use WPA2 network with hotspot credentials](doc/hotspot-to-wpa.md)
|
||||
|
|
|
@ -61,6 +61,7 @@ Installing script [packages-update](packages-update.md) gives extra options.
|
|||
See also
|
||||
--------
|
||||
|
||||
* [Automatically upgrade firmware and reboot](firmware-upgrade-reboot.md)
|
||||
* [Manage system update](packages-update.md)
|
||||
|
||||
---
|
||||
|
|
36
doc/firmware-upgrade-reboot.md
Normal file
36
doc/firmware-upgrade-reboot.md
Normal file
|
@ -0,0 +1,36 @@
|
|||
Automatically upgrade firmware and reboot
|
||||
=========================================
|
||||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
RouterOS and firmware are upgraded separately, activating the latter
|
||||
requires an extra reboot. This script handles upgrade and reboot.
|
||||
|
||||
⚠️ **Warning**: This *should* be bullet proof, but I can not guarantee. In
|
||||
worst case it has potential to cause a boot loop, so handle with care!
|
||||
|
||||
Requirements and installation
|
||||
-----------------------------
|
||||
|
||||
Just install the script and create a scheduler:
|
||||
|
||||
$ScriptInstallUpdate firmware-upgrade-reboot;
|
||||
/ system scheduler add name=firmware-upgrade-reboot on-event="/ system script run firmware-upgrade-reboot;" start-time=startup;
|
||||
|
||||
Enjoy firmware being up to date and in sync with RouterOS.
|
||||
|
||||
See also
|
||||
--------
|
||||
|
||||
* [Notify on RouterOS update](check-routeros-update.md)
|
||||
* [Manage system update](packages-update.md)
|
||||
|
||||
---
|
||||
[◀ Go back to main README](../README.md)
|
||||
[▲ Go back to top](#top)
|
|
@ -44,6 +44,7 @@ See also
|
|||
* [Upload backup to Mikrotik cloud](backup-cloud.md)
|
||||
* [Send backup via e-mail](backup-email.md)
|
||||
* [Upload backup to server](backup-upload.md)
|
||||
* [Automatically upgrade firmware and reboot](firmware-upgrade-reboot.md)
|
||||
|
||||
---
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
|
32
firmware-upgrade-reboot
Normal file
32
firmware-upgrade-reboot
Normal file
|
@ -0,0 +1,32 @@
|
|||
#!rsc by RouterOS
|
||||
# RouterOS script: firmware-upgrade-reboot
|
||||
# Copyright (c) 2022 Christian Hesse <mail@eworm.de>
|
||||
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
|
||||
#
|
||||
# install firmware upgrade, and reboot
|
||||
# https://git.eworm.de/cgit/routeros-scripts/about/doc/firmware-upgrade-reboot.md
|
||||
|
||||
:local 0 "firmware-upgrade-reboot";
|
||||
:global GlobalFunctionsReady;
|
||||
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
||||
|
||||
:global LogPrintExit2;
|
||||
|
||||
:local RouterBoard [ / system routerboard get ];
|
||||
:if ($RouterBoard->"current-firmware" = $RouterBoard->"upgrade-firmware") do={
|
||||
$LogPrintExit2 info $0 ("Firmware is already up to date.") true;
|
||||
}
|
||||
|
||||
:if ([ / system routerboard settings get auto-upgrade ] = false) do={
|
||||
$LogPrintExit2 info $0 ("Firmware version " . $RouterBoard->"upgrade-firmware" . \
|
||||
" is available, upgrading.") false;
|
||||
/ system routerboard upgrade;
|
||||
}
|
||||
|
||||
:while ([ :len [ / log find where topics=({"system";"info";"critical"}) \
|
||||
message="Firmware upgraded successfully, please reboot for changes to take effect!" ] ] = 0) do={
|
||||
:delay 1s;
|
||||
}
|
||||
|
||||
$LogPrintExit2 info $0 ("Firmware upgrade successful, rebooting.") false;
|
||||
/ system reboot;
|
|
@ -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 76;
|
||||
:global GlobalConfigVersion 77;
|
||||
|
||||
# This is used for DNS and backup file.
|
||||
:global Domain "example.com";
|
||||
|
|
|
@ -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'!
|
||||
# Comment or remove to disable news and change notifications.
|
||||
:global GlobalConfigVersion 76;
|
||||
:global GlobalConfigVersion 77;
|
||||
|
||||
# Use branch routeros-v6 with RouterOS v6:
|
||||
:global ScriptUpdatesUrlSuffix "\?h=routeros-v6";
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
74="Extended 'hotspot-to-wpa', it can now read additional configuration from templates and hotspot users.";
|
||||
75="You are using the branch 'routeros-v6', well done.";
|
||||
76="Added an option to suppress notifications on host down with 'netwatch-notify'.";
|
||||
77="Introduced new script 'firmware-upgrade-reboot'. Handle with care!";
|
||||
};
|
||||
|
||||
# Migration steps to be applied on script updates
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
# https://git.eworm.de/cgit/routeros-scripts/about/
|
||||
|
||||
# expected configuration version
|
||||
:global ExpectedConfigVersion 76;
|
||||
:global ExpectedConfigVersion 77;
|
||||
|
||||
# global variables not to be changed by user
|
||||
:global GlobalFunctionsReady false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue