Allow setting cache duration for individual syncs

This commit is contained in:
Manuel Thalmann 2024-04-20 12:55:58 +02:00
parent de061a8f2a
commit e38d2e66ee
3 changed files with 19 additions and 4 deletions

View file

@ -33,7 +33,7 @@ else
# Sync clouds
echo "Please complete the setup of your profile!";
NEXTCLOUD_DIR="${NEXTCLOUD_DIR}" . "../rclone/InstallSync.sh" nextcloud "$NEXTCLOUD_DIR";
PROTON_DIR="${PROTON_DIR}" . "../rclone/InstallSync.sh" proton "$PROTON_DIR";
PROTON_DIR="${PROTON_DIR}" . "../rclone/InstallSync.sh" proton "$PROTON_DIR" "2w";
if isTruthy "$INSTALL_FONTS"
then

View file

@ -1,8 +1,14 @@
#!/bin/bash
provider="$1";
dirname="$2";
cacheDuration="$3";
serviceName="rclone@$provider:$dirname";
if [ ! -z "${cacheDuration}" ]
then
serviceName="${serviceName}:$cacheDuration";
fi;
echo "Please create a remote called \`$1\`";
rclone config || true;
systemctl --user enable "$serviceName" --now || true;

View file

@ -7,8 +7,16 @@ Type=notify
Environment="EXPRESSION=%i"
ExecStart= \
bash -c ' \
target="${EXPRESSION%%":"*}"; \
dirname="${EXPRESSION#*":"}"; \
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; \
\
destination="`cd "%h/.mnt"; realpath -m "$dirname"`"; \
mkdir -p "$destination"; \
mkdir -p /tmp/rclone; \
@ -16,8 +24,9 @@ ExecStart= \
--config="%h/.config/rclone/rclone.conf" \
--vfs-cache-mode full \
--log-file /tmp/rclone/$target.log \
$args \
$target: "$destination";'
ExecStop=bash -c '/bin/fusermount -zu "`cd "%h/.mnt"; realpath "${EXPRESSION#*":"}"`"'
ExecStop=bash -c '/bin/fusermount -zu "`cd "%h/.mnt"; realpath "$(echo "$EXPRESSION" | cut -d":" -f2)"`"'
Restart=always
RestartSec=10