update_config_0.4.x-0.5.py
author Pascal Volk <neverseen@users.sourceforge.net>
Thu, 11 Sep 2008 20:38:30 +0000
changeset 82 6c85915f3815
parent 68 7ae95b9938c4
child 86 e43e4e7e9ec0
permissions -rwxr-xr-x
„speedup commit“ ;-) * 'VirtualMailManager/Account.py' - Account.__init__() checks only the existence of an alias or relocated record if there is no account with the supplied address yet * 'VirtualMailManager/Alias.py' - Alias.__init__() checks only the existence of an account or relocated record if there is no alias with the supplied address yet * 'VirtualMailManager/Relocated.py' - Relocated.__init__() checks only the existence of an account or alias record if there is no relocated user with the supplied address yet * 'create_optional_types_and_functions.pgsql' - Modified the 2nd part of postfix_smtpd_sender_login_map() in order to save 0.3 ms
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
68
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     1
#!/usr/bin/env python
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     2
# -*- coding: UTF-8 -*-
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     3
# Copyright 2008 VEB IT
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     4
# See COPYING for distribution information.
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     5
# $Id$
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     6
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     7
from ConfigParser import ConfigParser
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     8
from shutil import copy2
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     9
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    10
cf = '/usr/local/etc/vmm.cfg'
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    11
fh = file(cf, 'r')
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    12
cp = ConfigParser()
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    13
cp.readfp(fh)
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    14
fh.close()
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    15
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    16
if not cp.has_option('maildir', 'name') or not cp.has_option('maildir',
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    17
        'folders') or cp.has_option('maildir', 'folder'):
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    18
    copy2(cf, cf+'.bak_upd_0.4.x-0.5')
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    19
    fh = file(cf, 'w')
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    20
    if not cp.has_option('maildir', 'name'):
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    21
        if cp.has_option('maildir', 'folder'):
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    22
            cp.set('maildir', 'name', cp.get('maildir', 'folder'))
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    23
            cp.remove_option('maildir', 'folder')
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    24
        else:
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    25
            cp.set('maildir', 'name', 'Maildir')
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    26
    if not cp.has_option('maildir', 'folders'):
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    27
        cp.set('maildir', 'folders', 'Drafts:Sent:Templates:Trash')
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    28
    if cp.has_option('maildir', 'folder'):
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    29
        cp.remove_option('maildir', 'folder')
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    30
    cp.write(fh)
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    31
    fh.close()