diff options
author | ivan-boikov <ik.boikov.public@protonmail.com> | 2024-01-13 13:50:41 +0100 |
---|---|---|
committer | ivan-boikov <ik.boikov.public@protonmail.com> | 2024-01-13 13:50:41 +0100 |
commit | f8ffab3a115febe838cd1eda640abe959e51d792 (patch) | |
tree | e5f926f7d747b8b9cc91320fde5c3453aac074e5 | |
parent | a8863a750a360bad6759f5f2c4df5d2001b31e18 (diff) |
No mailsync with locked GPG key in non-interactive shells
-rwxr-xr-x | bin/mailsync | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/bin/mailsync b/bin/mailsync index cbd36ff..9c7f457 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -24,6 +24,9 @@ eval "$(grep -h -- \ "$HOME/.config/zsh/.zshenv" "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.config/zsh/.zshrc" \ "$HOME/.pam_environment" 2>/dev/null)" +# For non-interactive shell (e.g. cron job) run only when the GPG key (in $GNUPGHOME or pass --homedir) is unlocked +tty -s || (echo "dummy" | gpg --sign --batch --pinentry-mode error -o /dev/null > /dev/null 2>&1) || exit + export GPG_TTY="$(tty)" [ -n "$MBSYNCRC" ] && alias mbsync="mbsync -c $MBSYNCRC" || MBSYNCRC="$HOME/.mbsyncrc" |