mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-09 01:24:27 +02: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
|
@ -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…
Add table
Add a link
Reference in a new issue