X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=scripts.git;a=blobdiff_plain;f=gma.sh;h=e266737f0ea54e14e61bcf592bd057c1b912059e;hp=46992a38834d45c3d4a3196285aa4ef2a451d375;hb=0b5965cd1e6ed1758170691ac858b74be6e1ea0b;hpb=32ea9d8fc8d68b70199f8eb21a7affa82caaccf3 diff --git a/gma.sh b/gma.sh index 46992a3..e266737 100755 --- a/gma.sh +++ b/gma.sh @@ -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 ;; @@ -67,6 +77,9 @@ while [[ $1 ]]; do *) 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 @@ -88,7 +101,7 @@ if [[ -z "${PATTERN}" ]]; then 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" ") @@ -98,13 +111,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}