Skip to content

Instantly share code, notes, and snippets.

@trysten
Created August 7, 2023 20:47
Show Gist options
  • Save trysten/35e1d18f3249234c711d7d1196067127 to your computer and use it in GitHub Desktop.
Save trysten/35e1d18f3249234c711d7d1196067127 to your computer and use it in GitHub Desktop.
rclone mount systemd template
[Install]
# not sure what to put here
WantedBy=default.target
[Unit]
Description=mount rclone remote %i in home/mnt
Documentation=https://rclone.org/docs/
[Service]
Type=simple
# ensure the directory exists
# TODO: ensure empty
# -p in case this is the first run, to create parent dir 'mnt'
ExecStartPre=mkdir -p %h/mnt/%i
# %h: user homedir
# %i template instance name
ExecStart=%h/.local/bin/rclone mount %i: %h/mnt/%i
# unmounting will trigger rclone to die
ExecStop=fusermount -u %h/mnt/%i ; rmdir %h/mnt/%i
[Install]
WantedBy=default.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment