/vpopmail2postfixadmin

Script for migrating vpopmail servers to Postfixadmin-style ones

Primary LanguagePerl

vpopmail2postfixadmin

This is a set of scripts to use when migrating accounts and domains from a system running Inter7's vpopmail to one running postfixadmin.

There will be four scripts:

  • export.pl is run on the vpopmail system and creates a file describing the domains and accounts.
  • import.pl is run on the postfixadmin system and reads the above file to configure the server.
  • sync.pl rsyncs the maildirs from the vpopmail system to the postfixadmin one
  • test.pl checks that everything's worked.

The export requires a vpopmail module, and the import one equires my Postfixadmin module. They all require YAML, but everything else should be core Perl. sync.pl requires rsync, and they all make use of Linuxy coreutils (chown, chmod, mkdir etc.).

limitations

It can currently only migrate four things:

  • domains
  • usernames
  • passwords
  • forwarding addresses

Getting the password synced requires that vpopmail be storing it in cleartext. This is checked for each mailbox and those missing passwords have them generated for them; passwords generated so are written to a file called passwords in the current directory.

Forwarding addresses are deduced from some forms of piping into vdelivermail, and should be deduced from mailbox lines (but aren't).

export.pl

exports config from the vpopmail system on the machine it's run on using Mail::vpopmail. Dumps the config to the file passed as its only argument, as a YAML file. There's no options and the only argument it understands is a path to a file:

export.pl ./somefile

import.pl

Imports config from the file it's passed (as produced by export.pl) and inserts it into the postfixadmin system on the machine it's run on. Requires Mail::Postfixadmin.

	import.pl <options> -f <file>

Options:
        -d              Dry run; do everything except that which
                        involves writing to the db.
        -f <file>       Read from <file> for config data. 
        -g <expr>       evaluate expr to generate passwords where 
                        necessary (see below). Is executed in the 
                        shell, not perl. Default: `pwgen 10 1`
        -h              Show this help
        -p <file>       Write generated passwords to <file>
                        Default: ./passwords
        -v <num>        Set verbosity to num, will print:
                        1 : Only those lines from .qmail files
                            that I don't understand
                        2 : Name of each domain configured
                        3 : Username of each user configured
                        4 : Parameters used for each domain and 
                            user (except passwords)
                        9 : Clear-text passwords of each user

Verbosity is cumulative - setting it to 3 will enable 2 and 1, 
too. That which is printed at 1 is printed to STDERR, 
irrespective of higher numbers (which go to STDOUT).

Users in the supplied config with no clear-text passwords have
one generated for them using the parameter to -g (or its 
default) these usernames and their auto-generated passwords 
written to the password file specified by -p (or its default).