mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
global-functions: remove file on failed download
This commit is contained in:
parent
e9b4094dba
commit
8537bbe19d
1 changed files with 9 additions and 3 deletions
|
@ -142,7 +142,7 @@
|
||||||
:local PkgName [ :tostr $1 ];
|
:local PkgName [ :tostr $1 ];
|
||||||
:local PkgVer [ :tostr $2 ];
|
:local PkgVer [ :tostr $2 ];
|
||||||
:local PkgArch [ :tostr $3 ];
|
:local PkgArch [ :tostr $3 ];
|
||||||
:local PkgDest [ :tostr $4 ];
|
:local PkgDir [ :tostr $4 ];
|
||||||
|
|
||||||
:global CertificateAvailable;
|
:global CertificateAvailable;
|
||||||
|
|
||||||
|
@ -150,14 +150,20 @@
|
||||||
:if ([ :len $PkgVer ] = 0) do={ :set PkgVer [ / system package update get installed-version ]; }
|
: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 ]; }
|
:if ([ :len $PkgArch ] = 0) do={ :set PkgArch [ / system resource get architecture-name ]; }
|
||||||
|
|
||||||
|
:local PkgFile ($PkgName . "-" . $PkgVer . "-" . $PkgArch . ".npk");
|
||||||
|
:local PkgDest $PkgFile;
|
||||||
|
:if ($PkgDir != "") do={
|
||||||
|
:set PkgDest ($PkgDir . "/" . $PkgFile);
|
||||||
|
}
|
||||||
|
|
||||||
$CertificateAvailable "Let's Encrypt Authority X3" "letsencrypt";
|
$CertificateAvailable "Let's Encrypt Authority X3" "letsencrypt";
|
||||||
:do {
|
:do {
|
||||||
:local PkgFile ($PkgName . "-" . $PkgVer . "-" . $PkgArch . ".npk");
|
|
||||||
/ tool fetch mode=https check-certificate=yes-without-crl \
|
/ tool fetch mode=https check-certificate=yes-without-crl \
|
||||||
("https://upgrade.mikrotik.com/routeros/" . $PkgVer . "/" . $PkgFile) \
|
("https://upgrade.mikrotik.com/routeros/" . $PkgVer . "/" . $PkgFile) \
|
||||||
dst-path=($PkgDest . "/" . $PkgFile);
|
dst-path=$PkgDest;
|
||||||
:return true;
|
:return true;
|
||||||
} on-error={
|
} on-error={
|
||||||
|
/ file remove [ find where name=$PkgDest ];
|
||||||
:return false;
|
:return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue