]> git.donarmstrong.com Git - bin.git/blob - getmail
ignore errors from find in getmail
[bin.git] / getmail
1 #!/bin/sh
2
3 # Configure the two things below for your MUA and the host being run.
4 IMAPHOST=rzlab.ucr.edu
5 MUA=mutt
6
7 #set -x
8
9 # Don't check mail if ~/.nocheck exists and we're not running
10 # interactively.
11 if [[ -z "$CRON" && -e ~/.nocheck ]]; then
12     exit 0;
13 fi;
14
15 # See if the server exists
16 if [ -z "$CRON" ] || kill -0 `pgrep -U $(id -u) -x $MUA` 2>/dev/null; then
17     if ping -q -c 3 $IMAPHOST >/dev/null 2>&1; then
18         if nice -n 19 offlineimap -o -u Noninteractive.Basic 2>&1 |grep validity| \
19             perl -ne 'my ($account,$list) = /UID validity problem for folder ([\w-]+)\.([\w-]+)/;
20                       next unless defined $account and length $account;
21                       qx(/home/don/bin/deletemailbox -a $account $list > /dev/null);'; then
22             # Clean the lists up too
23             for account in bugs lists; do
24                 find /home/don/Mail/$account -maxdepth 1 -mindepth 1 -type d \
25                     -exec sh -c 'test $(find {} -type f |wc -l) -eq 0' ';' \
26                     -printf '%f\000'|xargs -0 -rn 1 ~/bin/deletemailbox -a $account >/dev/null 2>&1;
27                 find /home/don/Mail/$account -maxdepth 2 -mindepth 2 -iname 'new' \
28                     -type d -ctime +60 -printf '%h\n'|xargs -rn 1 basename|xargs \
29                     -rn 1 /home/don/bin/deletemailbox -a $account >/dev/null 2>&1;
30             done;
31         fi;
32     fi;
33 fi;