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.
24 if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
25 source /a
/bin
/bash-bear-trap
/bash-bear
27 source /a
/bin
/bash_unpublished
/source-state
28 if [[ $HOSTNAME != "$MAIL_HOST" ]]; then
33 # find but ignore directories which dont exist, assuming first args are directories
34 # and a following arg starts with -
38 if [[ $d == -* ]]; then
39 # past dirs, onto options
47 if (( ${#dirs[*]} )); then
52 # qemu-devel is our biggest list by far, so occasionally
53 # I want to hop into conversations about our mailing
54 # systems there, but I don't need many old messages.
55 myfind
/m
/md
/l
/qemu-devel
/new
-type f
-mtime +14 -execdir rm -- '{}' +
56 myfind
/m
/md
/l
/listhelper-moderatre
/new
-type f
-mtime +14 -execdir rm -- '{}' +
57 myfind
/m
/md
/{sec
,Spam
,Drafts
,{rtcc
,sysadmin
}/new
} -type f
-mtime +100 -execdir rm -- '{}' +
58 myfind
/m
/md
/log
-type f
-mtime +300 -execdir rm -- '{}' +
59 myfind
/m
/md
/dmarc
-type f
-mtime +60 -execdir rm -- '{}' +
60 myfind
/m
/md
/fsfalerts
-type f
-mtime +10 -execdir rm -- '{}' +
62 # not strictly a mail directory, but it fits well in this script
63 myfind
/p
/c
/.editor-backups
-type f
-mtime +300 -execdir rm -- '{}' +
75 [[ -d $d ]] ||
continue
76 leafdir
=${d##*/} # cur/new
77 archivebase
=${d%/*}-myarchive
78 archive
=$archivebase/$leafdir
79 mkdir
-p ${archivebase}/{cur
,tmp
,new
}
80 find $d -type f
-mtime +$days -name '1*' -exec mv '{}' $archive \
;
81 # count=$(find $d -type f -mtime +$days -name '1*' | wc -l)
82 # if (( count )); then
89 archive
800 .
/!(*archive|board|Drafts|Sent|INBOX
)/*(cur|new
) .
/l
/!(*archive
)/*(cur|new
)
90 archive
60 .
/{sysadmin
,rtcc
,fsfcc
,fsfmembers
}/{cur
,new
}
91 archive
30 .
/Junk
/{cur
,new
}
93 # This is a generally useless file which will grow to 1gb and eat up memory.
94 # https://doc.dovecot.org/admin_manual/known_issues/large_cache/
95 # I could probably disable the cache for this folder, but that would
96 # also mean I'm testing less of the full functionality.
97 rm -f /m
/md
/l
/testignore
/dovecot.index.cache