PortValhalla/scripts/Common/Software/rclone/rclone@.service

36 lines
1 KiB
SYSTEMD
Raw Normal View History

2022-11-10 17:24:02 +00:00
[Unit]
Description=rclone: Remote FUSE filesystem for cloud storage config %i
Documentation=man:rclone(1)
[Service]
Type=notify
Environment="EXPRESSION=%i"
ExecStart= \
bash -c ' \
args=; \
target="$(echo "$EXPRESSION" | cut -d":" -f1)"; \
dirname="$(echo "$EXPRESSION" | cut -d":" -f2)"; \
cacheDuration="$(echo "$EXPRESSION" | cut -d":" -f3)"; \
\
if [ ! -z "$cacheDuration" ]; \
then \
args="--vfs-cache-max-age=$cacheDuration"; \
fi; \
\
2024-01-17 13:55:07 +00:00
destination="`cd "%h/.mnt"; realpath -m "$dirname"`"; \
2023-05-03 16:31:38 +00:00
mkdir -p "$destination"; \
2022-11-10 17:24:02 +00:00
mkdir -p /tmp/rclone; \
/usr/bin/rclone mount \
2024-01-16 20:39:25 +00:00
--config="%h/.config/rclone/rclone.conf" \
2022-11-10 17:24:02 +00:00
--vfs-cache-mode full \
--log-file /tmp/rclone/$target.log \
$args \
2023-05-03 16:31:38 +00:00
$target: "$destination";'
ExecStop=bash -c '/bin/fusermount -zu "`cd "%h/.mnt"; realpath "$(echo "$EXPRESSION" | cut -d":" -f2)"`"'
2022-11-10 17:24:02 +00:00
2023-04-07 12:49:41 +00:00
Restart=always
RestartSec=10
2023-04-07 14:26:32 +00:00
[Install]
WantedBy=rclone.target