From 3be9849d8548d1af073a6d3db21cd15e2172604d Mon Sep 17 00:00:00 2001 From: root Date: Mon, 14 Sep 2009 05:57:19 +0200 Subject: Extend localmailrecipientsdump to (crudely) handle sympa domains. --- localmailrecipientsdump | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'localmailrecipientsdump') diff --git a/localmailrecipientsdump b/localmailrecipientsdump index 6662d55..d96038f 100755 --- a/localmailrecipientsdump +++ b/localmailrecipientsdump @@ -29,7 +29,12 @@ aliasmaps() { virtualmaps() { set -e - perl -ne 's/^virtual_maps\s*=\s*// and print' < /etc/postfix/main.cf | tr ',' ' ' + newmaps="$(postconf -h virtual_alias_maps)" + if [ '$virtual_maps' = "$newmaps" ]; then + perl -ne 's/^virtual_maps\s*=\s*// and print' < /etc/postfix/main.cf | tr ',' ' ' + else + echo "$newmaps" | tr ',' ' ' + fi } accounts() { @@ -49,11 +54,23 @@ mkrecipientsmap() { done done for map in $(virtualmaps); do - postmap -s $map | perl -ne 's/^([a-z]\S*\@\S+)\s.*/$1 OK/ and print' + case $map in + regexp:/etc/mail/sympa_virtual_regexp_*) + # FIXME: replace catch-all with actual accounts + echo "$map" | perl -ne 's,regexp:/etc/mail/sympa_virtual_regexp_(\S+).*,\@$1 OK, and print' + ;; + hash:*) + postmap -s $map | perl -ne 's/^([a-z]\S*\@\S+)\s.*/$1 OK/ and print' + ;; + *) + echo >&2 "Unsupported map type: $map" + exit 1 + ;; + esac done } redpill="$(firstitem "/etc/local-ORG/redpill")" realm="$(firstitem "/etc/local-ORG/realm")" -mkrecipientsmap | sort -t@ -k2 -k1 > "/etc/local-$redpill/$realm/mailrecipients" +mkrecipientsmap | LC_ALL=C sort -t@ -k2 -k1 > "/etc/local-$redpill/$realm/mailrecipients" -- cgit v1.2.3