summaryrefslogtreecommitdiff
path: root/user-mailaddr
blob: 5a848f0e4a7cf694bce7c3d2abc3ba4b26ac20a5 (plain)
  1. #!/bin/sh
  2. #
  3. # /usr/local/sbin/localusermailaddr
  4. # Copyright 2002 - 2006 Jonas Smedegaard <dr@jones.dk>
  5. #
  6. # $Id: user-mailaddr,v 1.4 2006-05-05 10:25:41 jonas Exp $
  7. #
  8. # List mail addresses attached to an account
  9. #
  10. for uid in $@; do
  11. echo "$uid@`cat /etc/mailname`"
  12. # grep "[[:space:]]$uid\$" | sed -e 's/.*://' -e 's/[[:space:]].*//' | grep -v '^$' | sort
  13. find /etc/postfix -regex '.*/virtual[^.]*' -exec grep "[[:space:]]$uid\$" '{}' ';' | sed -e 's/.*://' -e 's/[[:space:]].*//' | grep -v '^$' | sort
  14. for otheruid in `grep "^[[:alnum:]-]\+:[[:space:]]\+$uid" /etc/aliases | sed 's/:.*//'`; do
  15. echo "$otheruid@`cat /etc/mailname`"
  16. find /etc/postfix -regex '.*/virtual[^.]*' -exec grep "[[:space:]]$otheruid\$" '{}' ';' | sed -e 's/.*://' -e 's/[[:space:]].*//' | grep -v '^$' | sort
  17. done
  18. done