From ce2b04723fe6249cbd8fbd0146f7949c8fb632e6 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Wed, 8 Oct 2014 10:09:14 +0200 Subject: [PATCH] Documentation update. see #609 --- doc/additional/migrating.rst | 13 +++--- .../commands/migrate_from_postfixadmin.py | 41 +------------------ 2 files changed, 7 insertions(+), 47 deletions(-) diff --git a/doc/additional/migrating.rst b/doc/additional/migrating.rst index 4f1e8f71c..22acee28b 100644 --- a/doc/additional/migrating.rst +++ b/doc/additional/migrating.rst @@ -42,23 +42,20 @@ variable and save your changes. You are now ready to start the migration so run the following commands:: $ cd - $ python manage.py migrate_from_postfixadmin -r -p + $ python manage.py migrate_from_postfixadmin -s + +```` must be replaced by the scheme used within +postfixadmin (``crypt`` most of the time). Depending on how many domains/mailboxes your existing setup contains, the migration can be long. Just wait for the script's ending. -.. note:: - - The rename operation is not synchronous. If you choose this option, - you must enable **Handle mailboxes on filesystem** option. See - :ref:`fs_operations`. - The procedure is over, edit the :file:`settings.py` file and: * remove the ``pfxadmin`` database connection from the ``DATABASES`` variable * remove the ``'modoboa.tools.pfxadmin_migrate',`` from the - ``INSTALLED_APPS`` variable + ``MODOBOA_APPS`` variable You should be able to connect to Modoboa using the same credentials you were using to connect to PostfixAdmin. diff --git a/modoboa/tools/pfxadmin_migrate/management/commands/migrate_from_postfixadmin.py b/modoboa/tools/pfxadmin_migrate/management/commands/migrate_from_postfixadmin.py index aacab4111..7b40d5461 100644 --- a/modoboa/tools/pfxadmin_migrate/management/commands/migrate_from_postfixadmin.py +++ b/modoboa/tools/pfxadmin_migrate/management/commands/migrate_from_postfixadmin.py @@ -12,17 +12,6 @@ will be lost on the new database. Here is the list: * Logs * Fetchmail table -Mailboxes organisation on the filesystem will change. PostfixAdmin -uses the following layout:: - - /domain.tld/user@domain.tld/ - -Whereas Modoboa uses the following:: - - /domain.tld/user/ - -To rename directories, you'll need the appropriate permissions. - Domain administrators that manage more than one domain will not be completly restored. They will only be administrator of the domain that corresponds to their username. @@ -44,9 +33,7 @@ used by PostfixAdmin. """ from optparse import make_option -import os import re -import sys from django.contrib.auth.models import Group from django.core.management.base import BaseCommand @@ -89,15 +76,6 @@ class Command(BaseCommand): help="Name of the Modoboa db connection declared in settings.py" " (default is default)" ), - make_option( - "-r", "--rename-dirs", action="store_true", default=False, - help="Rename mailbox directories (default is no)" - ), - make_option( - "-p", "--mboxes-path", default=None, - help="Path where directories are stored on the filesystem" - "(used only if --rename-dirs)" - ), make_option( "-s", "--passwords-scheme", default="crypt", help="Scheme used to crypt user passwords" @@ -184,14 +162,7 @@ class Command(BaseCommand): ) def _migrate_mailboxes(self, domain, options, creator): - """Migrate mailboxes of a single domain. - - .. note:: - - Mailboxes rename will be done later by the - handle_mailboxes_operation script. - - """ + """Migrate mailboxes of a single domain.""" print "\tMigrating mailboxes" old_mboxes = pf_models.Mailbox.objects \ .using(options["_from"]).filter(domain=domain.name) @@ -217,11 +188,6 @@ class Command(BaseCommand): new_mb.set_quota(old_mb.quota / 1024000, override_rules=True) new_mb.save(creator=creator, using=options["_to"]) - if options["rename_dirs"]: - oldpath = os.path.join( - options["mboxes_path"], domain.name, old_mb.maildir) - new_mb.rename_dir(oldpath) - def _migrate_domain(self, pf_domain, options, creator): """Single domain migration.""" print "\nMigrating domain %s" % pf_domain.domain @@ -313,15 +279,12 @@ class Command(BaseCommand): except pf_models.AliasDomain.DoesNotExist: self._migrate_domain(pf_domain, options, creator) - #Handle the ALL domain + # Handle the ALL domain pf_domain = pf_models.Domain.objects.using( options["_from"]).get(domain='ALL') self._migrate_admins(options, creator, pf_domain) def handle(self, *args, **options): """Command entry point.""" - if options["rename_dirs"] and options["mboxes_path"] is None: - print "Error: you must provide the --mboxes-path option" - sys.exit(1) with transaction.commit_on_success(): self._do_migration(options)