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;
|
|
|
|
|
2019-07-24 08:13:39 +00:00
|
|
|
:local Update [ / system package update get ];
|
2019-02-19 15:41:27 +00:00
|
|
|
|
2019-07-24 08:22:37 +00:00
|
|
|
:if ([ :typeof ($Update->"latest-version") ] = "nothing") do={
|
|
|
|
:log warning "Latest version is not known.";
|
|
|
|
:error "Latest version is not known.";
|
|
|
|
}
|
|
|
|
|
2019-07-24 08:13:39 +00:00
|
|
|
:if ($Update->"installed-version" = $Update->"latest-version") do={
|
|
|
|
:log info ("Version " . $Update->"latest-version" . " is already installed.");
|
2019-04-03 19:30:43 +00:00
|
|
|
: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 ];
|
2019-07-24 08:13:39 +00:00
|
|
|
if ([ $DownloadPackage $PkgName ($Update->"latest-version") ] = false) do={
|
2019-04-03 19:30:43 +00:00
|
|
|
:log error ("Download for package " . $PkgName . " failed.");
|
|
|
|
:error "Error: See log for details.";
|
2019-02-19 15:41:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-18 11:18:44 +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;
|