Zionetrix::Git
Repositories
Help
Report an Issue
postfix_scripts
Code
Commits
Branches
Tags
Search
Tree:
774e0ce
Branches
Tags
master
postfix_scripts
scripts
username_to_original_mailid
Initial commit
Benjamin Renard
commited
774e0ce
at 2016-01-19 19:51:30
username_to_original_mailid
Blame
History
Raw
#!/bin/bash USERNAME="$1" [ -z "$USERNAME" ] && echo "Usage : $0 [username] [-d]" && exit 1 DEBUG=0 [ "$2" == "-d" ] && DEBUG=1 MAX_LOG=9 function search_user () { USER="$1" MAILLOG="$2" [ ! -f "$MAILLOG" ] && MAILLOG="$MAILLOG.gz" [ -f "$MAILLOG" ] && zgrep "sasl_username=$1" $MAILLOG|sed 's/.*: \([A-Z0-9]*\): client=.*$/\1/' } search_user $USERNAME /var/log/mail.log for i in $( seq 1 $MAX_LOG ) do search_user $USERNAME /var/log/mail.log.$i done