migrating mailbox configurations from qmail/vpopmail to postfix

Although I use tinydns, I don't exactly like qmail because it's too much of a spartan. I do postfix. Call it church practice. My migration procedure was pretty simple and I'll touch below only a part of it, the configuration of mailboxes. I didn't have anything else to take care of other than forwards and local maildirs so I didn't treat the case of mail pipes (one needs to translate those into postfix transport maps).
You probably want to modify the config vars (first lines). The script will append whatever generates to existent postfix config files.



#!/bin/sh
vpopmail_dir="/usr/local/vpopmail/domains"
pfix_cfgdir="/usr/local/etc/postfix"
pfix_vdomains="${pfix_cfgdir}/virtual_domains"
pfix_valiases="${pfix_cfgdir}/virtual_alias"
pfix_vmboxes="${pfix_cfgdir}/virtual"
pfix_dbfmt="cdb"
postmap="postmap"
(cd $vpopmail_dir &&
/bin/ls -1 | sed "s/^\(.*\)\$/\1 OK/w ${pfix_vdomains}" |awk '{ print $1; }' |\
while read domain; do
find $domain -name ".qmail-*" -maxdepth 1 -mindepth 1 | \
grep -v 'default' | sed 's/^.*\/.qmail-/ /' | \
while read emaddr ; do
(echo -n "$emaddr@$domain "; grep -E '^&' $vpopmail_dir/$domain/.qmail-$emaddr | \
sed -n 's/^\&//;1h;2,$H;${g;s/\n/,/g;p;}') >>${pfix_valiases}
done
done
find * -type d -maxdepth 1 -mindepth 1 | \
sed 's/\([^\/]*\)\/\(.*\)$/\2\@\1 \1\/\2\/Maildir\//' >>${pfix_vmboxes}
)
( cd ${pfix_cfgdir} &&
for cf in ${pfix_vdomains} ${pfix_valiases} ${pfix_vmboxes} ; do
${postmap} -c `pwd` ${pfix_dbfmt}:$cf
done
)

No comments:

Post a Comment