chiark / gitweb /
support .nomail/--force; don't run fetchmail on hours 3-7
authorColin Watson <cjwatson@chiark.greenend.org.uk>
Sat, 9 May 2009 07:23:39 +0000 (07:23 +0000)
committerColin Watson <cjwatson@chiark.greenend.org.uk>
Sat, 9 May 2009 07:23:39 +0000 (07:23 +0000)
pull-mail

index 13f4804..9653250 100755 (executable)
--- a/pull-mail
+++ b/pull-mail
@@ -1,13 +1,24 @@
 #! /bin/sh
 
+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
 
-date >> ~/.fetchmail/log
-fetchmail >> ~/.fetchmail/log
 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