blob: 7d161c290bb6b98ae352fa0050a3e5e123684ab9 (
about) (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#!rsc
# RouterOS script: packages-update
# Copyright (c) 2019 Christian Hesse <mail@eworm.de>
#
# download packages and reboot for installation
:global DownloadPackage;
:local Update [ / system package update get ];
:if ([ :typeof ($Update->"latest-version") ] = "nothing") do={
:log warning "Latest version is not known.";
:error "Latest version is not known.";
}
:if ($Update->"installed-version" = $Update->"latest-version") do={
:log info ("Version " . $Update->"latest-version" . " 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 ($Update->"latest-version") ] = false) do={
:log error ("Download for package " . $PkgName . " failed.");
:error "Error: See log for details.";
}
}
:foreach Script in=[ / system script find where name~"^(email|upload)-backup\$" ] do={
/ system script run $Script;
}
:log info ("Rebooting for update.");
:delay 1s;
/ system reboot;
|