summaryrefslogtreecommitdiff
path: root/user-mailaddr
blob: c583f44e737d6c209649be7e564c25b402f57722 (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.2 2005-02-08 10:50:49 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:]].*//' | grep -v '^$' | 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:]].*//' | grep -v '^$' | sort
  16. done
  17. done