Skip to content

Instantly share code, notes, and snippets.

@nosmall
Last active January 20, 2026 20:22
Show Gist options
  • Select an option

  • Save nosmall/1c1fb7c47f156c337e6fe6341e7b6f70 to your computer and use it in GitHub Desktop.

Select an option

Save nosmall/1c1fb7c47f156c337e6fe6341e7b6f70 to your computer and use it in GitHub Desktop.
rclone-gdplex.service - Mounted Rclone as service (auto start) - Ubuntu 24.04

Mounted Rclone as service (auto start) - Ubuntu 24.04

First

apt install rclone -y
apt install fuse -y
mkdir -p /mnt/hdd/gdplex_cache
mkdir -p /mnt/gdplex
touch /etc/systemd/system/rclone-gdplex.service
vim /etc/systemd/system/rclone-gdplex.service

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

[Unit]
Description=rclone-gdplex.service - Rclone Service
Documentation=http://rclone.org/docs/
Requires=network-online.target
# Přidáno docker.service, aby restart Plexu neproběhl dříve, než Docker vůbec běží
After=network-online.target docker.service

[Service]
Type=notify
Environment=RCLONE_CONFIG=/root/.config/rclone/rclone.conf
KillMode=process
RestartSec=5
Restart=on-failure
User=root
Group=root

# Vytvoření složky, pokud neexistuje
ExecStartPre=/usr/bin/mkdir -p /mnt/gdplex
# Rotace klíčů
ExecStartPre=/bin/bash -c 'ln -sf $(find /root/.config/rclone/sa -name "*.json" | shuf -n 1) /root/.config/rclone/current_sa.json'

ExecStart=/usr/bin/rclone mount gdplexcrypt: /mnt/gdplex \
--drive-service-account-file /root/.config/rclone/current_sa.json \
--allow-other \
--dir-cache-time 9999h \
--poll-interval 1m \
--log-file /var/log/rclone-gdplex.service.log \
--log-level INFO \
--umask 000 \
--cache-dir=/mnt/hdd/gdplex_cache \
--vfs-cache-mode full \
--vfs-cache-max-size 1600G \
--vfs-cache-max-age 7200h \
--vfs-write-back 900s \
--buffer-size 64M \
--vfs-read-ahead 5G \
--vfs-read-chunk-size 128M \
--vfs-read-chunk-size-limit off \
--drive-pacer-min-sleep 10ms \
--drive-pacer-burst 200 \
--drive-chunk-size 256M

# --- PŘÍKAZY PO NABĚHNUTÍ ---
ExecStartPost=/usr/bin/ls /mnt/gdplex/Filmy /mnt/gdplex/Pohadky
ExecStartPost=/usr/bin/sleep 3
ExecStartPost=/usr/bin/bash -c 'cd /root/Docker/plex && /usr/bin/docker compose restart'

ExecStop=/bin/fusermount -uz /mnt/gdplex

[Install]
WantedBy=multi-user.target

ENABLE & START SERVICE

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

DISABLE & REMOVE SERVICE

SRVCNAME=rclone-gdplex.service && \
MNTPOINT=/mnt/gdplex && \
\
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