Skip to content

Instantly share code, notes, and snippets.

@sasajib
Forked from kabili207/Rclone systemd service.md
Last active January 30, 2023 10:43
Show Gist options
  • Save sasajib/90c8a77d9ef558a9e4315bb1be107fbe to your computer and use it in GitHub Desktop.
Save sasajib/90c8a77d9ef558a9e4315bb1be107fbe to your computer and use it in GitHub Desktop.
Rclone systemd user service
#Mergerfs “mount” service
[Unit]
Description=MergerFS Mount
Documentation=man:mergerfs(1)
After=network-online.target
Wants=network-online.target
[Service]
Type=notify
ExecStart=/usr/bin/mergerfs /home/ubuntu/mnt/google:/home/ubuntu/mnt/one:/home/ubuntu/mnt/local /home/ubuntu/mnt/media -o rw,use_ino,allow_other,func.getattr=newest,category.action=all,category.create=ff,cache.files=auto-full
ExecStop=/bin/fusermount -uz /home/ubuntu/mnt/media
KillMode=none
Restart=on-failure
[Install]
WantedBy=default.target
# User service for Rclone mounting
#
# Place in ~/.config/systemd/user/
# File must include the '@' (ex [email protected])
# As your normal user, run
# systemctl --user daemon-reload
# You can now start/enable each remote by using rclone@<remote>
# systemctl --user enable rclone@dropbox
# systemctl --user start rclone@dropbox
[Unit]
Description=rclone: Remote FUSE filesystem for cloud storage config %i
Documentation=man:rclone(1)
After=network-online.target
Wants=network-online.target
AssertPathIsDirectory=%h/mnt/%i
[Service]
Type=notify
ExecStart= \
/usr/bin/rclone mount \
--config=%h/.config/rclone/rclone.conf \
--vfs-cache-mode writes \
--vfs-cache-max-size 100M \
--log-level INFO \
--log-file /tmp/rclone-%i.log \
--umask 022 \
--allow-other \
%i: %h/mnt/%i
ExecStop=/bin/fusermount -u %h/mnt/%i
[Install]
WantedBy=default.target

rclone systemd service

Preparation

This service will use the same remote name you specified when using rclone config create. If you haven't done that yet, do so now.

Next, create the mountpoint for your remote. The service uses the location ~/mnt/<remote> by default.

mkdir ~/mnt/dropbox

The --allow-other option is required in order to work in many desktop environments. This flag must be enabled by adding user_allow_other to /etc/fuse.conf.

Adding the service

Save the [email protected] file in ~/.config/systemd/user/ Make sure you include the @. This is required to work.

As your normal user, run:

systemctl --user daemon-reload

Using the service

You can now start/enable each remote by using rclone@<remote>

systemctl --user enable rclone@dropbox
systemctl --user start rclone@dropbox
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment