X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=blobdiff_plain;f=pull-mail;h=96532507a75b20abd32b04e482bee520131fc7f3;hb=44ec56c4e985839702b5fdb27c4dc99178d191f7;hp=828ec374f8e5a14e529ab9946c5cee090473f9e1;hpb=8c8342151d388db43efcaeec44d82c2d1c835f1e;p=bin.git diff --git a/pull-mail b/pull-mail index 828ec37..9653250 100755 --- a/pull-mail +++ b/pull-mail @@ -1,7 +1,24 @@ #! /bin/sh -date >> ~/.fetchmail/log -fetchmail >> ~/.fetchmail/log +if [ -f ~/.nomail ] && [ "$1" != --force ]; then + exit 0 +fi + +loadavg="$(cut -d. -f1 /proc/loadavg)" +if [ "$loadavg" -ge 5 ]; then + # System load is too high. Don't contribute to it. + exit 0 +fi + bsmtp-pull gluck +hour="$(date +%H)" +case $hour in + 0[0-289]|[12]*) + date >> ~/.fetchmail/log + fetchmail >> ~/.fetchmail/log + logrotate -s ~/.fetchmail/logrotate.status ~/.fetchmail/logrotate.conf + ;; +esac + exit 0