routeros-scripts-main/simple-routeros-update.sh
Miquel Bonastre f26cb2a105 Helper scripts to upgrade routeros to the latest version
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.
2026-03-19 15:46:43 +01:00

74 lines
2.4 KiB
Bash
Executable file

#!/bin/sh
#
# File: simple-routeros-update.sh
# Description: Upgrade to the last routeros stable version
# Author: Miquel Bonastre
# Date: 2025-03-11
#
# Inputs:
# $1 - ssh user to use to connect to Mikrotik (usualy "admin")
# $2 - Mikrotik address
#
# The address can be:
# - Previously configured IP address
# - Default address: 192.168.88.1
# - Local link IPv6 address
#
if [ -z "$2" ]; then
echo Missing parameters
echo $0 user addr
exit 1
fi
SSH="ssh -nq"
SCP="scp -q"
if ! $SSH -l "$1" "$2" ":put" \"Hello World\" \; ; then
exit 1
fi
echo "Copy simple-routeros-update.rsc via scp:"
$SCP simple-routeros-update.rsc "$1@[$2]":
echo "Exec simple-routeros-update via ssh:"
$SSH -l "$1" "$2" "/import simple-routeros-update.rsc;"
echo "Force exit if router has restarted (execute again until last version installed)"
$SSH -l "$1" "$2" "/system/clock/print" || exit 1
echo "If you see the output of /system/clock/print means there are no more upgrades"
echo "End of simple-routeros-update"
# How to find router's local link IPv6 address:
# ping -6 fe80::%n
#
# Where n is the number of the interface where the router can be found as reported by "ip link":
#
# Example:
# $ ip link
# 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
# link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
# 3: enx207bd2dc0ebe: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
# link/ether 20:7b:d2:dc:0e:be brd ff:ff:ff:ff:ff:ff
#
# ping -6 'fe80::%9' -c 4
# PING fe80::%9(fe80::%enx00b56d00e148) 56 data bytes
# 64 bytes from fe80::ba69:f4ff:fe77:beef%enx00b56d00e148: icmp_seq=1 ttl=64 time=0.405 ms
# 64 bytes from fe80::ba69:f4ff:fe77:beef%enx00b56d00e148: icmp_seq=2 ttl=64 time=0.479 ms
# 64 bytes from fe80::ba69:f4ff:fe77:beef%enx00b56d00e148: icmp_seq=3 ttl=64 time=0.461 ms
# 64 bytes from fe80::ba69:f4ff:fe77:beef%enx00b56d00e148: icmp_seq=4 ttl=64 time=0.374 ms
# --- fe80::%9 ping statistics ---
# 4 packets transmitted, 4 received, 0% packet loss, time 3053ms
# rtt min/avg/max/mdev = 0.374/0.429/0.479/0.042 ms
#
# Temporal connection to Mikrotik via ssh:
# ssh -l admin 'fe80::<found values>'
# example: ssh -l admin 'fe80::ba69:f4ff:fe77:beef%enx00b56d00e148'
#
# Temporal connection via Winbox:
# [fe80:....%n]
# example: [fe80::ba69:f4ff:fe77:beef%9]
#