mirror of
https://github.com/nymurbd/MikroTik-scripts.git
synced 2025-07-09 17:44:31 +02:00
global-functions: introduce and use $CleanFilePath
This commit is contained in:
parent
8537bbe19d
commit
c361caee5b
1 changed files with 21 additions and 4 deletions
|
@ -137,6 +137,25 @@
|
|||
}
|
||||
}
|
||||
|
||||
# clean file path
|
||||
:global CleanFilePath do={
|
||||
:local Path [ :tostr $1 ];
|
||||
|
||||
:global CharacterReplace;
|
||||
|
||||
:while ($Path ~ "//") do={
|
||||
:set $Path [ $CharacterReplace $Path "//" "/" ];
|
||||
}
|
||||
:if ([ :pick $Path 0 ] = "/") do={
|
||||
:set Path [ :pick $Path 1 [ :len $Path ] ];
|
||||
}
|
||||
:if ([ :pick $Path ([ :len $Path ] - 1) ] = "/") do={
|
||||
:set Path [ :pick $Path 0 ([ :len $Path ] - 1) ];
|
||||
}
|
||||
|
||||
:return $Path;
|
||||
}
|
||||
|
||||
# download package from upgrade server
|
||||
:global DownloadPackage do={
|
||||
:local PkgName [ :tostr $1 ];
|
||||
|
@ -145,16 +164,14 @@
|
|||
:local PkgDir [ :tostr $4 ];
|
||||
|
||||
:global CertificateAvailable;
|
||||
:global CleanFilePath;
|
||||
|
||||
: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 ]; }
|
||||
|
||||
:local PkgFile ($PkgName . "-" . $PkgVer . "-" . $PkgArch . ".npk");
|
||||
:local PkgDest $PkgFile;
|
||||
:if ($PkgDir != "") do={
|
||||
:set PkgDest ($PkgDir . "/" . $PkgFile);
|
||||
}
|
||||
:local PkgDest [ $CleanFilePath ($PkgDir . "/" . $PkgFile) ];
|
||||
|
||||
$CertificateAvailable "Let's Encrypt Authority X3" "letsencrypt";
|
||||
:do {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue