diff options
author | Luke Smith <luke@lukesmith.xyz> | 2025-02-28 09:49:22 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-28 09:49:22 +0000 |
commit | 213afe1e8f84c0753d6d492c7997dce3dd87645b (patch) | |
tree | bbd9197eb4dc8538e35366c7e7d2416a0d13bc9b | |
parent | 5300aa7f723941b444f6fe13d9190582b80c071a (diff) | |
parent | f8ffab3a115febe838cd1eda640abe959e51d792 (diff) |
Merge pull request #976 from ivan-boikov/master
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 1407e7c..3a681f0 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" |