LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Samba share script advice (https://www.linuxquestions.org/questions/linux-general-1/samba-share-script-advice-741491/)

Plato 07-20-2009 03:07 PM

Samba share script advice
 
This is my first time posting, and just ran into a little problem with samba. Im trying to make a script that will create a / directory, and make that directory a samba share. What I am wondering is if a samba share can even be created in a script. I understand that the /etc/samba/smb.conf has to be editted to create a share, or can be done in Samba gui. Any input is much appreciated. Thank you in advance. :confused:

mjlouis 07-21-2009 04:46 PM

If you want it scripted, then GUI is not really an option. You may want to experiment with >> as this will append data to a file.
If you have file1 and file2 then the following will stick the contents of file1 at the end of file2:
Code:

cat file1 >> file2
file1 could contain your share entry and file2 is your smb.conf - of course, you're going to try this with some harmless file1 and file2 to test it out *before* running wild with your smb.comf aren't you? :-)

Plato 07-22-2009 01:23 PM

Solved
 
Ive got it working now. Thanks for the spark mjlouis. This is the code I'm using below that adds to the configuration file. Earlier in the script i prompt for a username, hence the $NAME's.

Code:

echo [$NAME] >> /etc/samba/smb.conf
echo path = /folder >/etc/samba/smb.conf
echo valid users = $NAME >> /etc/samba/smb.conf
echo    >> /etc/samba/smb.conf



All times are GMT -5. The time now is 03:02 AM.