remove kinsis / unused input settings
[distro-setup] / offlineimap-sync
1 #!/bin/bash
2
3 set -eE -o pipefail
4 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
5
6 offlineimap -u quiet
7 shopt -s nullglob
8
9 omv() { # offlineimap mv. move mail files within $src_base/$1 to /m/md/$2
10 src="$1"
11 dst="$2"
12 found_files=false
13 for x in new cur; do
14 files=("$src_base"/"$src"/$x/*)
15 if [[ $files ]]; then
16 found_files=true
17 mv "${files[@]}" /m/md/"$dst"/$x
18 fi
19 done
20 }
21
22 src_base=/m/offlineimap
23 omv "Sent Items" "Sent"
24 omv INBOX offlineimaptmp
25 src_base=/m/md
26 if $found_files; then
27 sieve-filter -eW ~/sieve/main.sieve offlineimaptmp &>/dev/null
28 # the default folder is INBOX for anything leftover
29 omv offlineimaptmp INBOX
30 # remove messages from remote host
31 offlineimap -u quiet
32 # this makes us sit and wait when we want to use mu and this is running in a cronjob.
33 # todo: emacs updates the index much faster. what command is it running? I'd like
34 # to just run that
35 # looks like it might be mu index --lazy-check, but that still takes like 10 seconds,
36 # figure out if that is the same speed, or if we can make it faster.
37 #mu index &>/dev/null ||:
38 fi