Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I use gvfs script to mount my SAMBA share when my system starts. I run it at autostart. Here is the script:

#!/bin/bash

sleep 4

   wifi="'$(/sbin/iwconfig eth1 | egrep ESSID | cut -d '"' -f 2)'"

      if [ $wifi = "'deckoff'" ]; then 

 gvfs-mount smb://192.168.1.106/public

      fi
end script

It works great, but when network is down I have to manually re-connect. I added the same script to /etc/network/ifup.d, and as I expected, I am getting a warning

Could not change permissions for
/home/deckoff/MyBookLive/GVFS-mount

I suspect the reason is that the script that re-mounts at reconnect is run as sudo. So, ideally, I want a solution that runs the script every time network is connected as user. I will be happy if I get rid if the warning at the very least.

share|improve this question
    
please accept your own answer –  Ringtail Jan 15 '13 at 2:43
add comment

1 Answer

I fixed it this way:

STEP 1

I decided to use cifs

STEP 2

Added this script to /etc/network/if-up.d

#!/bin/bash

WL=$(iwconfig wlan0 | grep wlan0 | cut -d':' -f2)

if [ $WL == '"yournetworkname"' ]
then
echo "deckoff"
sudo mount -t cifs //192.168.1.106/Public/ /media/MyBookLive -o username=user,password=pass,uid=1000,nobrl,iocharset=utf8,codepage=unicode,unicode

fi

The name and the type of the wifi (wlan0) in my case should be changed to yours. The type can be seen with the command iwconfig

STEP 3

sudo visudo 

This command will let you mod which commands could be executed without sudo rights, by which users etc.

Add

deckoff ALL = NOPASSWD: /bin/mount
deckoff ALL = NOPASSWD: /bin/umount

This will let deckoff mount and umount drives without sudo rights

Restart

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.