Community discussions

MikroTik App
 
Allieduser
just joined
Topic Author
Posts: 2
Joined: Tue Feb 18, 2025 8:57 pm

script for auto update

Tue Feb 18, 2025 9:28 pm

Hello community, i wrote some script to do automatic updates, but when i run in, i mean run script pushed i got error.
executing script CheckForAllUpdates from winbox failed, please check it manually
i gave those permissions: read, write, reboot, test, sensitive, test.
and script is
:local version
:local latestVersion

# Check for updates
/system package update check
:delay 5

# Get current and latest version
:set version [/system package get version]
:set latestVersion [/system package update get installed-version]

# Log current and latest versions
/log info message=("Current version: " . $version)
/log info message=("Latest version: " . $latestVersion)

# Compare versions
:if ($version != $latestVersion) do={
/log info message=("New version detected: " . $latestVersion . ". Starting update...")

# Install updates
/system package update install
:delay 10

# Reboot system after update
/log info message="Update completed. Rebooting system..."
/system reboot
} else={
/log info message=("No updates available. You have the latest version! :) Current version: " . $version)
}
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12736
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: script for auto update

Tue Feb 18, 2025 10:02 pm

One of the stupidest things you can do is update something as soon as the new version comes out...
Especially with RouterOS....

Apart from that, the script is full of bulls–t.
For example, after the update installation starts, the system automatically reboots without the need to reboot it with the commands...
Restarting the routerboard after 10 seconds that the update has started to be downloaded, could cause an incomplete download that upon forced reboot could be installed by mistake, and being incomplete would not restart anymore.

Not to mention that if the script is on multiple machines, installing and restarting poe switches while the connected peripherals are updating creates other problems.

Not to mention that comparing versions is useless, because "install" only installs the new version if it is not the same one already installed.

So to hurt ourselves like fools, this line is enough:
/system package update ; check ; install

In short, the script, which I seem to have already reviewed elsewhere, is a load of c–p.
 
optio
Forum Guru
Forum Guru
Posts: 1031
Joined: Mon Dec 26, 2022 2:57 pm

Re: script for auto update

Tue Feb 18, 2025 11:14 pm

I have feeling someone is just creating users on forum to create such topics to pissoff @rextended :)
 
holvoetn
Forum Guru
Forum Guru
Posts: 7078
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: script for auto update

Tue Feb 18, 2025 11:42 pm

And it results in lots of aceto balsamico being spilled ...
 
Allieduser
just joined
Topic Author
Posts: 2
Joined: Tue Feb 18, 2025 8:57 pm

Re: script for auto update

Wed Feb 19, 2025 7:24 pm

One of the stupidest things you can do is update something as soon as the new version comes out...
Especially with RouterOS....

Apart from that, the script is full of bulls–t.
For example, after the update installation starts, the system automatically reboots without the need to reboot it with the commands...
Restarting the routerboard after 10 seconds that the update has started to be downloaded, could cause an incomplete download that upon forced reboot could be installed by mistake, and being incomplete would not restart anymore.

Not to mention that if the script is on multiple machines, installing and restarting poe switches while the connected peripherals are updating creates other problems.

Not to mention that comparing versions is useless, because "install" only installs the new version if it is not the same one already installed.

So to hurt ourselves like fools, this line is enough:
/system package update ; check ; install

In short, the script, which I seem to have already reviewed elsewhere, is a load of c–p.
thank you for your ideas, i am new here :)