update_config_0.3.x-0.4.py
changeset 24 48ea255e8a85
parent 20 55146c78b3fb
equal deleted inserted replaced
23:d5ad5432e9eb 24:48ea255e8a85
     9 cff = file('/usr/local/etc/vmm.cfg', 'r')
     9 cff = file('/usr/local/etc/vmm.cfg', 'r')
    10 cf = ConfigParser()
    10 cf = ConfigParser()
    11 cf.readfp(cff)
    11 cf.readfp(cff)
    12 cff.close()
    12 cff.close()
    13 
    13 
    14 if not cf.has_option('misc', 'transport') or not cf.has_section('services'):
    14 if not cf.has_option('misc', 'transport') or not cf.has_section('services') \
       
    15 or cf.has_option('maildir', 'base'):
    15     cff = file('/usr/local/etc/vmm.cfg', 'w')
    16     cff = file('/usr/local/etc/vmm.cfg', 'w')
    16     if not cf.has_option('misc', 'transport'):
    17     if not cf.has_option('misc', 'transport'):
    17         cf.set('misc', 'transport', 'dovecot:')
    18         cf.set('misc', 'transport', 'dovecot:')
    18     if not cf.has_section('services'):
    19     if not cf.has_section('services'):
    19         cf.add_section('services')
    20         cf.add_section('services')
    20         for service in ['smtp', 'pop3', 'imap', 'managesieve']:
    21         for service in ['smtp', 'pop3', 'imap', 'managesieve']:
    21             cf.set('services', service, 'true')
    22             cf.set('services', service, 'true')
       
    23     if cf.has_option('maildir', 'base'):
       
    24         domdir = cf.get('maildir', 'base')
       
    25         cf.remove_option('maildir', 'base')
       
    26         cf.set('domdir', 'base', domdir)
    22     cf.write(cff)
    27     cf.write(cff)
    23     cff.close()
    28     cff.close()