Skip to content

Instantly share code, notes, and snippets.

@nosmall
Last active December 10, 2023 08:31
Show Gist options
  • Save nosmall/1c1fb7c47f156c337e6fe6341e7b6f70 to your computer and use it in GitHub Desktop.
Save nosmall/1c1fb7c47f156c337e6fe6341e7b6f70 to your computer and use it in GitHub Desktop.
rclone-srv52.service - Mounted Rclone as service (auto start) - Ubuntu 20.04

Mounted Rclone as service (auto start) - Ubuntu 20.04

Vars

SRVRNAME=srv52
SRVCNAME=rclone-srv52.service
MNTRDRIVE=srv52crypt:
MNTPOINT=/mnt/srv52
CACHEDIR=/cache

First

apt install fuse -y
mkdir -p /cache
mkdir -p /mnt/srv52
touch /etc/systemd/system/rclone-srv52.service
vim /etc/systemd/system/rclone-srv52.service

vim /etc/systemd/system/rclone-srv52.service

[Unit]
Description=rclone-srv52.service - RClone Service
Documentation=http://rclone.org/docs/
Wants=network-online.target
After=network-online.target

[Service]
Type=notify
Environment=RCLONE_CONFIG=/root/.config/rclone/rclone.conf
KillMode=none
RestartSec=5
ExecStart=/usr/bin/rclone mount srv52crypt: /mnt/srv52 \
# This is for allowing users other than the user running rclone access to the mount
--allow-other \
# Dropbox is a polling remote so this value can be set very high and any changes are detected via polling.
--dir-cache-time 9999h \
# Time to wait between polling for changes. Must be smaller than dir-cache-time. Set to 0 to disable (default 1m0s)
--poll-interval 30s \
# Log file location
--log-file /var/log/rclone-srv52.service.log \
# Set the log level
--log-level INFO \
# This is setting the file permission on the mount to user and group have the same access and other can read
--umask 000 \
# The local disk used for caching
--cache-dir=/data/vfsCache \
# This is used for caching files to local disk for streaming
--vfs-cache-mode full \
# This limits the cache size to the value below
--vfs-cache-max-size 600G \
# Wait before uploading
--vfs-write-back 900s \
# This limits the age in the cache if the size is reached and it removes the oldest files first
--vfs-cache-max-age 720h \
# Set the tpslimit
--tpslimit 12 \
# Set the tpslimit-burst
--tpslimit-burst 12 \
# Fix IPV6 Errors if you are not running IPV6
#--bind 192.168.1.30 \
# Disable HTTP2
--disable-http2
ExecStop=pkill -f "rclone mount srv52crypt:"
ExecStopPost=fusermount -uz /mnt/srv52
Restart=on-failure
User=root
Group=root

[Install]
WantedBy=multi-user.target

ENABLE & START SERVICE

systemctl daemon-reload && \
systemctl enable rclone-srv52.service && \
systemctl start rclone-srv52.service

DISABLE & REMOVE SERVICE

SRVCNAME=rclone-srv52.service && \
MNTPOINT=/mnt/srv52 && \
\
systemctl stop $SRVCNAME && \
systemctl disable $SRVCNAME && \
rm -f /etc/systemd/system/$SRVCNAME && \
rm -f /usr/lib/systemd/system/$SRVCNAME && \
systemctl daemon-reload && \
rmdir $MNTPOINT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment