Community discussions

MikroTik App
 
Mitar
newbie
Topic Author
Posts: 35
Joined: Thu Mar 28, 2013 1:07 am

Create .type file using script

Sat May 13, 2023 4:36 pm

How can I create file named ".type" with contents "container" in it ?
When I am trying to run command "/file print file=/temp/.type" the result is always "invalid file name".

I need that ".type" file because I am using tmpfs disks with container writing often there, and the ".type" file causes the directory to stop showing directory contents in winbox file list, and because its tmpfs the directory contents get removed upon restart so the ".type" file needs to be recreated.
 
optio
Forum Veteran
Forum Veteran
Posts: 945
Joined: Mon Dec 26, 2022 2:57 pm

Re: Create .type file using script

Sat May 13, 2023 5:41 pm

Did you try to upload .type file from local computer into that directory over winbox? If upload of hidden files (with . prefix) is not working (didn't tried), uploading directory with that file in it will certainly work - delete temp directory in ROS, create temp directory on local computer and put .type file in it, drag'n'drop that direcotry to Files in Winbox.

Edit: Ah, tmpfs... you will need to do that on each boot manually, not sure if is possible to create hidden files in ROS. If you surround path with "" will not result invalid file name error for print, but if you want to set contents to that file path will result no such item which means that file is not created.

P.S.
container store directories types are not possible to read/modify from ROS shell, not sure if will work for ROS internal processes like writing/reading docker image files in it, maybe it will if this is just shell limitation... You can create persistant temp dir in usb drive with .type in it where you have containers direcories so you don't need to bother to create it on each boot, I hope you are using usb because using internal NAND drive is not recommended for containers persistance because it can wear out flash. In general I don't thing this is smart thing to do because you can't see files in that directory and if sometihng fails you cannot manually delete files in it.
 
Mitar
newbie
Topic Author
Posts: 35
Joined: Thu Mar 28, 2013 1:07 am

Re: Create .type file using script  [SOLVED]

Sat May 13, 2023 10:06 pm

ok, I actually tried it again and correct command is "/file add name=/temp/.type contents=container"
this single command does what I wanted, /file print was totally wrong usage, which is funny because old tutorials says that "print" is used to create files https://mikrotik-routeros.com/2016/06/t ... -routeros/

Who is online

Users browsing this forum: No registered users and 4 guests