On Tue, Nov 19, 2013 at 05:33:30PM -0500, Wietse Venema wrote:

> --8<-snip-here--8<--
> #!/bin/sh
> 
> case $# in 
> 0) echo usage: $0 example.com ... 1>&2; exit 1;;
> esac
> 
> VIRTUAL_MAP=/etc/postfix/virtual
> VIRTUAL_DOMAINS=/etc/postfix/virtual_domains
> 
> for domainname
> do
>       echo postmaster@domainname root
>       echo abuse@domainname root
> done >> $VIRTUAL_MAP
> postmap $VIRTUAL_MAP
> 
> echo domainname >>$VIRTUAL_DOMAINS
> postmap $VIRTUAL_DOMAINS
> --8<-snip-here--8<--

Replacing domainname with "${domainname}" as required:

--8<-snip-here--8<--
#!/bin/sh

case $# in 
0) echo usage: $0 example.com ... 1>&2; exit 1;;
esac

VIRTUAL_MAP=/etc/postfix/virtual
VIRTUAL_DOMAINS=/etc/postfix/virtual_domains

for domainname
do
        echo "postmaster@${domainname}" root
        echo "abuse@${domainname}" root
done >> $VIRTUAL_MAP
postmap $VIRTUAL_MAP

echo "${domainname} >>$VIRTUAL_DOMAINS
postmap $VIRTUAL_DOMAINS
--8<-snip-here--8<--

Run this once for each new domain.  A more sophisticated approach
is to use a Makefile, with a list of domains in a separate file,
and the virtual table constructed from this and other files that
contain ad-hoc mappings.

-- 
        Viktor.

Reply via email to