Xfce Forum

Sub domains
 

You are not logged in.

#1 2020-01-15 04:40:55

Aravisian
Member
Registered: 2019-08-17
Posts: 196

Automount Remote folder at Login

A member asked this over on the Zorin forum. He would like to have a remote folder on a windows machine automount. However, he would like it to automount AFTER login.
He already has set up the network to start at boot rather than login, so we cannot set it to wait for network.
All I can think of (And other suggestions welcome) would be to create a script to run at login that mounts the remote folder. But I'm not confident enough to try writing it.
Any suggestions?

Offline

#2 2020-01-15 12:00:03

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 6,158

Re: Automount Remote folder at Login

Personally, I use autofs for this. The drives aren't actually mounted until you click on (or enter) the mount point. For more info, see https://wiki.archlinux.org/index.php/Autofs.

However, if you are looking for a script to run, you can use gvfs/gio to automate mounts. To make so that you don't have to enter in credentials, first create the file ~/.creds with the following content:

username
workgroup
password

...so it looks something like this:

toz
WORKGROUP
mypassword

Then you can use a command like this:

gio mount smb://Server/Music < .creds

...to mount the remote share (in this case an smb share). It will show up in thunar as a mounted volume in the NETWORK section.

You can create a script to do multiple mounts:

#!/bin/sh 
gio mount smb://Server/Music < .creds
gio mount smb://Server/Pictures < .creds
gio mount smb://Server/Videos < .creds

...and add it to your autostart applications to have it start when you log in.

Offline

#3 Yesterday 05:03:09

Aravisian
Member
Registered: 2019-08-17
Posts: 196

Re: Automount Remote folder at Login

Toz, you are amazing. Thanks. However, this is what he had to say:

TK1
Unfortunately, this doesn't work because I don't want a password in a clear text file.

I tried putting only the user and domain in the .creds file hoping it would prompt me for the password, but it doesn't. I tried this from a terminal with that .creds file, but it doesn't prompt and wait for the password.

If I could get it to prompt me for the password, I think this would work, but I don't see an option for that.

Offline

#4 Yesterday 08:50:46

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 6,158

Re: Automount Remote folder at Login

Okay, without a credentials file asking for password, you could use:

gio mount smb://WORKGOUP\;USER@SERVER/SHARE

However, you need to manually run this in a terminal window because it will ask you to enter in a password. You could use something like zenity to prompt for a password in a window if you want to automate it.

Is autofs out of the question? It really is the simpler way.

Offline

#5 Today 03:59:48

tk1
Member
Registered: Today
Posts: 1

Re: Automount Remote folder at Login

Hi ToZ, I'm the one from the other forum asking about this.  I appreciate Aravisian doing me a favor by being the middle man but that's not fair to him or her, so I'll just jump in here.


Autofs is not feasible for me because I have the network starting before logging in (I know this is not the default), and I don't want the share mounted prior to logging in.  Another reason is it will auto-unmount it after a period of time and I don't want that.

From a terminal, this worked:

zenity --password | gio mount smb://windowspc\;user@windowspc/sharename$

This does prompt me and works after the password is entered, although it's apparently discouraged because "GtkDialog mapped without a transient parent".  I don't know what that means.

When I tried putting the same line in Startup Applications, it did not mount the share even though it did prompt for a password after the log in.

Thank you for your help and suggestions!

tk1

Offline

#6 Today 04:40:02

Aravisian
Member
Registered: 2019-08-17
Posts: 196

Re: Automount Remote folder at Login

tk1 wrote:

Hi ToZ, I'm the one from the other forum asking about this.  I appreciate Aravisian doing me a favor by being the middle man but that's not fair to him or her, so I'll just jump in here.

Him.
It's a great forum and Toz is among the most helpful Linux Forum contributors I've seen.
Welcome to it.

Offline

#7 Today 13:12:17

MrEen
Member
Registered: 2019-04-19
Posts: 101

Re: Automount Remote folder at Login

The warning "GtkDialog mapped without a transient parent" is a common thing to see, especially when using Zenity, and is a harmless warning.

I didn't take proper notes, but I have 2 ways of stopping the warning. I believe the second allows actual errors to still come through:

zenity --info --text "hello" 2> /dev/null
zenity --info --text "hello" 2> >(grep -v 'GtkDialog' >&2)

As for Startup Applications, I'm guessing the pipe is a bashism so it might need to start with

bash -c 'zenity --password | gio mount smb://windowspc\;user@windowspc/sharename$'

Someone may correct me on that one.

Offline

#8 Today 13:14:01

MrEen
Member
Registered: 2019-04-19
Posts: 101

Re: Automount Remote folder at Login

If I'm correct, the full line would be

bash -c 'zenity --password | gio mount smb://windowspc\;user@windowspc/sharename$ 2> >(grep -v 'GtkDialog' >&2)'

Offline

#9 Today 13:30:10

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 6,158

Re: Automount Remote folder at Login

tk1 wrote:

When I tried putting the same line in Startup Applications, it did not mount the share even though it did prompt for a password after the log in.

I'll bet it's because of the escaped characters - the mini-interpreter that it uses is not that robust.  @MrEen's suggestion should work.

You might also want to have a look at the gigolo app. From what I remember, you can create your connection "bookmarks" and set them to automount. Then all you would need to do is add gigolo to your autostart.

Welcome to the forums, btw.

Offline

Board footer

Powered by FluxBB