X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=gma.sh;h=6d25f0f19a900eadb943f22afe2fcb8771698314;hb=069e747edd8ffb87b66c839e08812d30c4675b8a;hp=56250254b42d995285330b7930e88c56a10c0e21;hpb=3bf7eb477418b4f21788204c083fdcb6927ce3d4;p=scripts.git diff --git a/gma.sh b/gma.sh index 5625025..6d25f0f 100755 --- a/gma.sh +++ b/gma.sh @@ -1,13 +1,21 @@ #!/bin/bash -################################################################## -# START_IP_HEADER # -# # -# Written by Francois Fleuret # -# Contact for comments & bug reports # -# # -# END_IP_HEADER # -################################################################## +######################################################################### +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the version 3 of the GNU General Public License # +# as published by the Free Software Foundation. # +# # +# This program is distributed in the hope that it will be useful, but # +# WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # +# General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +# Written by and Copyright (C) Francois Fleuret # +# Contact for comments & bug reports # +######################################################################### set -e @@ -27,11 +35,20 @@ if [[ $1 ]]; then exit 1 fi - if [[ $2 ]]; then - FILE_PATTERN="${MAIL_ARCHIVE_DIR}/${2}/*/*gz" - SIZE=$(\dus ${MAIL_ARCHIVE_DIR}/${2} | cut -f 1 -d" ") + shift + + HEADER_ONLY="-H" + + if [[ $1 == "--body" ]]; then + HEADER_ONLY="" + shift + fi + + if [[ $1 ]]; then + FILE_PATTERN="${MAIL_ARCHIVE_DIR}/${1}/*/*" + SIZE=$(\dus ${MAIL_ARCHIVE_DIR}/${1} | cut -f 1 -d" ") else - FILE_PATTERN="${MAIL_ARCHIVE_DIR}/*/*/*gz" + FILE_PATTERN="${MAIL_ARCHIVE_DIR}/*/*/*" SIZE=$(\dus ${MAIL_ARCHIVE_DIR}/ | cut -f 1 -d" ") fi @@ -41,9 +58,8 @@ if [[ $1 ]]; then cat ${FILE_PATTERN} \ | pv -s ${SIZE} -p -t -e - \ - | zcat \ - | mboxgrep -i "$1" \ - | mboxgrep -v '^Subject:.*SPAM' > ${RESULT_MBOX} + | mboxgrep ${HEADER_ONLY} -i "${PATTERN}" \ + | mboxgrep ${HEADER_ONLY} -v '^Subject:.*SPAM' > ${RESULT_MBOX} echo "Found "$(grep ^"From " ${RESULT_MBOX} | wc -l)" messages." else