};
:delay 1s;
};
- :put "Thr tmpfs variable is true. Checking for tmpfs/scripts directory...";
- :if ($tmpfs = true && [/file find name="tmpfs/scripts"] != "") do={
+ :if ($tmpfs = true) do={
+ :put "Tmpfs variable is true. Checking for tmpfs/scripts directory...";
+ :if ([/file find name="tmpfs/scripts"] != "") do={
:log debug ($0 . "Directory tmpfs/scripts exsist.");
:return $true;
} else={
- :log error ($0 . "Directory tmpfs/scripts does not exsist. Remove global variable tmpfs!");
- :global tmpfs (a);
+ :local MkTmpfs do={
+ :local TmpFs [ /disk/find where slot=tmpfs type=tmpfs ];
+ :if ([ :len $TmpFs ] = 1) do={
+ :if ([ /disk/get $TmpFs disabled ] = true) do={
+ :log info ("The tmpfs is disabled, enabling.");
+ /disk/enable $TmpFs;
+ }
+ :return true;
+ }
+ :log info ("Creating disk of type tmpfs.");
+ /file/remove "tmpfs";
+# $RmDir "tmpfs";
+ :onerror Err {
+ /disk/add slot=tmpfs type=tmpfs tmpfs-max-size=([ /system/resource/get total-memory ] / 3);
+ :do {
+ :retry {
+ /file/get tmpfs;
+ :return true;
+ } delay=222ms max=10;
+ } on-error={ }
+ } do={
+ :log warning ("Creating disk of type tmpfs failed: " . $Err);
+ :return false;
+ }
+ :return true;
+ }
+# :log error ($0 . "Directory tmpfs/scripts does not exsist. Remove global variable tmpfs!");
+# :global tmpfs (a);
return false;
}
:put "Renaming AM-GlobalConfig, if exists...";