You are not logged in.

#1 2021-11-07 07:52:12

cloverskull
Member
Registered: 2018-09-30
Posts: 207

How to run gdfs to mount Google Drive once network is connected?

Hey friends, what would folks here recommend as the most graceful means of auto-connecting to Google Drive once a network connection has been established?

I'm thinking some sort of systemd script that relies on systemd-networkd-wait-online.service ... but am not 100% sure and could use a hand smile

What I want to do is, as my user (i.e., _not_ as root), run the following command when the network connects:

gdfs -o allow_other default ~/Google\ Drive

And then I would like to automatically unmount the directory once the network disconnects or there's a shutdown/reboot command. I've confirmed the above command works as expected.

Thoughts/advice? Thanks!

Offline

#2 2021-11-07 12:53:38

Morta
Member
Registered: 2019-07-07
Posts: 660

Re: How to run gdfs to mount Google Drive once network is connected?

Why not rclone?

Offline

#3 2021-11-07 16:13:54

cloverskull
Member
Registered: 2018-09-30
Posts: 207

Re: How to run gdfs to mount Google Drive once network is connected?

Morta wrote:

Why not rclone?

While that didn't fix the auto-mount question I posed earlier, this /did/ lead me down an rclone rabbit hole and now I have gdrive/dropbox/mega all working with it smile But I'd still like to find a way to auto-mount them to my user directories upon establishment of network connection and then automatically unmount when the connection goes away.

Offline

#4 2021-11-07 17:41:57

Morta
Member
Registered: 2019-07-07
Posts: 660

Re: How to run gdfs to mount Google Drive once network is connected?

You can make a automount file and activate with systemd. Look at the wiki...

Offline

#5 2021-11-07 17:55:00

Morta
Member
Registered: 2019-07-07
Posts: 660

Re: How to run gdfs to mount Google Drive once network is connected?

cat /etc/systemd/system/home-backup.automount 
[Unit]
Description=Automount Backup

[Automount]
Where=/home/backup

[Install]
WantedBy=multi-user.target
[morta@5erver ~]$ cat /etc/systemd/system/home-backup.mount
[Unit]
Description=Mount NFS Backup at boot

[Mount]
What=192.168.11.96:/export/Backup_Server
Where=/home/backup
Options=vers=3
Type=nfs
TimeoutSec=30

[Install]
WantedBy=multi-user.target[morta@5erver ~]$ 

Is a sample for a nfs3 share. It's boot automatically after the network is up...

Last edited by Morta (2021-11-07 18:02:52)

Offline

#6 2021-11-07 18:04:49

archqt
Member
Registered: 2015-04-29
Posts: 200

Re: How to run gdfs to mount Google Drive once network is connected?

I use rclone to mount my drive on a directory. After i configured it to be able to mount it
I started this on plasma in service at startup

rclone mount MyDrive:  /home/user/MyGoogleDrive 

Offline

#7 2021-11-07 23:17:55

cloverskull
Member
Registered: 2018-09-30
Posts: 207

Re: How to run gdfs to mount Google Drive once network is connected?

I made a simple systemd script (~/.config/systemd/user/rclone-mount-gdrive.service):

[Unit]
Description=RClone Google Drive Mount Service
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
StandardOutput=journal
ExecStart=/usr/bin/rclone mount "Google Drive:" "~/Google Drive"

[Install]
WantedBy=default.target

Seems to work ok. *shrug*

Edit - this does _not_ work upon initial login. I have to manually --user start the service (even though it's enabled) for it to mount the drive.

Last edited by cloverskull (2021-11-07 23:50:50)

Offline

Board footer

Powered by FluxBB