X-Git-Url: https://iankelling.org/git/?p=distro-setup;a=blobdiff_plain;f=offlineimap-sync;h=4fac2474686ff9d11d139fe7d7ffb373ef7c6580;hp=2b71a6969b0f970df0012e148241b7b140227a54;hb=0cc08a73110c15c4e7bbb8c8233a6c122c27490e;hpb=917ca4a71b5c456b741456dc173c144ee7042d89 diff --git a/offlineimap-sync b/offlineimap-sync index 2b71a69..4fac247 100755 --- a/offlineimap-sync +++ b/offlineimap-sync @@ -2,7 +2,6 @@ set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR - # mail-route can get messed up a bit randomly, I don't know why. #/b/ds/mail-route up | /b/log-quiet/log-once -1 mail-route @@ -10,16 +9,16 @@ offlineimap -u quiet shopt -s nullglob omv() { # offlineimap mv. move mail files within $src_base/$1 to /m/md/$2 - src="$1" - dst="$2" - found_files=false - for x in new cur; do - files=($src_base/"$src"/$x/*) - if [[ $files ]]; then - found_files=true - mv "${files[@]}" /m/md/"$dst"/$x - fi - done + src="$1" + dst="$2" + found_files=false + for x in new cur; do + files=($src_base/"$src"/$x/*) + if [[ $files ]]; then + found_files=true + mv "${files[@]}" /m/md/"$dst"/$x + fi + done } src_base=/m/offlineimap @@ -27,28 +26,47 @@ omv "Sent Items" "Sent" omv INBOX offlineimaptmp src_base=/m/md if $found_files; then - sieve-filter -eW ~/sieve/main.sieve offlineimaptmp &>/dev/null - # the default folder is INBOX for anything leftover - omv offlineimaptmp INBOX - # remove messages from remote host - offlineimap -u quiet - # this makes us sit and wait when we want to use mu and this is running in a cronjob. - # todo: emacs updates the index much faster. what command is it running? I'd like - # to just run that - # looks like it might be mu index --lazy-check, but that still takes like 10 seconds, - # figure out if that is the same speed, or if we can make it faster. - #mu index &>/dev/null ||: + sieve-filter -eW ~/sieve/main.sieve offlineimaptmp &>/dev/null + # the default folder is INBOX for anything leftover + omv offlineimaptmp INBOX + # remove messages from remote host + offlineimap -u quiet + # this makes us sit and wait when we want to use mu and this is running in a cronjob. + # todo: emacs updates the index much faster. what command is it running? I'd like + # to just run that + # looks like it might be mu index --lazy-check, but that still takes like 10 seconds, + # figure out if that is the same speed, or if we can make it faster. + #mu index &>/dev/null ||: fi +# find but ignore directories which dont exist, assuming first args are directories +# and a following arg starts with - +myfind() { + dirs=() + for d; do + if [[ $d == -* ]]; then + # past dirs, onto options + break + fi + shift + if [[ -e $d ]]; then + dirs+=($d) + fi + done + if [[ $dirs ]]; then + find ${dirs[@]} $@ + fi +} # qemu-devel is our biggest list by far, so occasionally # I want to hop into conversations about our mailing # systems there, but I don't need many old messages. -find /nocow/user/fsfmd/l/qemu-devel/new -type f -mtime +14 -execdir rm -- '{}' + +myfind /nocow/user/fsfmd/l/qemu-devel/new -type f -mtime +14 -execdir rm -- '{}' + + -find /nocow/user/fsfmd/{sec,Spam,Drafts,{rtcc,sysadmin,l/outreachy-mentors}/new} -type f -mtime +100 -execdir rm -- '{}' + +myfind /nocow/user/fsfmd/{sec,Spam,Drafts,{rtcc,sysadmin,l/outreachy-mentors}/new} -type f -mtime +100 -execdir rm -- '{}' + -find /nocow/user/fsfmd/log -type f -mtime +300 -execdir rm -- '{}' + +myfind /nocow/user/fsfmd/log -type f -mtime +300 -execdir rm -- '{}' + # delete based on http://deflexion.com/2006/05/imap-way-of-deleting-message