X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=blobdiff_plain;f=pull-mail;h=96532507a75b20abd32b04e482bee520131fc7f3;hb=9b7b22d2e16376edc6049a81cd8ad00243f1dbd9;hp=c0104d4913bb31a13f3205be079e1f0247ae8339;hpb=11ddadb352831eed98654814b29ee1f5e3f32840;p=bin.git diff --git a/pull-mail b/pull-mail index c0104d4..9653250 100755 --- a/pull-mail +++ b/pull-mail @@ -1,8 +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 -bsmtp-pull klecker + +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