aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2022-12-13 15:42:45 +0100
committerGravatar Christian Hesse <mail@eworm.de>2022-12-13 21:50:32 +0100
commit16bfe4de7ebc651854fd66939a84c6af8ee81af2 (patch)
tree56c1ed01aa08b2dea47bf6354b94b0f545dfc89f
parent1579330864c98f4526cf5e0f0ea7204ad25f87a3 (diff)
global-functions: $MkDir: create a tmpfs (RAM disk)...routeros-7.7rc1
... if the path starts with "tmpfs/". This helps to mitigate flash wear.
-rw-r--r--global-functions10
1 files changed, 10 insertions, 0 deletions
diff --git a/global-functions b/global-functions
index 9ff6bd5..a9c1c93 100644
--- a/global-functions
+++ b/global-functions
@@ -525,6 +525,7 @@
:global CleanFilePath;
:global GetRandom20CharAlNum;
:global LogPrintExit2;
+ :global RequiredRouterOS;
:global WaitForFile;
:set Path [ $CleanFilePath $Path ];
@@ -547,6 +548,15 @@
:set Continue true;
}
+ :if ($Continue = false && $PathNext = "tmpfs" && [ $RequiredRouterOS $0 "7.7rc1" false ] = true) do={
+ :if ([ :len [ /disk/find where slot=tmpfs type=tmpfs ] ] = 0) do={
+ $LogPrintExit2 info $0 ("Creating disk of type tmpfs.") false;
+ /file/remove [ find where name="tmpfs" type="directory" ];
+ [ :parse "/disk/add slot=tmpfs type=tmpfs;" ];
+ }
+ :set Continue true;
+ }
+
:if ($Continue = false && [ :len [ /file/find where name=$PathNext ] ] = 1) do={
$LogPrintExit2 warning $0 ("The path '" . $PathNext . "' exists, but is not a directory.") false;
:return false;