zimbra-script/zimbra_get_list_users.sh

47 lines
1.4 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/usr/bin/bash
####################################################################
#
# Получение списка пользователей участников списка(ов) рассылки
#
####################################################################
# Автор: Сергей Калинин
# https://nuk-svk.ru
# svk@nuk-svk.ru
####################################################################
#
# Использование:
#
# get_lists_users.sh mail-lists.txt
#
# Где mail-lists.txt файл с перечислением списков рассылки
#
# Формат файла:
# ----------
# list1@example.com
# list2@example.com
# ...
# -----------
#
# На выходе будет CSV формата:
# ----------
# Список - list1@example.com;
# user1@example.com
# user2@example.com
# ...
# Список - list2@example.com;
# user1@example.com
# user3@example.com
# ...
#
####################################################################
IN_FILE=$1
while read LIST_NAME; do
echo "Список - $LIST_NAME;"
/opt/zimbra/bin/zmprov gdl $LIST_NAME | grep zimbraMailForwardingAddress | cut -d":" -f 2 | tr -d " "| while read USER; do
NAME=$(/opt/zimbra/bin/zmprov ga $USER | grep displayName | cut -d":" -f 2)
echo "$USER;$NAME"
done
done < $IN_FILE