Tiny Core Linux

Tiny Core Extensions => TCE Q&A Forum => Topic started by: bkm on April 04, 2017, 05:59:37 AM

Title: [SOLVED] Any TCL Samba Epxerts here? I have a unique problem.
Post by: bkm on April 04, 2017, 05:59:37 AM
I know how to set up samba to do the share that I want and how to make it persistent. But that is not quite what I need.

I need Samba to start on boot every time with my share settings, but the folder that I want to share is one that I do not want to be persistent. I want to open a share that I can drop files into from a MS Windows environment, but if I lose power I want the files to disappear, and when the box reboots, I want an empty share folder again. This is where it gets tricky, the folder (that disappears on reboot) must be owned by a "nobody" user, all files going into the folder must be 777 permissions, and subfolder creation must be 777 permission. This way any user or anonymous users can drop files into the share from the local network, even though they will all be lost on reboot.

All of this is intentional in order to reduce the chances the box could become infected with malware, and to reduce the number of write operations to the USB drive. I will be dropping 2 fresh files into the share folder every 10 minutes during the 8 hour work day. At the end of the work day I will copy the most recent files from the share to a backed up folder that will be written to the USB drive. Seven hours later (after the close of business) I will have the TCL box reboot to start fresh for the next business day and during boot I want to copy the last backed up version of the files to the share folder again.

All of the instructions I have found so far tell me how to make the share with all files persistent along with the settings. I just want the settings to be persistent and share folder to be created in memory on each reboot so I can populate it throughout the day. However it is the permissions that I need for the share folder that have really lost me. Not sure how to do this unique configuration.

Can anyone point me to a way to accomplish this mixed bag of persistent and permission settings?

Thanks,

BKM
Title: Re: Any TCL Samba Epxerts here? I have a unique problem.
Post by: Rich on April 04, 2017, 06:43:51 AM
Hi bkm
If you create your subfolder under  /tmp  it will be in RAM. You can do this in  bootlocal.sh  as well as setting the folders
owner and permissions. If memory serves, permissions and owner of the actual files are settings in the SAMBA config file.
Title: Re: Any TCL Samba Epxerts here? I have a unique problem.
Post by: bkm on April 04, 2017, 07:05:22 AM
How brilliantly simple!! I was of course over thinking the whole mess. I will give this a try and see if I can make it work as I hoped. Will report back later. 

Thanks for the moment of clarity  :-[

BKM
Title: Re: Any TCL Samba Epxerts here? I have a unique problem.
Post by: Rich on April 04, 2017, 07:10:20 AM
Hi bkm
How brilliantly simple!!
Brilliant is not a term often used when referring to me, though simple is. ::)
Title: Re: Any TCL Samba Epxerts here? I have a unique problem.
Post by: coreplayer2 on April 04, 2017, 08:58:00 AM
Title: Re: Any TCL Samba Epxerts here? I have a unique problem.
Post by: bkm on April 04, 2017, 10:12:29 AM
Well, erm...

I  created a folder /tmp/myfiles  as the location for my samba share so that it would go away when TCL was rebooted.
Well, imagine my surprise when it did just that! Then my further surprise when on reboot /tmp/myfiles didn't exist anymore and samba just sat there like a lost penguin not knowing what to do next.  :o

Ugh! Ok, so now it appears that I need to figure our how to recreate the /tmp/myfiles on reboot and before samba restarts so that it has something to share. Any ideas?

BKM
Title: Re: Any TCL Samba Epxerts here? I have a unique problem.
Post by: gerald_clark on April 04, 2017, 10:15:02 AM
Create /tmp/myfiles with the proper permissions in bootlocal.sh before you start the server.
Title: Re: Any TCL Samba Epxerts here? I have a unique problem.
Post by: Misalf on April 04, 2017, 11:36:31 AM
I would do it in  /opt/bootlocal.sh  like so
Code: [Select]
NETSHARE="/tmp/myfiles"
mkdir -p "$NETSHARE"
cp /mnt/sda1/file1 /mnt/sda1/file2 "$NETSHARE"
chown -R "$(cat /etc/sysconfig/tcuser)":staff "$NETSHARE"
chmod -R 777 "$NETSHARE"
/usr/local/etc/init.d/samba start
Title: Re: Any TCL Samba Epxerts here? I have a unique problem.
Post by: bkm on April 04, 2017, 11:57:19 AM
Thanks Misalf

But what exactly does this line do for me?
Code: [Select]
chown -R "$(cat /etc/sysconfig/tcuser)":staff "$NETSHARE"
It "appears" to my novice experience that the command uses the cat command to list the users of TCL and assigns them all to ownership of the samba share folder? Is that right? ???

I would just like to understand a little about why it works. Any tid-bit you can toss my way will be appreciated.

Thanks.

BKM
Title: Re: Any TCL Samba Epxerts here? I have a unique problem.
Post by: bkm on April 04, 2017, 12:10:43 PM
Oo.. Oo..

I noticed you also specify the /mnt/sda1 in your copy command. Is the /mnt reference really needed? Is that maybe why my first attempt the files did not seem to copy at all?

I used:

cp /home/tc/safefiles/. /tmp/myfiles/

and it came up blank. Nothing in the /tmp/myfiles folder after reboot, but the files still existed in the /home/tc/safefiles folder.

BKM
Title: Re: Any TCL Samba Epxerts here? I have a unique problem.
Post by: Rich on April 04, 2017, 01:09:31 PM
Hi bkm
Maybe you meant:
Code: [Select]
cp /home/tc/safefiles/* /tmp/myfiles/
Title: Re: Any TCL Samba Epxerts here? I have a unique problem.
Post by: bkm on April 04, 2017, 02:10:56 PM
Hey Rich,

Either way it didn't work with the ( . ) or the ( * )

The only way I got it to work was using the exact file name in full path for each of the 2 files.

And with that my interesting Samba project is finally running, resetting itself after reboot, and moving the last known good copy of the files back into the shared directory.

Thank you to ALL. This has been a wonderful learning experience in Samba for TinyCore. So I will mark the first post as solved.

Or so I thought... I can't seem to find a way to edit the original post to mark it as SOLVED

BKM
Title: Re: Any TCL Samba Epxerts here? I have a unique problem.
Post by: Misalf on April 04, 2017, 03:14:31 PM
Code: [Select]
cp /mnt/sda1/file1 /mnt/sda1/file2 "$NETSHARE"
was just an example, as I don't know where you copy your files from.  /home/tc/  should work just as well.
I don't know why
Code: [Select]
cp /home/tc/safefiles/* /tmp/myfiles/
doesn't work for you.

Code: [Select]
chown -R "$(cat /etc/sysconfig/tcuser)":staff "$NETSHARE"
Because  bootlocal.sh  runs as root, I tend to read  /etc/sysconfig/tcuser  as it contains the user name used after login.
By default, this 'translates' to
Code: [Select]
chown -R tc:staff "$NETSHARE"
Title: Re: [SOLVED] Any TCL Samba Epxerts here? I have a unique problem.
Post by: Rich on April 04, 2017, 05:29:53 PM
Hi bkm
So I will mark the first post as solved.

Or so I thought... I can't seem to find a way to edit the original post to mark it as SOLVED

BKM

Done.