MikroTik scripts: RouterBOARD firmware auto upgrade

Script to automatically upgrade the firmware (bootloader) of MikroTik after updating the version of RouterOS, to match the version of MikroTik RouterOS and the RouterBOARD bootloader.

Previously, I had to manually upgrade the RouterBOARD bootloader version, after updating the RouterOS version, this required additional time and attention when there were a lot of MikroTik devices. I wrote a script to automate this process.

Other languages:

Description

The script runs 2 minutes later (180 seconds delay) after booting the MikroTik device. The used RouterBOARD firmware version (current-firmware) and the RouterBOARD version offered for upgrade (upgrade-firmware) are compared. If the versions do not match, the MikroTik device downloads the updated version of the RouterBOARD firmware and reboots the device after installing the new firmware version.

✏️ Note: check that after the specified pause time before the script starts, the Internet will really have time to connect or increase the delay before the script runs.

Create script (manually)

This script should run as soon as the device boots, so we create the script in the task scheduler, not in the script store.

Menu

[System] - [Scheduler] - [+]

Script Data

Name: AutoUpgradeFirmware
Start Time: startup
Policy: read, policy, reboot, write.

Script

:delay 180s;
/system/routerboard
:if ([get current-firmware] != [get upgrade-firmware]) do={
    upgrade;
    /system/reboot;
    }
MikroTik RouterBOARD firmware auto upgrade script

Create script (automatically)

/system scheduler
add name=AutoUpgradeFirmware on-event=":delay 180s;\r\
    \n/system/routerboard\r\
    \n:if ([get current-firmware] != [get upgrade-firmware]) do={\r\
    \n    upgrade;\r\
    \n    /system/reboot;\r\
    \n    }" policy=reboot,read,write,policy start-time=startup

Now the firmware version of the device (bootloader) is always the same as the RouterOS version, and I don’t have to spend time manually updating the firmware.

Script tested: RouterOS v7


🟢 The script for automatically updating the firmware of a MikroTik device when the installed RouterOS version is changed was discussed in this article. I hope you can now automate the task of upgrading RouterOS and device bootloader version. However, if you encounter any problems while setting up the script, feel free to write in the comments. I will try to help.

Leave a Reply

Your email address will not be published. Required fields are marked *

Adblock
detector