From 0b9843893fac3520a12abc5c498e23406bd84a7e Mon Sep 17 00:00:00 2001 From: Kr1ss Date: Thu, 18 Mar 2021 19:03:08 +0100 Subject: [PATCH] setup some environment vars for the cron job Some tickets suggest that the mailsync process doesn't have all environ- ment variables set which are needed. For example: https://github.com/LukeSmithxyz/mutt-wizard/issues/678 The error messages indicate that for mailsync, `XDG_DATA_HOME` is empty/ unset and hence it cannot resolve the user's gnupg folder. This commit defines those variables via the crontab, which I think are the relevant ones. Not sure though if these are all we need or if I for- got some. --- bin/mw | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/mw b/bin/mw index 43bb4d6..95c04b7 100755 --- a/bin/mw +++ b/bin/mw @@ -271,10 +271,16 @@ togglecron() { cron="$(mktemp)" crontab -l > "$cron" if grep -q mailsync "$cron"; then echo "Removing automatic mailsync..." - sed -ibu /mailsync/d "$cron"; rm -f "$cron"bu + sed -ibu '/^# mailsync/,/^.*mailsync$/d' "$cron"; rm -f "$cron"bu else echo "Adding automatic mailsync every ${cronmin:-10} minutes..." - echo "*/${cronmin-10} * * * * $prefix/bin/mailsync" >> "$cron" + cat <>"$cron" +MBSYNCRC=${MBSYNCRC:-$HOME/.mbsynrc} +NOTMUCH_CONFIG=${NOTMUCH_CONFIG:-$HOME/.notmuch-config} +GNUPGHOME=${GNUPGHOME:-$HOME/.gnupg} +PASSWORD_STORE_DIR=${PASSWORD_STORE_DIR:-$HOME/.password-store} +*/${cronmin-10} * * * * $prefix/bin/mailsync +EOF fi && crontab "$cron"; rm -f "$cron" ;}