mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
31 lines
953 B
Text
31 lines
953 B
Text
#!rsc
|
|
# RouterOS script: packages-update
|
|
# Copyright (c) 2019 Christian Hesse <mail@eworm.de>
|
|
#
|
|
# download packages and reboot for installation
|
|
|
|
:global DownloadPackage;
|
|
|
|
:local InstalledVersion [ / system package update get installed-version ];
|
|
:local LatestVersion [ / system package update get latest-version ];
|
|
|
|
:if ($InstalledVersion = $LatestVersion) do={
|
|
:log info ("Version " . $LatestVersion . " is already installed.");
|
|
:error "No updates available.";
|
|
}
|
|
|
|
:foreach Package in=[ / system package find where !bundle ] do={
|
|
:local PkgName [ / system package get $Package name ];
|
|
if ([ $DownloadPackage $PkgName $LatestVersion ] = false) do={
|
|
:log error ("Download for package " . $PkgName . " failed.");
|
|
:error "Error: See log for details.";
|
|
}
|
|
}
|
|
|
|
:if ([ / system script print count-only where name="email-backup" ] > 0) do={
|
|
/ system script run email-backup;
|
|
}
|
|
|
|
:log info ("Rebooting for update.");
|
|
:delay 1s;
|
|
/ system reboot;
|