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