LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   how can i run smbmount automatically when a user login (http://www.linuxquestions.org/questions/linux-networking-3/how-can-i-run-smbmount-automatically-when-a-user-login-183661/)

rddreamz 05-20-2004 07:04 AM

how can i run smbmount automatically when a user login
 
hi all,
i want to use winxppro as my file server and linux(mandrake9.1)as a client.situation is of following
1.i have 5 directories on ntfs partitions on my winxppro(a,b,c,d,e,f).
2.i have 5 different users 1,2,3,4,5 who has diferent partitions on those directories.
3.i have 5 users with smbpaaswd created on my linux pc .
4.for each user i have written a scripts file where i have actually placed smbmount commands with proper permissions set for each user for each directory.e.g
smbmount //win/a /home/1/win rw,username=<>,password=<>,uid=<>,dmask=0765,fmask=0765

5.i have five scripts written for each user with different set of permiossions on diffferent directories

6. when user 1 runs this it asks for passwords for different directories and after providing proper passwords he can share directories on winxp with proper rights.

but users find it reallydifficult to provide passwords for each directories.so i want to run these scritps whenever a perticuler user logs in (locally), when they logoff locally these all mount points should be umounted automatically.

i belive there should be solution to this and somebody can help me to do this.

thanks in advance.

tonyfreeman 02-15-2006 06:40 PM

smbmount during gui login
 
Sorry I don't have an answer ... I have the basic same question.

Where does one put the smbmount command in order to mount drives in a user's home directory when that user logs in to a GUI (such a gnome, kde, etc):

smbmount //blahblah/blah ~/drives/blah rw,exec,guest

I would rather the smbmount command not run when the user accesses his/her profile via other mechanism such as ssh. Only mount the drives when he/she sits down at the workstation and opens a desktop manager (gnome, kde, enlightenment, fluxbox, etc).

Any ideas?

soulestream 02-15-2006 08:50 PM

.bashrc or .bash_profile should do it

Folder permissions should be set on the ntfs side, not on the client side.

You shouldnt need smbpasswd at all. The only time that should matter is if you are logging into a domain controller.

you can use fstab and sudo, probably with better security as well as then using credentials files(instead of username=blah, password=blah)that are only visible by root.

soule

tonyfreeman 02-17-2006 10:14 PM

.bashrc and .bash_profile not good to automount drive
 
Hello soulestream,

Thanks ... but adding smbmount to those files doesn't work as I'd like.

.bash_profile doesn't mount the drives at all.
.bashrc mounts them every single time I open a terminal such as gnome-terminal (multiple mounts of the same drive start stacking up for the same user).

Here's the code that I put at the end of .bash_profile and then at the end of .bashrc:

Code:

# mount smbshares to drive directory:
smbmount //linkstation/books  ~/drives/books  -o guest,rw,exec
smbmount //linkstation/games  ~/drives/games  -o guest,rw,exec
smbmount //linkstation/movies ~/drives/movies -o guest,rw,exec
smbmount //linkstation/music  ~/drives/music  -o guest,rw,exec
smbmount //linkstation/share  ~/drives/share  -o guest,rw,exec

So I started fooling with /etc/fstab. The fstab file chokes when I add an entry like this:

Code:

//linkstation/share ~/drives/share smbfs rw,exec,guest 0 0
... and a command like this:

Code:

sudo mount -a
Could not resolve mount point ~/drives/share

Anyone have ideas about how to automount drives (be it in the user's home directory or elsewhere) when the user logs into a desktop manager (gnome, kde) rather than when the user opens a ssh session or every time a terminal is opened.

I'd also like the mount points to be release when the user logs out.

-- Tony

Bugger 02-18-2006 03:10 AM

well,
Better write all the mount commands in a shell script and call it form .bashrc...
but first check for already mounted file system in u r script file...
like
#!/bin/bash
count=`mount | grep -c drives/books`
if [ count -lt 1 ]; then
# u r mount statement goes here
fi

I feel you have to apply conditions for all your file systems... and the call this script from any file which is executed automatically, say at startup or say .bashrc

Regards,
ANU


All times are GMT -5. The time now is 03:27 PM.