X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?p=bin.git;a=blobdiff_plain;f=pull-mail;h=a669a29508d9381b7e505908a1513e0f143e72fd;hp=2c11b992c659d00d940921a0c1610ea6fc3a4a3b;hb=b238980e7533a97a6e14c1fdbc7f4da91e924001;hpb=ae167f5853dae73ed23c077e76553bc3e933bffa diff --git a/pull-mail b/pull-mail old mode 100644 new mode 100755 index 2c11b99..a669a29 --- a/pull-mail +++ b/pull-mail @@ -1,10 +1,26 @@ #! /bin/sh -set -e -if ! [ -e ~/.nomail ]; then - date >> ~/.fetchmail/log - fetchmail >> ~/.fetchmail/log - bsmtp-pull gluck +if [ -f ~/.nomail ] && [ "$1" != --force ]; then + exit 0 fi +loadavg="$(cut -d. -f1 /proc/loadavg)" +if [ "$loadavg" -ge 5 ] && [ "$1" != --force ]; then + # System load is too high. Don't contribute to it. + exit 0 +fi + +bsmtp-pull master + +hour="$(date +%H)" +case $hour in + 0[0-4789]|[12]*) + date >> ~/.fetchmail/log + fetchmail >> ~/.fetchmail/log + logrotate -s ~/.fetchmail/logrotate.status ~/.fetchmail/logrotate.conf + ;; +esac + +notmuch new >/dev/null 2>&1 + exit 0