Rclone at startup

Hello,

I installed rclone for mounting OneDrive account on my local drive.

I followed this guide: https://www.linuxuprising.com/2018/07/how-to-mount-onedrive-in-linux-using.html

Everything is working properly, but I cannot run rclone at startup.

I installed rclone with my user and with the command:

/usr/bin/rclone --vfs-cache-mode writes mount OneDrive: /home/dlynfox/OneDrive/

I can mount and everything is working.

Now, I want to startup the computer with this command running.
I tried from “Autostart” to add the command but is not working, even with the option “run as: [user]”.

I also tried with:

/usr/bin/runuser -l dlynfox -c “/usr/bin/rclone --vfs-cache-mode writes mount OneDrive: /home/dlynfox/OneDrive/”

what am I doing wrong?

Hi @dlynfox,

rclone is awesome. To know what’s happening, we need to see the error output.

However, I suspect the RCLONE_CONFIG_PASS variable isn’t set on startup, which would be necessary.

From the Documentation:

If it is safe in your environment, you can set the RCLONE_CONFIG_PASS environment variable to contain your password, in which case it will be used for decrypting the configuration.
You can set this for a session from a script. For unix like systems save this to a file called set-rclone-password

I put mine in a file called ~/.config/plasma-workspace/env/set_rclone_config_password.sh

It runs automatically on startup. The file is small, only 2 lines:

#!/bin/env bash
export RCLONE_CONFIG_PASS='<rclone password here>' && echo 'rClone configuration password set!' || echo 'Problem setting rClone configuration password'

I hope this helps.

Hi,
I tried to create that file.
Then I added a “startup” command with this command:

usr/bin/rclone --vfs-cache-mode writes mount OneDrive: /home/dlynfox/OneDrive/

with the option “Run as user:” and put my username “dlynfox”.

Now after the login it prompt a terminal asking me the password.

If I type my password the rclone mount OneDrive correctly.
Reading the documentation, I also tried the --password-command option, but it’s not working.

/usr/bin/rclone --password-command echo “” --vfs-cache-mode writes mount OneDrive: /home/dlynfox/OneDrive/

So, I’m by no means an expert, just keep that in mind.

Firstly, that file only runs when I login to KDE. So, it doesn’t set the variable for anything before that. I do not start my rclone with my PC, I prefer to run it manually. It might need to run before the rclone mount command, If so, try &&:

export RCLONE_CONFIG_PASS='<rclone password here>' && usr/bin/rclone --vfs-cache-mode writes mount OneDrive: /home/dlynfox/OneDrive/

The && just ensures that the command after it will run only if the first one was successful. (In this case, if the export was successful.

Secondly, that password and variable is only necessary if you encrypted the configuration file, which I’ve done, as I’m a paranoid one. It’s not really necessary if your computer is in a safe environment. (Which mine is but, like I said, I’m paranoid.)

Also, that

 usr/bin/rclone --vfs-cache-mode writes mount OneDrive: /home/dlynfox/OneDrive/

command of yours is missing a / in the beginning:

/usr/bin/rclone --vfs-cache-mode writes mount OneDrive: /home/dlynfox/OneDrive/

Hope this helps,

I decided to create a Systemd /etc/systemd/system/rclonemount.service service like this:

[Unit]
Description=rclonemount
AssertPathIsDirectory=/home/dlynfox/OneDrive/
After=network-online.target

[Service]
Type=simple
User=dlynfox
Group=dlynfox
ExecStart=/usr/bin/rclone --vfs-cache-mode writes mount OneDrive: /home/dlynfox/OneDrive/ --config /home/dlynfox/.config/rclone/rclone.conf
ExecStop=/bin/fusermount -u /home/dlynfox/OneDrive/
Restart=always
RestartSec=10

[Install]
WantedBy=default.target

and now, it works!!!

Anyway, thank you for your help.

Apologies, just read your reply again. In the above command, you should actually specify the command for the --password-command echo “” parameter. Doing this will leave it blank.

Something like:

1 Like

in the brackets I put my password.

Anyway, I decided to create the service Systemd and it works.

Thanks for your help.

Happy you’ve got it working now and glad if I could have been some kind of assistance!

1 Like

You should instead of using a system-wide service use a per-user one instead.
You can create those under ~/.config/systemd/user/ :wink:
Inside you can make use of %h as explained in systemd.unit(5) #Specifiers :wink:

PS: that way you won’t need to use User= nor Group= etc which makes it even cleaner…

For more info on user units see:
https://wiki.archlinux.org/index.php/Systemd/User

2 Likes

Thank you TriMoon. :+1:

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.