diff options
author | Jonas Smedegaard <dr@jones.dk> | 2008-02-03 22:09:07 +0000 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2008-02-03 22:09:07 +0000 |
commit | 31a2f897cfd72618879f348b9c6c63b6f317d2c5 (patch) | |
tree | 7af6d11513adb3907b1af052adce88268469ad24 /localshowmailreceived | |
parent | 21f80eb17189a95f90f02af1cca52acb5bc31df5 (diff) |
Rewrite to use common localshowlogentries.
Diffstat (limited to 'localshowmailreceived')
-rwxr-xr-x | localshowmailreceived | 50 |
1 files changed, 8 insertions, 42 deletions
diff --git a/localshowmailreceived b/localshowmailreceived index 38bf64a..9278191 100755 --- a/localshowmailreceived +++ b/localshowmailreceived @@ -3,55 +3,21 @@ # /usr/local/sbin/localshowmailreceived # Copyright 2007-2008 Jonas Smedegaard <dr@jones.dk> # -# $Id: localshowmailreceived,v 1.4 2008-02-03 20:10:45 jonas Exp $ +# $Id: localshowmailreceived,v 1.5 2008-02-03 22:09:07 jonas Exp $ # # List recently received emails # # TODO: Handle other patterns than AMaViS # -input="${input:-user}" -output="${output:-shortline}" -logfilecount="${logfilecount:-1}" -pattern="${pattern:-user_amavis}" +set -e mailname="$(cat /etc/mailname | head -n 1)" -sed_longline='s/^\(.\{15\}\) [^:]*: /\1 /' -sed_time='s/^\(.\{15\}\) .*$/\1 /' +localshowlogentries "$1" \ + ' -> <' \ + '@'"$mailname" \ + 's/^\(.\{15\}\) [^)]*) \([^,]*\), [^]]*] \([^ ]*\) -> .*Message-ID: \([^>,]*>\?\).*/\1 \3 (\4) \2/' \ + 's/^.*Message-ID: //;s/: .*$//' -case $pattern in - user_amavis) - # AMaViSd new - egrep_before=' -> <' - egrep_after='@'"$mailname" - sed_shortline='s/^\(.\{15\}\) [^)]*) \([^,]*\), [^]]*] \([^ ]*\) -> .*Message-ID: \([^>,]*>\?\).*/\1 \3 (\4) \2/' - sed_msgid='s/^.*Message-ID: //;s/: .*$//' - ;; - *) - echo >&2 "ERROR: unknwon pattern \"$pattern\"" - exit 1 - ;; -esac - -case $output in - shortline) - sedstring="$sed_shortline" - ;; - longline) - sedstring="$sed_longline" - ;; - msgid) - sedstring="$sed_msgid" - ;; - *) - echo >&2 "ERROR: unknwon output \"$output\"" - exit 1 - ;; -esac - -localuser="$1" - -find /var/log -name 'mail.log*' | sort -nr -t. -k3 | tail -n "$logfilecount" | xargs zcat -f \ - | egrep -- "$egrep_before$localuser$egrep_after" \ - | sed "$sedstring" +exit 0 |