2 # I, Ian Kelling, follow the GNU license recommendations at
3 # https://www.gnu.org/licenses/license-recommendations.en.html. They
4 # recommend that small programs, < 300 lines, be licensed under the
5 # Apache License 2.0. This file contains or is part of one or more small
6 # programs. If a small program grows beyond 300 lines, I plan to switch
9 # Copyright 2024 Ian Kelling
11 # Licensed under the Apache License, Version 2.0 (the "License");
12 # you may not use this file except in compliance with the License.
13 # You may obtain a copy of the License at
15 # http://www.apache.org/licenses/LICENSE-2.0
17 # Unless required by applicable law or agreed to in writing, software
18 # distributed under the License is distributed on an "AS IS" BASIS,
19 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 # See the License for the specific language governing permissions and
21 # limitations under the License.
25 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
26 # mail-route can get messed up a bit randomly, I don't know why.
27 #/b/ds/mail-route up |& /b/log-quiet/log-once -1 mail-route
29 for f
in $
(awk '$1 == "localfolders" {print $NF}' ~
/.offlineimaprc
); do
37 if grep -qP '^ *accounts.*fsf' ~
/.offlineimaprc
; then
38 if [[ ! -e /nocow
/user
/.mufsf
]]; then
39 mkdir
-p /nocow
/user
/.mufsf
40 chmod 700 /nocow
/user
/.mufsf
41 mu index
--maildir=/nocow
/user
/fsfmd
45 omv
() { # offlineimap mv. move mail files within $src_base/$1 to /m/md/$2
50 files
=($src_base/"$src"/$x/*)
53 mv "${files[@]}" /m
/md
/"$dst"/$x
58 src_base
=/m
/offlineimap
59 omv
"Sent Items" "Sent"
60 omv INBOX offlineimaptmp
63 sieve-filter
-eW ~
/sieve
/main.sieve offlineimaptmp
&>/dev
/null
64 # the default folder is INBOX for anything leftover
65 omv offlineimaptmp INBOX
66 # remove messages from remote host
68 # this makes us sit and wait when we want to use mu and this is running in a cronjob.
69 # todo: emacs updates the index much faster. what command is it running? I'd like
71 # looks like it might be mu index --lazy-check, but that still takes like 10 seconds,
72 # figure out if that is the same speed, or if we can make it faster.
73 #mu index &>/dev/null ||:
77 # delete based on http://deflexion.com/2006/05/imap-way-of-deleting-message
78 sieve-filter
-eW -o mail_location
=maildir
:/nocow
/user
/fsfmd
:LAYOUT
=fs
:INBOX
=/nocow
/user
/fsfmd
/INBOX ~
/sieve
/fsf.sieve INBOX delete
&>>/tmp
/fsfsieve.log
80 # to test new rules, update fsf-test.sieve, run these commands, then copy new fsf-test.sieve to fsf.sieve
81 # sieve-filter -o mail_location=maildir:/nocow/user/fsfmd:LAYOUT=fs:INBOX=/nocow/user/fsfmd/INBOX ~/sieve/fsf-test.sieve INBOX &>/tmp/testfsfsieve.log
82 # sed -rn '/^Performed actions:/{n;n;p}' /tmp/testfsfsieve.log | sort -u