X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=gma.sh;h=6b0c51816ee16c090b9577e90693c7667e9a6c43;hb=1e890fe2d9174c9885320fc48228a43b8154f87d;hp=1e79c72c96bbf3ba7d183730e433bdd3127aa3fe;hpb=20794e99b3635c6b364f536631d779f8f3d78b28;p=scripts.git diff --git a/gma.sh b/gma.sh index 1e79c72..6b0c518 100755 --- a/gma.sh +++ b/gma.sh @@ -20,7 +20,7 @@ set -e function usage () { - echo "gma.sh [--body] [--keepspam] [--subject|--from|--to|--fromto] []" + echo "gma.sh [--body] [--keepspam] [--subject|--from|--to|--fromto|--sender] []" } RESULT_MBOX="/tmp/gma" @@ -30,6 +30,12 @@ if [[ -z "${MAIL_ARCHIVE_DIR}" ]]; then exit 1 fi +if [[ $(which ionice) ]]; then + IONICE="ionice -c3" +else + IONICE="" +fi + HEADER_ONLY="-H" while [[ $1 ]]; do @@ -45,6 +51,10 @@ while [[ $1 ]]; do HEADER_ONLY="" ;; + "--intense") + IONICE="" + ;; + "--keepspam") KEEP_SPAM=1 ;; @@ -61,6 +71,10 @@ while [[ $1 ]]; do RE_PREFIX="^(From|To):.*" ;; + "--sender") + RE_PREFIX="^Sender:.*" + ;; + "--subject") RE_PREFIX="^Subject:.*" ;; @@ -101,13 +115,13 @@ echo " writing result in ${RESULT_MBOX}" 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}