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 # Sync clouds
echo "Please complete the setup of your profile!"; echo "Please complete the setup of your profile!";
NEXTCLOUD_DIR="${NEXTCLOUD_DIR}" . "../rclone/InstallSync.sh" nextcloud "$NEXTCLOUD_DIR"; 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" if isTruthy "$INSTALL_FONTS"
then then

View file

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

View file

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