Page 1 of 1

script for auto update

Posted: Tue Feb 18, 2025 9:28 pm
by Allieduser
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)
}

Re: script for auto update

Posted: Tue Feb 18, 2025 10:02 pm
by rextended
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.

Re: script for auto update

Posted: Tue Feb 18, 2025 11:14 pm
by optio
I have feeling someone is just creating users on forum to create such topics to pissoff @rextended :)

Re: script for auto update

Posted: Tue Feb 18, 2025 11:42 pm
by holvoetn
And it results in lots of aceto balsamico being spilled ...

Re: script for auto update

Posted: Wed Feb 19, 2025 7:24 pm
by Allieduser
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 :)