Ignore:
Timestamp:
Dec 20, 2014, 2:47:51 PM (8 years ago)
Author:
quentin
Message:
Add features to prune-mailq show_rand
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/fedora/config/etc/scripts/prune-mailq

    r2609 r2657  
    77    $0 list-from
    88    $0 list-to
    9     $0 show-rand
     9    $0 show-rand [from|to] [regex]
    1010    $0 email lockers...
    1111    $0 purge-from lockers...
    1212    $0 purge-to lockers..."
    1313
     14usage() {
     15    echo "$usage" >&2;
     16    exit 1
     17}
    1418clean_locker() {
    1519    echo "${1%%@scripts.mit.edu}"
     
    2731
    2832show_rand() {
    29     files=$(ls /var/spool/postfix/deferred/?/* | shuf | head -n 3)
     33    if [[ $# -eq 0 ]]; then
     34        files=$(ls /var/spool/postfix/deferred/?/* | shuf | head -n 3)
     35    else
     36        match=$2
     37        case "$1" in
     38            from) dir=7;;
     39            to) dir=8;;
     40            *) usage;;
     41        esac
     42        msgids=$(mailq | tail -n +2 | grep -v '^ *(' | awk "BEGIN { RS = \"\" } (\$$dir ~ /$match/) { print \$1 }" | shuf | head -n 3)
     43        files=$(for msgid in $msgids; do echo /var/spool/postfix/deferred/${msgid:0:1}/$msgid; done)
     44    fi
    3045    for file in $files; do
    3146        echo ">>>> $file";
     
    99114    list-from) list_from;;
    100115    list-to) list_to;;
    101     show-rand) show_rand;;
     116    show-rand) show_rand "$@";;
    102117    email) tmpl_email "$@";;
    103118    purge-from) purge_from "$@";;
    104119    purge-to) purge_to "$@";;
    105120    *)
    106         echo "$usage" >&2;
    107         exit 1
     121        usage
    108122        ;;
    109123esac
Note: See TracChangeset for help on using the changeset viewer.