set -e
function usage () {
- echo "gma.sh [--body] [--subject|--from|--to|--fromto|--subject] <pattern> [<year>]"
+ echo "gma.sh [--body] [--keepspam] [--subject|--from|--to|--fromto] <pattern> [<year>]"
}
RESULT_MBOX="/tmp/gma"
exit 1
fi
+if [[ $(which ionice) ]]; then
+ IONICE="ionice -c3"
+else
+ IONICE=""
+fi
+
HEADER_ONLY="-H"
while [[ $1 ]]; do
HEADER_ONLY=""
;;
+ "--intense")
+ IONICE=""
+ ;;
+
"--keepspam")
KEEP_SPAM=1
;;
*)
if [[ ${PATTERN} ]]; then
+ # If we already have the pattern to match in the
+ # message, get the new argument as a pattern for the
+ # filename
if [[ ${FILE_PATTERN} ]]; then
usage
exit 1
fi
[[ ${FILE_PATTERN} ]] || FILE_PATTERN="${MAIL_ARCHIVE_DIR}/*/*/*"
-[[ ${SIZE_FILE_PATTERN} ]] || SIZE_FILE_PATTERN="${MAIL_ARCHIVE_DIR}/"
+[[ ${SIZE_FILE_PATTERN} ]] || SIZE_FILE_PATTERN="${MAIL_ARCHIVE_DIR}"
SIZE=$(\dus ${SIZE_FILE_PATTERN} | cut -f 1 -d" ")
if [[ ${KEEP_SPAM} ]]; then
- cat ${FILE_PATTERN} \
+ ${IONICE} cat ${FILE_PATTERN} \
| pv -s ${SIZE} -p -t -e - \
| mboxgrep ${HEADER_ONLY} -i "${RE_PREFIX}${PATTERN}" > ${RESULT_MBOX}
else
- cat ${FILE_PATTERN} \
+ ${IONICE} cat ${FILE_PATTERN} \
| pv -s ${SIZE} -p -t -e - \
| mboxgrep ${HEADER_ONLY} -i "${RE_PREFIX}${PATTERN}" \
| mboxgrep ${HEADER_ONLY} -v '^Subject:.*SPAM' > ${RESULT_MBOX}