looking for a script

Hi,
I’ve just created a suse based file server in a windows enviroment, given that samba is not as easy to create file shares as windows I have set the samba.conf to include a custom conf file that can be edited by members of our team to create new shares.
We create an individual share for each user and i would like a script that can be run as a cron job to detect a new folder being created in /data/shares/users (typically firstname.surname) and append the users.conf file in the samba directory so that when the samba service is restarted (daily via a cron) it enables the new shares.

Could anyone assist me with this at all?
Thanks.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Things that would help:

A template file’s contents for the user’s conf.
A working user’s conf file contents (to see how the template is modified).
The location of the destination conf files.

If your user’s conf files were named the same thing as their respective
shared directories (firstname.lastname) then you could just loop through
the list of directories in /data/shares/users and look for corresponding
files in your Samba conf directory; if any don’t exist, copy the template
to create the new file and then replace values inside it as necessary.
Assuming there are only directories in /data/shares/users:

<code interpreter="/bin/bash">
#!/bin/bash
for i in find /data/shares/users -type d -printf '%f ' 2>/dev/null; do
if -e /etc/samba/conf.d/$i ]; then
echo “$i exists” >&2
else
cp /etc/samba/template.conf /etc/samba/conf.d/$i
sed -i -r ‘s/template.user/new.user/g’ /etc/samba/conf.d/$i
fi
done
</code>

Something like that. Untested as a whole, but I think the individual
lines should work.

Good luck.

On 02/11/2011 09:36 AM, martyn collis wrote:
>
> Hi,
> I’ve just created a suse based file server in a windows enviroment,
> given that samba is not as easy to create file shares as windows I have
> set the samba.conf to include a custom conf file that can be edited by
> members of our team to create new shares.
> We create an individual share for each user and i would like a script
> that can be run as a cron job to detect a new folder being created in
> /data/shares/users (typically firstname.surname) and append the
> users.conf file in the samba directory so that when the samba service is
> restarted (daily via a cron) it enables the new shares.
>
> Could anyone assist me with this at all?
> Thanks.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJNVW3IAAoJEF+XTK08PnB53QAP/iVNM6hhQQPF4uk59sV7U6Bc
bMlBNzHhS28jn475hlRVHy3rAQCjXCb9fgJ3OF+lMx9vKrOuiTAgxapJYp/qXwPN
rC3QfLIs4xVT2ShOQcRCDoZyR6/fMygaxHiwx4HRAN7YRWVxWFFRimyBt1Pp3Sgu
U13qLeYyd6E3z1yv9GLqiqrpuGA/8+SdqadjtprwEWvaLdEpZT8DJzjvJKP2bzHs
7tMIB7DDgpTNUDNpbbdz7NhQcPO53UTSWLgDjOBPEjmzvynIh5Ywy7pSN50/rJlv
kVwfahinJXE+mx7hnwjdq2cWD5yB5JUNGrTGeLbgj/+bxnZMpMcbwqLN9uIUot88
kx0w7prGCwwmvCX+N2Afo+FR3UN0ThFe/lshGuaof8DZibCTHlTaJV1j3078Uf0f
NsuYwl3GBXde7lvRkkHV4HbpV4o37ZI414Z7hklruQQ5tJnmae1m3oUxLcj6b5qF
izggsE07how1pZptGJn0cxlE8G25i78xcU8xuSIil1iWf6RzyTOumSJAd0Q/Opjr
vXjs8mtN/AIXb6aU62GXG1VEVQt21O85ENkBC4qaP1W0wRTjqvRXpJqilgEf0BAH
ACLAORfyDmSbUu8kYhYzCNIR6JHxc/DluQtQ4xGj+jNNW57hG/Ur6rADtHaBp2Og
62SwySnWHjBvubH81zEN
=T0qn
-----END PGP SIGNATURE-----

Hi,
Sorry about my lack of specifics,
I’ll try and be more specific in my request:

When I create a new user share i preform the following:

  1. create a new folder in /data/shares/users (typically firstname.lastname)
  2. I then create an entry in /etc/samba/users.conf
    example of the data in users.conf:

[firstname.lastname$]
	admin users = monbs\firstname.lastname
	comment = Firstname.lastname
	inherit acls = yes #do not change
	path = /data/shares/users/firstname.lastname
	read only = no

  1. Samba then restarts at the schedualed time to make the new share live.

In the smb.conf file it has the default lines and includes a line:
Include = /etc/samba/users.conf

this enables the users share and is configured to allow other members of my team be able to add lines to the conf file accordingly.
I know i can add the share using SWAT however when i attempted this on a development system it caused a corruption in the SMB.conf and stoped authentication from our Active Directory server.

The script i need is to automate the above process meaning that when i create a new folder a script instantly detects the presence of the new folder and creates an entry in the users.conf accordingly.

Thanks All.

Actually, these days it is as easy to create shares as Windows. Your users could use the Personal File Sharing" of the System submenu.
Or they can get to “Personal File Sharing” from the Control Center menus.

They would enable Public sharing over the Network with or without password and then they can either use the “Public” folder or share other folders, SMB/CIF sharing occurs instantly.
No updates to smb.conf necessary.

OTOH, AFAIK, all you need to add to your script to copy entries into user.conf
would be a test if the folder exist

sleep 20s
if test -d /data/shares/users/firstname.lastname ]
then
cp -p firstname.lastname /usr/share/user.conf
fi

You are aware that each Samba account automatically gets a share that is mapped to their home directory? This is the [homes] share.

maybe this is better

Unfortunately, none of these solutions would work.
Our openSuse box is implemented as a File Server (we didnt require all the features of SLES thus using the open variety).
None of our users log onto the server directly (apart form members of the IT department and thats only when somethng goes very wrong).

I hope that helps.

No it doesn’t.

I’m not sure what problem you’re trying to solve.
Perhaps you can restate your problem, configuration and what’s needed.