3

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.

0

1 Answer 1

2

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .