mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-04-16 10:09:37 +00:00
The RouterOS scripts from https://github.com/eworm-de/routeros-scripts require a recent routeros version (7.19 as of 2026-03-11). It is not rare to have an older version when reinstalling a Mikrotik router that has not been updated for a while. So, the first step I do when configuring a new or old router is to upgrade the RouterOS to the latest stable version. This usually requires multiple reboots because the upgrade process not always goes directly to the last version. Also, upgrading the firmware requires an extra boot. The simple-routeros-update.rsc doesn't use any functionality the requires a specific RouterOS version, so it should work with almost any router. (I have upgraded routers from v6 using this method). The shell script is just a wrapper around ssh/scp to launch the rsc script.
58 lines
1.6 KiB
Text
58 lines
1.6 KiB
Text
#!rsc by Guillen
|
|
#
|
|
# Script: simple-routeros-update.rsc
|
|
#
|
|
# Copied and adaptated from RouterOS script: packages-update
|
|
# Copyright (c) 2019-2025 Christian Hesse <mail@eworm.de>
|
|
# https://rsc.eworm.de/COPYING.md
|
|
#
|
|
# download packages and reboot for installation
|
|
# https://rsc.eworm.de/doc/packages-update.md
|
|
#
|
|
# RouterOS upgrade for a new or repurposed Mikrotik.
|
|
# Works even with very old RouterOS versions
|
|
# WARNING: reboots router after each upgrade
|
|
#
|
|
{:put "START script simple-routeros-update"};
|
|
|
|
{
|
|
:local ScriptName "simple-routeros-update";
|
|
:local LogPrint;
|
|
|
|
# Simplified LogPrint
|
|
:set LogPrint do={
|
|
:local Name [ :tostr $1 ];
|
|
:local Message [ :tostr $2 ];
|
|
|
|
:log info ( $Name . ": " . $Message);
|
|
:put ( $Name . ": " . $Message);
|
|
}
|
|
|
|
#
|
|
# Main block:
|
|
#
|
|
|
|
$LogPrint $ScriptName "Checking for updates...";
|
|
/system/package/update/check-for-updates without-paging;
|
|
$LogPrint $ScriptName "Installing updates (if any) ...";
|
|
/system/package/update/install without-paging;
|
|
|
|
$LogPrint $ScriptName "Checking firmware upgrade ...";
|
|
|
|
:local RouterBoard [ /system/routerboard/get ];
|
|
:if ($RouterBoard->"current-firmware" = $RouterBoard->"upgrade-firmware") do={
|
|
$LogPrint $ScriptName ("Firmware already updated:" . $RouterBoard->"current-firmware" . ".");
|
|
} else={
|
|
:if ([ /system/routerboard/settings/get auto-upgrade ] = false) do={
|
|
$LogPrint $ScriptName ("Firmware " . $RouterBoard->"upgrade-firmware" . " available, upgrading.");
|
|
:delay 5s;
|
|
/system/routerboard/upgrade;
|
|
$LogPrint $ScriptName ("Rebooting...");
|
|
:delay 5s;
|
|
/system/reboot;
|
|
}
|
|
}
|
|
};
|
|
|
|
{:put "END script simple-routeros-update"};
|
|
|