WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [SOLVED] Any TCL Samba Epxerts here? I have a unique problem.  (Read 3037 times)

Offline bkm

  • Jr. Member
  • **
  • Posts: 72
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
« Last Edit: April 04, 2017, 05:20:21 PM by Rich »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Any TCL Samba Epxerts here? I have a unique problem.
« Reply #1 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.

Offline bkm

  • Jr. Member
  • **
  • Posts: 72
Re: Any TCL Samba Epxerts here? I have a unique problem.
« Reply #2 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

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Any TCL Samba Epxerts here? I have a unique problem.
« Reply #3 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. ::)

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: Any TCL Samba Epxerts here? I have a unique problem.
« Reply #4 on: April 04, 2017, 08:58:00 AM »

Offline bkm

  • Jr. Member
  • **
  • Posts: 72
Re: Any TCL Samba Epxerts here? I have a unique problem.
« Reply #5 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

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: Any TCL Samba Epxerts here? I have a unique problem.
« Reply #6 on: April 04, 2017, 10:15:02 AM »
Create /tmp/myfiles with the proper permissions in bootlocal.sh before you start the server.

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: Any TCL Samba Epxerts here? I have a unique problem.
« Reply #7 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
Download a copy and keep it handy: Core book ;)

Offline bkm

  • Jr. Member
  • **
  • Posts: 72
Re: Any TCL Samba Epxerts here? I have a unique problem.
« Reply #8 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

Offline bkm

  • Jr. Member
  • **
  • Posts: 72
Re: Any TCL Samba Epxerts here? I have a unique problem.
« Reply #9 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

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Any TCL Samba Epxerts here? I have a unique problem.
« Reply #10 on: April 04, 2017, 01:09:31 PM »
Hi bkm
Maybe you meant:
Code: [Select]
cp /home/tc/safefiles/* /tmp/myfiles/

Offline bkm

  • Jr. Member
  • **
  • Posts: 72
Re: Any TCL Samba Epxerts here? I have a unique problem.
« Reply #11 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
« Last Edit: April 04, 2017, 02:14:12 PM by bkm »

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: Any TCL Samba Epxerts here? I have a unique problem.
« Reply #12 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"
Download a copy and keep it handy: Core book ;)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: [SOLVED] Any TCL Samba Epxerts here? I have a unique problem.
« Reply #13 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.