X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=getmail;h=1f66e073d1f166253a042a32e07812cf546d802c;hb=08297393bd605ed9104b3f9f1d6e35eb26bb7f4e;hp=77900af9dcec53629ea10dc6fcef5692c65fcb72;hpb=7be10d24b200a2b83669c132f25badf75e2fd8fb;p=bin.git diff --git a/getmail b/getmail index 77900af..1f66e07 100755 --- a/getmail +++ b/getmail @@ -14,9 +14,20 @@ fi; # See if the server exists if [ -z "$CRON" ] || kill -0 `pgrep -U $(id -u) -x $MUA` 2>/dev/null; then - if ping -q -c 3 $IMAPHOST >/dev/null; then - nice -n 19 offlineimap -o -u Noninteractive.Basic 2>/dev/null |grep validity| \ + if ping -q -c 3 $IMAPHOST >/dev/null 2>&1; then + if nice -n 19 offlineimap -o -u Noninteractive.Basic 2>&1 |grep validity| \ perl -ne 'my ($account,$list) = /UID validity problem for folder ([\w-]+)\.([\w-]+)/; - qx(/home/don/bin/deletemailbox -a $account $list > /dev/null);'; + next unless defined $account and length $account; + qx(/home/don/bin/deletemailbox -a $account $list > /dev/null);'; then + # Clean the lists up too + for account in bugs lists; do + find /home/don/Mail/$account -maxdepth 1 -mindepth 1 -type d \ + -exec sh -c 'test $(find {} -type f |wc -l) -eq 0' ';' \ + -printf '%f\000'|xargs -0 -rn 1 ~/bin/deletemailbox -a $account >/dev/null 2>&1; + find /home/don/Mail/$account -maxdepth 2 -mindepth 2 -iname 'new' \ + -type d -ctime +60 -printf '%h\n'|xargs -rn 1 basename|xargs \ + -rn 1 /home/don/bin/deletemailbox -a $account >/dev/null 2>&1; + done; + fi; fi; fi;