From c7a9e07d9d73526d2d4c4329db131578231915e9 Mon Sep 17 00:00:00 2001 From: tonio Date: Fri, 19 Jun 2009 14:48:18 +0200 Subject: [PATCH] A little script to simplify migration from 0.5 to 0.6 --- INSTALL | 6 ++++++ scripts/upgrade_autoreply.py | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100755 scripts/upgrade_autoreply.py diff --git a/INSTALL b/INSTALL index 4fb35c5fd..fe32ee55b 100644 --- a/INSTALL +++ b/INSTALL @@ -43,6 +43,12 @@ current installation. Once done, go to MailNG repository and run:: You must also modify 'settings.py' in order to activate new components. +If you plan to use the 'Postfix autoreply' extension, you'll need to run +the following script to make it work correctly:: + + export PYTHONPATH=$PWD/.. + DJANGO_SETTINGS_MODULE=mailng.settings ./scripts/upgrade_autoreply.py + Host configuration ------------------ diff --git a/scripts/upgrade_autoreply.py b/scripts/upgrade_autoreply.py new file mode 100755 index 000000000..d532640bf --- /dev/null +++ b/scripts/upgrade_autoreply.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from django.conf import settings +from mailng.admin.models import Domain, Mailbox + +if __name__ == "__main__": + if "mailng.extensions.postfix_autoreply" in settings.INSTALLED_APPS: + import mailng.extensions.postfix_autoreply.main as par + from mailng.extensions.postfix_autoreply.models import Transport, Alias + + doms = Domain.objects.all() + for dom in doms: + try: + trans = Transport.objects.get(domain="autoreply.%s" % dom.name) + continue + except Transport.DoesNotExist: + par.onCreateDomain(dom=dom) + mboxes = Mailbox.objects.filter(domain=dom.id) + for mb in mboxes: + try: + alias = Alias.objects.get(full_address=mb.full_address) + continue + except Alias.DoesNotExist: + par.onCreateMailbox(mbox=mb) +