Allow overriding close timeout via environment

This commit is contained in:
Peter Cai 2022-12-29 16:14:22 -05:00
parent 771957d2d2
commit 193960db99
1 changed files with 8 additions and 2 deletions

View File

@ -54,12 +54,18 @@ gocrypt_spawn_close_task() {
# Cancel any previous task that might be present
systemctl --user stop "$task_name.timer" > /dev/null 2>&1
# Allow overriding close timeout from env variable
local timeout=$gocrypt_close_timeout
if [ ! -z "$PASS_GOCRYPT_CLOSE_TIMEOUT" ]; then
timeout="$PASS_GOCRYPT_CLOSE_TIMEOUT"
fi
# Create a new task
systemd-run --user --on-active=$gocrypt_close_timeout --unit="$task_name" \
systemd-run --user --on-active=$timeout --unit="$task_name" \
/usr/bin/env flock -x "$(gocrypt_lock_file_path)" /usr/bin/env bash -c \
"fusermount -u '$PREFIX'/'$gocrypt_dec_dir' || fusermount -u -z '$PREFIX'/'$gocrypt_dec_dir'"
echo "Will close the gocryptfs mount after $gocrypt_close_timeout seconds"
echo "Will close the gocryptfs mount after $timeout seconds"
}
_cmd_git() {