aboutsummaryrefslogtreecommitdiffstats
path: root/global-functions
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2019-02-13 09:22:20 +0100
committerGravatar Christian Hesse <mail@eworm.de>2019-02-13 09:22:20 +0100
commit8537bbe19dab99a6943d7cdd3180f9d49394b518 (patch)
treea1df260a75a14cf431032141dcd47e882f7cef08 /global-functions
parente9b4094dba248e7a3df1792008a07c5dc9cb5f3e (diff)
global-functions: remove file on failed download
Diffstat (limited to 'global-functions')
-rw-r--r--global-functions12
1 files changed, 9 insertions, 3 deletions
diff --git a/global-functions b/global-functions
index 2a32cf7..d55d0a6 100644
--- a/global-functions
+++ b/global-functions
@@ -142,7 +142,7 @@
:local PkgName [ :tostr $1 ];
:local PkgVer [ :tostr $2 ];
:local PkgArch [ :tostr $3 ];
- :local PkgDest [ :tostr $4 ];
+ :local PkgDir [ :tostr $4 ];
:global CertificateAvailable;
@@ -150,14 +150,20 @@
: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 ]; }
+ :local PkgFile ($PkgName . "-" . $PkgVer . "-" . $PkgArch . ".npk");
+ :local PkgDest $PkgFile;
+ :if ($PkgDir != "") do={
+ :set PkgDest ($PkgDir . "/" . $PkgFile);
+ }
+
$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);
+ dst-path=$PkgDest;
:return true;
} on-error={
+ / file remove [ find where name=$PkgDest ];
:return false;
}
}