Mounting onedrive on startup/login/restart/reboot

What question?
Read again and do as suggested.
Then explain what you did and the result.

For the changes on services, use systemctl, not manual file editing.
Read relevant manuals.

2 Likes

Hi! I modify the script as such:

[Unit]
Description=Mount OneDrive
Requires=network.target 
After=network.target 

[Service]
ExecStart=sh -c "sleep 5s && rclone --config=/home/andre/.config/rclone/rclone.conf --vfs-cache-mode writes moun
t onedrive: /home/andre/OneDrive"

[Install]
WantedBy=default.target

And I also tried this one:

[Unit]
Description=Mount OneDrive
Requires=network-online.target 
After=network-online.target 

[Service]
ExecStart=sh -c "sleep 5s && rclone --config=/home/andre/.config/rclone/rclone.conf --vfs-cache-mode writes moun
t onedrive: /home/andre/OneDrive"

[Install]
WantedBy=default.target

None of witch worked. The network.target and the network-online.target dose not exist in ~/.config/systemd/user/ where my script has visibility.

Is the NetworkManager-wait-online.service enabled, and is it started?

To have that target specified as “After” in the service you must make sure the NetworkManager-wait-online.service is working. Have you checked its status?

1 Like

No! I haven't. Don't know how yet, but let me search for it. Brb with my findings.

Yes, I have checked it. It is running like it sould be.

OT

Amazing.

5 Likes

Have you tried this ^^^

Add something like this before your exec line in the service:

ExecStartPre=/usr/bin/sleep 10

Rip VanWinkle. :zzz:

:rofl:

4 Likes

I read through the entire thread without looking at the start of the timeline.. this made me laugh.

1 Like

No, I haven't tried this yet.

Solution:

/usr/bin/onedrive/mount-onedrive.sh

#!/bin/bash
rclone mount --config ~/.config/rclone/rclone.conf --allow-non-empty --vfs-cache-mode writes onedrive: /home/$
{USER}/OneDrive

/etc/systemd/system/onedrive-mount.service

[Unit]
Description=Mount OneDrive with rclone
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/onedrive/mount-onedrive.sh
Restart=on-failure
RestartSec=10
User=<your-user>

[Install]
WantedBy=default.target

Note: This is important! If you have a Microsoft Notes url file, the directory you saved it in will not be loaded. rclone outputs ERROR : IO error: unknown object type <nil>.

No ideea why, I’ve just moved everything else from that dir an let the url file in it’s own dedicated dir(I don’t know why do I have these since I never use Notes, but whatever).

Yeah. This is the solution I came up with. Is a combination of the responses you guys gave and some further research about services.

2 Likes