Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have set up a laptop with ubuntu, linked to server with nfs and set up MPD. This all works great, but the problem is on startup the NFS drive tries to mount at boot up, but the wireless doesn't connect until I log in, at which point the NFS isn't mounted and then MPD stalls. I have to manually re-mount and restart MPD. To start with I have written a script to mount the nfs drive after the network is up, I plan on adding a command to start the MPD after I figure out how,
What I would like to know is how to get this script to run after I log in and after everything else has started. I have been reading forums for a few days trying to figure it out but I just ended up getting really confused.
My understanding so far, place script.sh in /etc/profile.d, make it executable for all, then run update-rc.d default Is this correct? When I run the script manually it needs root, is this because I havent used the correct chmod command? I used chmod +x.
From reading another post on NFS mounting I know that there is another way to get the drive to mount after network is up, but I would like to get the script to run anyway and I'm not sure if this method would work with wireless.
Thanks in advance if anybody is able to point me in the right direction.
Distribution: Fedora 18, Slackware64 13.37, Windows 7/8
Posts: 386
Rep:
Quote:
Originally Posted by chrisgreg
Hi
I have set up a laptop with ubuntu, linked to server with nfs and set up MPD. This all works great, but the problem is on startup the NFS drive tries to mount at boot up, but the wireless doesn't connect until I log in, at which point the NFS isn't mounted and then MPD stalls. I have to manually re-mount and restart MPD. To start with I have written a script to mount the nfs drive after the network is up, I plan on adding a command to start the MPD after I figure out how,
What I would like to know is how to get this script to run after I log in and after everything else has started. I have been reading forums for a few days trying to figure it out but I just ended up getting really confused.
My understanding so far, place script.sh in /etc/profile.d, make it executable for all, then run update-rc.d default Is this correct? When I run the script manually it needs root, is this because I havent used the correct chmod command? I used chmod +x.
From reading another post on NFS mounting I know that there is another way to get the drive to mount after network is up, but I would like to get the script to run anyway and I'm not sure if this method would work with wireless.
Thanks in advance if anybody is able to point me in the right direction.
The reason you need root access is because users can't mount file-systems by default. You will need to set the setuid bit in order to allow users to run mount (or you can edit /etc/sudoers using the visudo command).
Code:
chmod +s /sbin/mount
If you need to wait for the user to be logged in before running your script then you want that code to run in ~/.bash_profile which will run after you are logged in. I'm not too keen on init.d as suggested above so I can't comment on that advise.
All you need to do to resolve your problem is to allow users to execute mount and then run your script in ~/.bash_profile.
Hope this helps
Last edited by thund3rstruck; 01-27-2012 at 10:14 PM.
Reason: afterthought
Thanks for the advice. Ive tried init.d and that seemed to cause problems because of the wireless not being active, I might try this on another desktop just to see if I can get it to work.
So if I put it in bash_profile, is there anything I have to update as you would with init.d? Or is it just a case of making the script executable and putting it in the directory. Sorry if these are obvious questions, Ive never installed scripts before.
Distribution: Fedora 18, Slackware64 13.37, Windows 7/8
Posts: 386
Rep:
Quote:
Originally Posted by chrisgreg
So if I put it in bash_profile, is there anything I have to update as you would with init.d? Or is it just a case of making the script executable and putting it in the directory. Sorry if these are obvious questions, Ive never installed scripts before.
No, init.d has nothing to do with running scripts after the user logs in. Anything in bash_profile will get run every time the user logs in. So if you have a working script then execute it from .bash_profile.
For example, in my bash_profile I call a script that maps the user's Windows home share.
Distribution: Fedora 18, Slackware64 13.37, Windows 7/8
Posts: 386
Rep:
Quote:
Originally Posted by WarTurkey
You'll also need to invoke the command as "/sbin/mount", because "/sbin" is not in your path by default, when you're not root.
Yea, I don't know about all that. Mount is in /bin and anyways /sbin is in my regular users path. I run mount.cifs on all my linux without specifying the /sbin path.
Code:
$ ls -all $(which mount.cifs)
-rwxr-xr-x. 1 root root 38992 Dec 9 21:09 /sbin/mount.cifs
$ ls -all $(which mount.cifs)
-rwsr-sr-x 1 root root 30424 2011-09-30 18:36 /sbin/mount.cifs
$which mount
/bin/mount
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
This is the output from those command, the /sbin/mount.cifs bit is highlighted red. This is after I have run sudo chmod +x /sbin/mount.cifs, and sudo chmod +x /bin/mount. I'm not really sure what I am supposed to be doing. If I try and run the script manually it says mount:only root can do this, which we already know.
Distribution: Fedora 18, Slackware64 13.37, Windows 7/8
Posts: 386
Rep:
Quote:
Originally Posted by chrisgreg
I'm not really sure what I am supposed to be doing. If I try and run the script manually it says mountnly root can do this, which we already know.
post the output of:
Code:
ls -all $(which mount)
because if you set the sticky bit correctly on mount then all users can now mount filesystems. In other words when you type mount it now returns the help page instead of a message that says only root can do this.
/dev/sda5 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nodev)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
none on /dev type devtmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
none on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
gvfs-fuse-daemon on /home/chris/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=chris)
/dev/sda5 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nodev)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
none on /dev type devtmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
none on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
gvfs-fuse-daemon on /home/chris/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=chris)
what does this all mean?
When you run mount on its own without any parameters it lists all the devices that are currently monted (that's a really handy feature too!)
You should be all set now. Try to have a regular user mount something.
Distribution: Fedora 18, Slackware64 13.37, Windows 7/8
Posts: 386
Rep:
Quote:
Originally Posted by chrisgreg
I still get the message mountnly root can do that
Ugh... I accept my apologizes. When you set the sticky bit on mount you also have to have that filesystem defined in /etc/fstab with the user mountable option. Now I remember why we don't do it that way.
Hate to lead you down another path (maybe someone here can better walk through using the sticky bit with mount) but the way we (my company) allows users to mount is by editing /etc/sudoers (via visudo)
Code:
# Edit sudoers
sudo visudo
# add this line to the end of the file:
# Allow members of the cdrom group to mount file systems (BE CAREFUL WITH THIS)
%cdrom ALL=NOPASSWD:NOEXEC:/bin/mount,/bin/umount
Now any user in the cdrom group can mount file-systems without requiring a password or anything:
Code:
sudo mount [parms] [source] [dest]
We usually create a security group called smbusers and add users into that group that have Windows shares and instead of granting those users the ability to use mount blatently we allow them to use /sbin/mount.cifs (which is exclusively for windows shares).
Hope this resolves your problem and I aoplogize for leading you down the sticky bit path
To permit user mounts without giving away the keys to the kingdom, you could try adding something like this to /etc/sudoers:
Code:
ALL ALL = (ALL) NOPASSWD: /bin/mount -o loop /usr/local/isos/*.iso /media/cdrom*
ALL ALL = (ALL) NOPASSWD: /bin/mount /dev/cd* /media/cdrom*
ALL ALL = (ALL) NOPASSWD: /bin/mount /dev/dvd* /media/cdrom*
ALL ALL = (ALL) NOPASSWD: /bin/umount /media/cdrom*
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.