Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 8th November 2010, 10:38 PM
mantas Offline
Registered User
 
Join Date: Sep 2010
Posts: 6
linuxfedorafirefox
Auto mount smb shares

I currently mount my smb shares by adding the appropriate line to fstab. Now my son also uses my laptop (F13 by the way) and I would also like to automount the shares for him but as a different user because there are some directories he should not have access to. What is the best way to accomplish this? Thank you
Reply With Quote
  #2  
Old 9th November 2010, 01:38 AM
jbkt23 Offline
Registered User
 
Join Date: Mar 2006
Posts: 510
linuxfedorafirefox
Re: Auto mount smb shares

This is a script that I wrote using mount.cifs from the smbclient package in samba. It won't work with versions of samba distributed after Fedora 12. If you have an older copy of the distro then you can extract mount.cifs and umount.cifs from it and copy to /usr/local/sbin/ . The binaries are arch version independent, as I've been copying them between distro upgrades. So here's my code:

# sharemount
#!/bin/bash
# sharemount <sharename 1> <sharename 2>
# This script will test for <server> on the network and then mount shares or
# issue an error message

share="$@"

if ping -w 2 -c 1 <server> && smbclient -NL <server>; then
echo "<server> is present"
for share in "$@" ; do
mkdir ~/$share
/usr/local/sbin/mount.cifs //<server>/$share ~/$share -o credentials=~/.samba/.$USERNAME
done

else
echo "The server <server> could not be reached. Is it on?"

fi

##################################### end ################################

I also wrote a logout script to delete the empty mount points when done:

# logoutsmb

#!/bin/bash
# logout <share 1> <share 2>
# this program un-mounts network shares and then calls gnome-session-save
# with the --logout option

share="$@"

for share in "$@" ; do

if [ -d ~/$share ]; then
/usr/local/sbin/umount.cifs /home/$USERNAME/$share
wait=2
rmdir /home/$USERNAME/$share
wait=1
fi
done

/usr/bin/gnome-session-save --logout

##################################### end ######################

This script will log you out when executed, if you don't want that then remove the last line.


You need to substitute the name or IP address of your server for <server> in the sharemount script.
__________________
jbkt23

Last edited by jbkt23; 9th November 2010 at 02:26 AM. Reason: Clarification
Reply With Quote
Reply

Tags
auto, mount, shares, smb

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot mount Windows shares AdrianRiley Servers & Networking 5 4th March 2010 07:00 PM
Cannot mount shares from WinXP jdogzilla Servers & Networking 0 21st July 2006 11:09 PM
mount smb/nfs shares safely axelseap Guides & Solutions (No Questions) 0 23rd January 2006 06:35 AM
mount smb-shares at boot? dezibel Servers & Networking 0 26th February 2005 10:41 PM


Current GMT-time: 08:28 (Thursday, 23-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat