Created
November 16, 2015 17:41
-
-
Save drAlberT/b0e7f4b7320dd526323d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# /usr/local/bin/listAliasByDomain | |
# | |
# Lists all aliases for mailboxes and distribution lists associated with a particular domain | |
# | |
# Syntax: listAliasByDomain someMailDomain.com | |
# | |
# The settings for the LDAP queries are guesses. They work for me, but if I have overlooked | |
# something, please let me know! | |
# | |
# -- | |
# Phil Freed <[email protected]> | |
# Emiliano Gabrielli <[email protected]> | |
# | |
# EXAMPLE: | |
# for d in $(zmprov gad name); | |
# do | |
# listAliasByDomain $d >> /tmp/mail_lists.txt; | |
# done | |
# | |
######### | |
DOMAIN="$1" | |
if [ -z "$DOMAIN" ]; | |
then | |
echo | |
echo "ERROR!" | |
echo "Syntax: `basename $0` yourMailDomain.com" | |
echo | |
exit 2 | |
fi | |
( | |
echo | |
echo -e "# Domain: $DOMAIN" | |
echo -e "\t## Mailboxes:" | |
zmprov sa -v "(zimbraMailDeliveryAddress=*@$DOMAIN)" | perl -ne \ | |
' | |
if ( s/^# name /\t\t/ | |
or s/^zimbraMailForwardingAddress:/\t\t>>>>> : / | |
or s/^zimbraMailAlias:/\t\tAlias : / | |
) { print $_; } | |
' | |
echo | |
echo -e "\t## Distribution Lists:" | |
for dl in $(zmprov sa "(objectClass=zimbraDistributionList)" domain $DOMAIN); | |
do | |
zmprov gdl $dl | perl -ne \ | |
' | |
if ( s/^# distributionList (.*)memberCount.*$/\t\tDist. List: $1/ | |
or s/^zimbraMailForwardingAddress:/\t\t>>>>> : / | |
or s/^zimbraMailAlias:/\t\tAlias : / | |
) { print $_; } | |
' | |
done | |
) >&1 | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment