LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 12-12-2003, 05:37 AM   #1
mule
Member
 
Registered: Aug 2003
Posts: 81

Rep: Reputation: 15
how to execute automatically a program/script after login


hi guys,

i struggle with samba with my linux-clients, as there is (for me) no real solution to mount my shares automatically:

fstab needs fixed entries per share, even with credentials, you need one entry per user. makes for me 5 mountpoints on one client.

so, i think, it would be a possibiliy to use a credentials-file within the users-dir. and then executing a shell-script after the login having someting like:

mount -t smbfs -o credentials=/home/$User/.credentials //server/share /$USER/mntdir


AND LET IT EXECUTE LINUX AUTOMATICALLY AFTER A SUCCESSFUL LOGIN!

so, i would get a kind of login-script as you have it in windows. does anybody know:

a) how to execute automatically this script after the successful login?

b) whether this shell-script would work?

THANKS for any reply

Cheers,
Roger
 
Old 12-12-2003, 01:57 PM   #2
demmylls
Member
 
Registered: Aug 2003
Location: AT
Distribution: Fedora Core 3
Posts: 404

Rep: Reputation: 30
i think there is one startup folder in the "/home/ur account" folder that act the same as windows start\all programs\startup
just place a link there a symbolic link in that folder and youoff and go
 
Old 12-12-2003, 02:41 PM   #3
ac1980
Member
 
Registered: Aug 2003
Location: Trento, Italy
Distribution: Debian testing
Posts: 394

Rep: Reputation: 30
'classical' linux user startup file is ~/.login placed in every user's home. Consider also changing the template for new users in /etc/skel

You can alternatevely leave homes unchanged and change /etc/csh.login and /etc/bash.bashrc, however note these will probably be launched again when a new xconsole is opened.
 
Old 12-12-2003, 03:27 PM   #4
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 47
I'm not too sure which "logon" you want to refer to...
Shell logon, samba logon, domain logon etc

If you want to mount a user's files as shares for other people to use, after they have connected to Samba, you can use the preexec and postexec functions in samba..
They are used to mount cdroms once someone browses the share, and remove the mount when they exit, but they can of course mount other things as well...
You can also run them as root using root preexec & root postexec

Give them an individual share to browse first then personalise the mount.
Make the mount directory one below the share directory so they can see all the possible mounts.

Last edited by peter_robb; 12-12-2003 at 03:29 PM.
 
Old 12-12-2003, 03:43 PM   #5
mule
Member
 
Registered: Aug 2003
Posts: 81

Original Poster
Rep: Reputation: 15
Thanks for your tips, i did as followed:

i placed a script called mount.sh in /etc/profile.d. I had to do someworkaround, as at this location, the system reloads this script at eachcall of bash or nautilus.My script is as followed:

#!/bin/bash
more /etc/mtab | grep smbfs > /home/$USER/EOFile
read ende < /home/$USER/EOFile
#echo $ende
if [ "$ende" = "" ]; then
sudo mount -t smbfs -o credentials=/home/$USER/.credentials,uid=$USER,gid=grosswiler,fmask=777,dmask=777,rw //morpheus/$USER /home/$USER/winpriv
sudo mount -t smbfs
fi
...and this works...somehow....
 
Old 12-12-2003, 03:50 PM   #6
scottpioso
Member
 
Registered: Jan 2003
Location: United States of America and damn proud of it!
Distribution: Ubuntu
Posts: 466

Rep: Reputation: 30
Hi Mule,

I read your dilemma. I had a similiar situation some time ago and this is what I read about in a huge samba book I bought. Have the windows boxes connect via network drives. You can do that with the Net Use command in the windows command prompt. Make certain to put in there persistent:yes to make certain the network drives will initalize at start up. Also, you can set your permissions file and folder specific should you wish.

I don't know if this is what you're looking for, but I thought it might help. Take care and good luck!
 
Old 12-13-2003, 04:22 AM   #7
mule
Member
 
Registered: Aug 2003
Posts: 81

Original Poster
Rep: Reputation: 15
hi scott,

Thanks for your idea. But the Window-Boxex are no problem. i put there a login-script into the netlogon-share. This is executed, as a Windows-Client authenticates itself on the samba-domain. WINDOWS MACHINES ARE NO PROBLEM! a sad fact, as i have more linux-clients...

if you want to, i send you my login.bat placed in the netlogon-share of my samba-server, perhaps this helps you also a little bit....always appreciated to help people trying to help me!!
 
Old 12-13-2003, 08:54 AM   #8
scottpioso
Member
 
Registered: Jan 2003
Location: United States of America and damn proud of it!
Distribution: Ubuntu
Posts: 466

Rep: Reputation: 30
Oh, this is a domain controller?? I have never set up a Linux DC. Sorry.
 
Old 12-13-2003, 02:44 PM   #9
mule
Member
 
Registered: Aug 2003
Posts: 81

Original Poster
Rep: Reputation: 15
this is no problem, scott, just a few more minutes of engagement for the installation, but extra for a network at home with several clients....the samba-pdc (i have samba version 3.0.x) is very reliable and some magazine say even quicker than windows 2003. at least: no cost for licenses on the server....

if you are intersted: o'reilly put their book from samba (printed: about 600 pages) online, without any cost for everybody at http://www.oreilly.com/catalog/samba2/

if you need any more help (for your windows-clients, seems i don't bring the linux-clients proper in network before christmas :-) let us know...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
execute program only once during login tcma Linux - General 6 11-03-2004 08:55 AM
i need to write a program it has to execute automatically ykirankumar Linux - Software 5 08-31-2004 12:34 AM
execute php script automatically? brandnewbie Linux - Newbie 1 08-14-2004 05:42 AM
Trying to execute bash script upon login?? mr-d-2003 Linux - Newbie 4 10-30-2003 03:15 PM
How to execute script after login? gmitra Linux - General 2 02-19-2003 11:39 AM


All times are GMT -5. The time now is 10:11 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration