summaryrefslogtreecommitdiff
path: root/user-mailaddr
blob: 801d147c1b68731144f6d54eec055d5392a4a2ee (plain)
  1. #!/bin/sh
  2. #
  3. # /usr/local/sbin/localusermailaddr
  4. # Copyright 2002 Jonas Smedegaard <dr@jones.dk>
  5. #
  6. # $Id: user-mailaddr,v 1.1 2002-03-14 12:15:33 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\$" `ls /etc/postfix/virtual* | egrep -v '\.(bak|db|dpkg-new|dpkg-old|old)$'` | sed -e 's/.*://' -e 's/[[:space:]].*//' | sort
  13. for otheruid in `grep "^[[:alnum:]-]\+:[[:space:]]\+$uid" /etc/aliases | sed 's/:.*//'`; do
  14. echo "$otheruid@`cat /etc/mailname`"
  15. grep "[[:space:]]$otheruid\$" `ls /etc/postfix/virtual* | egrep -v '\.(bak|db|dpkg-new|dpkg-old|old)$'` | sed -e 's/.*://' -e 's/[[:space:]].*//' | sort
  16. done
  17. done