update_config_0.3.x-0.4.py
author Pascal Volk <neverseen@users.sourceforge.net>
Mon, 28 Apr 2008 21:33:28 +0000
changeset 24 48ea255e8a85
parent 20 55146c78b3fb
permissions -rwxr-xr-x
* 'vmm.cfg.5' - Added to repository * 'vmm.cfg' * 'update_config_0.3.x-0.4.py' * 'VirtualMailManager/VirtualMailManager.py' * 'VirtualMailManager/Config.py' - Moved option 'base' from section 'maildir' to section 'domdir' * 'VirtualMailManager/Account.py' - Removed parameter 'address' from Account._setAddr() * 'VirtualMailManager/Domain.py' - Added 'ORDER BY' clause in queries in Domain.getAccounts() and Domain.getAliases() * 'setup.py' - Adjusted trove classifiers.

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Copyright 2008 VEB IT
# See COPYING for distribution information.
# $Id$

from ConfigParser import ConfigParser

cff = file('/usr/local/etc/vmm.cfg', 'r')
cf = ConfigParser()
cf.readfp(cff)
cff.close()

if not cf.has_option('misc', 'transport') or not cf.has_section('services') \
or cf.has_option('maildir', 'base'):
    cff = file('/usr/local/etc/vmm.cfg', 'w')
    if not cf.has_option('misc', 'transport'):
        cf.set('misc', 'transport', 'dovecot:')
    if not cf.has_section('services'):
        cf.add_section('services')
        for service in ['smtp', 'pop3', 'imap', 'managesieve']:
            cf.set('services', service, 'true')
    if cf.has_option('maildir', 'base'):
        domdir = cf.get('maildir', 'base')
        cf.remove_option('maildir', 'base')
        cf.set('domdir', 'base', domdir)
    cf.write(cff)
    cff.close()