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 ' \
|
2024-04-20 10:55:58 +00:00
|
|
|
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 \
|
2024-10-22 19:18:17 +00:00
|
|
|
--log-level INFO \
|
2024-04-20 10:55:58 +00:00
|
|
|
$args \
|
2023-05-03 16:31:38 +00:00
|
|
|
$target: "$destination";'
|
2024-04-20 10:55:58 +00:00
|
|
|
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
|