mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2024-05-11 05:55:19 +00:00
global-functions: $MkDir: rename internal variable
This commit is contained in:
@ -519,35 +519,35 @@
|
|||||||
|
|
||||||
# create directory
|
# create directory
|
||||||
:set MkDir do={
|
:set MkDir do={
|
||||||
:local Dir [ :tostr $1 ];
|
:local Path [ :tostr $1 ];
|
||||||
|
|
||||||
:global CleanFilePath;
|
:global CleanFilePath;
|
||||||
:global GetRandom20CharAlNum;
|
:global GetRandom20CharAlNum;
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
:global WaitForFile;
|
:global WaitForFile;
|
||||||
|
|
||||||
:set Dir [ $CleanFilePath $Dir ];
|
:set Path [ $CleanFilePath $Path ];
|
||||||
|
|
||||||
:if ($Dir = "") do={
|
:if ($Path = "") do={
|
||||||
:return true;
|
:return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ([ :len [ /file/find where name=$Dir type="directory" ] ] = 1) do={
|
:if ([ :len [ /file/find where name=$Path type="directory" ] ] = 1) do={
|
||||||
:return true;
|
:return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ([ :len [ /file/find where name=$Dir ] ] = 1) do={
|
:if ([ :len [ /file/find where name=$Path ] ] = 1) do={
|
||||||
$LogPrintExit2 warning $0 ("The path '" . $Dir . "' exists, but is not a directory.") false;
|
$LogPrintExit2 warning $0 ("The path '" . $Path . "' exists, but is not a directory.") false;
|
||||||
:return false;
|
:return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
:local Return true;
|
:local Return true;
|
||||||
:local Name ($Dir . "-" . [ $GetRandom20CharAlNum 6 ]);
|
:local Name ($Path . "-" . [ $GetRandom20CharAlNum 6 ]);
|
||||||
:do {
|
:do {
|
||||||
/ip/smb/share/add disabled=yes directory=$Dir name=$Name;
|
/ip/smb/share/add disabled=yes directory=$Path name=$Name;
|
||||||
$WaitForFile $Dir;
|
$WaitForFile $Path;
|
||||||
} on-error={
|
} on-error={
|
||||||
$LogPrintExit2 warning $0 ("Making directory '" . $Dir . "' failed!") false;
|
$LogPrintExit2 warning $0 ("Making directory '" . $Path . "' failed!") false;
|
||||||
:set Return false;
|
:set Return false;
|
||||||
}
|
}
|
||||||
/ip/smb/share/remove [ find where name=$Name ];
|
/ip/smb/share/remove [ find where name=$Name ];
|
||||||
|
Reference in New Issue
Block a user