From 771957d2d20a5c5fe83881ef173859d4bb8bab65 Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Thu, 29 Dec 2022 16:09:50 -0500 Subject: [PATCH 1/2] Fix redirection again --- gocrypt.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gocrypt.bash b/gocrypt.bash index c6f8608..aac89b0 100755 --- a/gocrypt.bash +++ b/gocrypt.bash @@ -156,7 +156,7 @@ gocrypt_close() { [ $# -eq 0 ] || gocrypt_die "Unexpected argument" gocrypt_open_check # Remove the systemd task for closing if present - which systemctl > /dev/null && systemctl --user stop "$(gocrypt_unique_task_identifier).timer" > /dev/null 2>1 + which systemctl > /dev/null && systemctl --user stop "$(gocrypt_unique_task_identifier).timer" > /dev/null 2>&1 fusermount -u "$gocrypt_dec_dir" || fusermount -u -z "$gocrypt_dec_dir" } From 193960db99ed060503784e37e1002ad6536b2583 Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Thu, 29 Dec 2022 16:14:22 -0500 Subject: [PATCH 2/2] Allow overriding close timeout via environment --- gocrypt.bash | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gocrypt.bash b/gocrypt.bash index aac89b0..2d70939 100755 --- a/gocrypt.bash +++ b/gocrypt.bash @@ -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() {