X-Git-Url: https://git.madduck.net/etc/offlineimap.git/blobdiff_plain/2fe7b5485cac1d59a5d0b3ab93a0d6688b4788df..032f40601e49f1ebe69671798675574101109e6b:/.bin/offlineimap?ds=sidebyside diff --git a/.bin/offlineimap b/.bin/offlineimap index c9f8b2a..7e439d4 100755 --- a/.bin/offlineimap +++ b/.bin/offlineimap @@ -1,10 +1,20 @@ #!/bin/sh set -eu +[ "${1:-}" = -q ] && exec >/dev/null + +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 + echo "E: offlineimap is already running." >&2 + exit 1 +fi + 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 -c2 -n7 -p $$ + ionice -c3 -p $$ fi ret=0