update_config_0.3.x-0.4.py
author Pascal Volk <neverseen@users.sourceforge.net>
Tue, 29 Apr 2008 00:13:50 +0000
changeset 25 985cee77da5f
parent 24 48ea255e8a85
permissions -rwxr-xr-x
* 'vmm.cfg.5' - Added sections FILES, SEE ALSO and AUTHOR * 'vmm.1' - Fixed SEE ALSO
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14
ebc9b864bc9a * 'update_config_0.3.x-0.4.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     1
#!/usr/bin/env python
ebc9b864bc9a * 'update_config_0.3.x-0.4.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     2
# -*- coding: UTF-8 -*-
ebc9b864bc9a * 'update_config_0.3.x-0.4.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     3
# Copyright 2008 VEB IT
ebc9b864bc9a * 'update_config_0.3.x-0.4.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     4
# See COPYING for distribution information.
ebc9b864bc9a * 'update_config_0.3.x-0.4.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     5
# $Id$
ebc9b864bc9a * 'update_config_0.3.x-0.4.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     6
ebc9b864bc9a * 'update_config_0.3.x-0.4.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     7
from ConfigParser import ConfigParser
ebc9b864bc9a * 'update_config_0.3.x-0.4.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     8
ebc9b864bc9a * 'update_config_0.3.x-0.4.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     9
cff = file('/usr/local/etc/vmm.cfg', 'r')
ebc9b864bc9a * 'update_config_0.3.x-0.4.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    10
cf = ConfigParser()
ebc9b864bc9a * 'update_config_0.3.x-0.4.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    11
cf.readfp(cff)
ebc9b864bc9a * 'update_config_0.3.x-0.4.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    12
cff.close()
20
55146c78b3fb * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 14
diff changeset
    13
24
48ea255e8a85 * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 20
diff changeset
    14
if not cf.has_option('misc', 'transport') or not cf.has_section('services') \
48ea255e8a85 * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 20
diff changeset
    15
or cf.has_option('maildir', 'base'):
14
ebc9b864bc9a * 'update_config_0.3.x-0.4.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    16
    cff = file('/usr/local/etc/vmm.cfg', 'w')
20
55146c78b3fb * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 14
diff changeset
    17
    if not cf.has_option('misc', 'transport'):
55146c78b3fb * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 14
diff changeset
    18
        cf.set('misc', 'transport', 'dovecot:')
55146c78b3fb * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 14
diff changeset
    19
    if not cf.has_section('services'):
55146c78b3fb * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 14
diff changeset
    20
        cf.add_section('services')
55146c78b3fb * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 14
diff changeset
    21
        for service in ['smtp', 'pop3', 'imap', 'managesieve']:
55146c78b3fb * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 14
diff changeset
    22
            cf.set('services', service, 'true')
24
48ea255e8a85 * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 20
diff changeset
    23
    if cf.has_option('maildir', 'base'):
48ea255e8a85 * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 20
diff changeset
    24
        domdir = cf.get('maildir', 'base')
48ea255e8a85 * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 20
diff changeset
    25
        cf.remove_option('maildir', 'base')
48ea255e8a85 * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 20
diff changeset
    26
        cf.set('domdir', 'base', domdir)
14
ebc9b864bc9a * 'update_config_0.3.x-0.4.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    27
    cf.write(cff)
ebc9b864bc9a * 'update_config_0.3.x-0.4.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    28
    cff.close()