mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-10 18:14:27 +02:00
Merge branch 'mkdir' into next
This commit is contained in:
commit
814fb7197f
1 changed files with 64 additions and 34 deletions
|
@ -561,6 +561,26 @@
|
||||||
:global RequiredRouterOS;
|
:global RequiredRouterOS;
|
||||||
:global WaitForFile;
|
:global WaitForFile;
|
||||||
|
|
||||||
|
:local MkTmpfs do={
|
||||||
|
:global LogPrintExit2;
|
||||||
|
:global WaitForFile;
|
||||||
|
|
||||||
|
:if ([ :len [ /disk/find where slot=tmpfs type=tmpfs ] ] = 1) do={
|
||||||
|
:return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$LogPrintExit2 info $0 ("Creating disk of type tmpfs.") false;
|
||||||
|
/file/remove [ find where name="tmpfs" type="directory" ];
|
||||||
|
:do {
|
||||||
|
/disk/add slot=tmpfs type=tmpfs tmpfs-max-size=([ /system/resource/get total-memory ] / 3);
|
||||||
|
$WaitForFile "tmpfs";
|
||||||
|
} on-error={
|
||||||
|
$LogPrintExit2 warning $0 ("Creating disk of type tmpfs failed!") false;
|
||||||
|
:return false;
|
||||||
|
}
|
||||||
|
:return true;
|
||||||
|
}
|
||||||
|
|
||||||
:set Path [ $CleanFilePath $Path ];
|
:set Path [ $CleanFilePath $Path ];
|
||||||
|
|
||||||
:if ($Path = "") do={
|
:if ($Path = "") do={
|
||||||
|
@ -571,6 +591,23 @@
|
||||||
:return true;
|
:return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:if ([ $RequiredRouterOS $0 "7.9beta4" false ] = true) do={
|
||||||
|
:if ([ :pick $Path 0 5 ] = "tmpfs") do={
|
||||||
|
:if ([ $MkTmpfs ] = false) do={
|
||||||
|
:return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:do {
|
||||||
|
:local File ($Path . "/file");
|
||||||
|
/file/add name=$File;
|
||||||
|
$WaitForFile $File;
|
||||||
|
/file/remove $File;
|
||||||
|
} on-error={
|
||||||
|
$LogPrintExit2 warning $0 ("Making directory '" . $Path . "' failed!") false;
|
||||||
|
:return false;
|
||||||
|
}
|
||||||
|
} else={
|
||||||
:local Error false;
|
:local Error false;
|
||||||
:local PathNext "";
|
:local PathNext "";
|
||||||
:foreach Dir in=[ :toarray [ $CharacterReplace $Path "/" "," ] ] do={
|
:foreach Dir in=[ :toarray [ $CharacterReplace $Path "/" "," ] ] do={
|
||||||
|
@ -582,16 +619,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ($Continue = false && $PathNext = "tmpfs") do={
|
:if ($Continue = false && $PathNext = "tmpfs") do={
|
||||||
:if ([ :len [ /disk/find where slot=tmpfs type=tmpfs ] ] = 0) do={
|
:if ([ $MkTmpfs ] = false) do={
|
||||||
$LogPrintExit2 info $0 ("Creating disk of type tmpfs.") false;
|
:return false;
|
||||||
/file/remove [ find where name="tmpfs" type="directory" ];
|
|
||||||
:do {
|
|
||||||
/disk/add slot=tmpfs type=tmpfs tmpfs-max-size=([ /system/resource/get total-memory ] / 3);
|
|
||||||
$WaitForFile "tmpfs";
|
|
||||||
} on-error={
|
|
||||||
$LogPrintExit2 warning $0 ("Creating disk of type tmpfs failed!") false;
|
|
||||||
:set Error true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
:set Continue true;
|
:set Continue true;
|
||||||
}
|
}
|
||||||
|
@ -616,6 +645,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
:return true;
|
:return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue