routeros-scripts/packages-update

32 lines
957 B
Text
Raw Normal View History

2019-02-19 15:41:27 +00:00
#!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.";
2019-02-19 15:41:27 +00:00
}
: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.";
2019-02-19 15:41:27 +00:00
}
}
:foreach Script in=[ / system script find where name~"^(email|upload)-backup\$" ] do={
/ system script run $Script;
2019-02-19 15:41:27 +00:00
}
:log info ("Rebooting for update.");
:delay 1s;
/ system reboot;