mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
global-functions: add $DownloadPackage
... and make script 'capsman-download-packages' use it.
This commit is contained in:
parent
30166cc287
commit
ac2e6cfc61
2 changed files with 30 additions and 8 deletions
|
@ -7,7 +7,7 @@
|
|||
#
|
||||
# download and cleanup packages for CAP installation from CAPsMAN
|
||||
|
||||
:global CertificateAvailable;
|
||||
:global DownloadPackage;
|
||||
|
||||
:local "package-path" [ / caps-man manager get package-path ];
|
||||
:if ([ :pick $"package-path" 0 ] = "/") do={
|
||||
|
@ -26,13 +26,10 @@
|
|||
:if ($"package-name" = "wireless@") do={
|
||||
:set "package-name" "wireless";
|
||||
}
|
||||
:local "package-file" ($"package-name" . "-" . $"installed-version" . "-" . $"package-architecture" . ".npk");
|
||||
$CertificateAvailable "Let's Encrypt Authority X3" "letsencrypt";
|
||||
/ tool fetch mode=https check-certificate=yes-without-crl \
|
||||
("https://upgrade.mikrotik.com/routeros/" . $"installed-version" . "/" . $"package-file") \
|
||||
dst-path=($"package-path" . "/" . $"package-file");
|
||||
:set updated true;
|
||||
/ file remove $package;
|
||||
:if ([ $DownloadPackage $"package-name" $"installed-version" $"package-architecture" $"package-path" ] = true) do={
|
||||
:set updated true;
|
||||
/ file remove $package;
|
||||
}
|
||||
}
|
||||
|
||||
:if ($updated = true) do={
|
||||
|
|
|
@ -107,3 +107,28 @@
|
|||
:return "unknown vendor";
|
||||
}
|
||||
}
|
||||
|
||||
# download package from upgrade server
|
||||
:global DownloadPackage do={
|
||||
:local pkgname [ :tostr $1 ];
|
||||
:local pkgver [ :tostr $2 ];
|
||||
:local pkgarch [ :tostr $3 ];
|
||||
:local pkgdest [ :tostr $4 ];
|
||||
|
||||
:global CertificateAvailable;
|
||||
|
||||
:if ([ :len $pkgname ] = 0) do={ return false; }
|
||||
:if ([ :len $pkgver ] = 0) do={ :set pkgver [ / system package update get installed-version ]; }
|
||||
:if ([ :len $pkgarch ] = 0) do={ :set pkgarch [ / system resource get architecture-name ]; }
|
||||
|
||||
$CertificateAvailable "Let's Encrypt Authority X3" "letsencrypt";
|
||||
do {
|
||||
:local pkgfile ($pkgname . "-" . $pkgver . "-" . $pkgarch . ".npk");
|
||||
/ tool fetch mode=https check-certificate=yes-without-crl \
|
||||
("https://upgrade.mikrotik.com/routeros/" . $pkgver . "/" . $pkgfile) \
|
||||
dst-path=($pkgdest . "/" . $pkgfile);
|
||||
return true;
|
||||
} on-error={
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue