X-Git-Url: https://git.madduck.net/etc/offlineimap.git/blobdiff_plain/84ad23ae0edb52bd785a38ef87398133e73c41e2..d6533cdd1e4f42895b2569e979ad9987ba8d7454:/.bin/offlineimap diff --git a/.bin/offlineimap b/.bin/offlineimap index f55fee5..d1f81c0 100755 --- a/.bin/offlineimap +++ b/.bin/offlineimap @@ -5,21 +5,23 @@ set -eu VAR=$HOME/.var/offlineimap LOCKFILE="$VAR/.cron.lock" -trap "rm -f $LOCKFILE" 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15 -if ! lockfile -0 -r0 -l 3600 "$LOCKFILE" 2>/dev/null; then +trapfn() { rm -f "$LOCKFILE"; trap - 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15; } +trap trapfn 1 2 3 4 5 6 7 8 10 11 12 13 14 15 +if [ -d "$VAR" ] && ! lockfile -0 -r0 -l 3600 "$LOCKFILE" 2>/dev/null; then echo "E: offlineimap is already running." >&2 exit 1 fi +trap trapfn 0 + if ! test -t 0; then - echo Renicing because we are not run interactively… >&2 + echo Renicing because we are not run interactively… renice 20 -p $$ >/dev/null ionice -c3 -p $$ fi ret=0 -/usr/bin/offlineimap -o "$@" || exit $? +strace -tfo /tmp/offlineimap.strace /usr/bin/offlineimap "$@" || ret=$? -if [ -x "$(command -v notmuch)" ]; then - notmuch new || exit $? -fi +trapfn +exit $ret