update_config.py
author Pascal Volk <neverseen@users.sourceforge.net>
Sun, 13 Feb 2011 03:32:31 +0000
branchv0.6.x
changeset 402 8984b1f4e6e3
parent 366 d6573da35b5f
child 436 d296a020f440
permissions -rwxr-xr-x
VMM/domain: Execute the database updates of Domain.update_{quotalimit,transport}() when argument force is True, even when the 'new' setting is the same as the current one.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
104
c0b5afb89088 Restored update_*_0.4.x-0.5.p*, modified upgrade.sh for v. 0.5.1
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     1
#!/usr/bin/env python
c0b5afb89088 Restored update_*_0.4.x-0.5.p*, modified upgrade.sh for v. 0.5.1
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     2
# -*- coding: UTF-8 -*-
366
d6573da35b5f Updated copyright notices to include the year 2011.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 358
diff changeset
     3
# Copyright (c) 2008 - 2011, Pascal Volk
104
c0b5afb89088 Restored update_*_0.4.x-0.5.p*, modified upgrade.sh for v. 0.5.1
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     4
# See COPYING for distribution information.
c0b5afb89088 Restored update_*_0.4.x-0.5.p*, modified upgrade.sh for v. 0.5.1
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     5
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
     6
import os
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
     7
os.sys.path.remove(os.sys.path[0])
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
     8
from time import time
104
c0b5afb89088 Restored update_*_0.4.x-0.5.p*, modified upgrade.sh for v. 0.5.1
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     9
from ConfigParser import ConfigParser
c0b5afb89088 Restored update_*_0.4.x-0.5.p*, modified upgrade.sh for v. 0.5.1
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    10
from shutil import copy2
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    11
from VirtualMailManager.constants.VERSION import VERSION
104
c0b5afb89088 Restored update_*_0.4.x-0.5.p*, modified upgrade.sh for v. 0.5.1
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    12
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    13
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    14
def get_config_file():
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    15
    f = None
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    16
    for d in ('/root', '/usr/local/etc', '/etc'):
119
014335f38962 Small code cleanups (replaced dir+'/'+file by os.path.join()).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 118
diff changeset
    17
        tmp = os.path.join(d, 'vmm.cfg')
014335f38962 Small code cleanups (replaced dir+'/'+file by os.path.join()).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 118
diff changeset
    18
        if os.path.isfile(tmp):
014335f38962 Small code cleanups (replaced dir+'/'+file by os.path.join()).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 118
diff changeset
    19
            f = tmp
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    20
            break
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    21
    if f:
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    22
        return f
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    23
    else:
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    24
        os.sys.stderr.write('error: vmm.cfg not found\n')
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    25
        raise SystemExit(2)
104
c0b5afb89088 Restored update_*_0.4.x-0.5.p*, modified upgrade.sh for v. 0.5.1
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    26
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    27
def update(cp):
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    28
    if VERSION == '0.5.2':
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    29
        upd_052(cp)
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    30
    elif VERSION == '0.6.0':
130
9dca3e898ddb avoid error message if used with version 0.5.2
Pascal Volk <neverseen@users.sourceforge.net>
parents: 119
diff changeset
    31
        os.sys.stdout.write('info: nothing to do for version %s\n' % VERSION)
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    32
        return
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    33
    else:
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    34
        os.sys.stderr.write(
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    35
            'error: the version %s is not supported by this script\n' % VERSION)
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    36
        raise SystemExit(3)
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    37
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    38
def get_cfg_parser(cf):
181
866a6d679fce update_config: do not add options w/ default values.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 168
diff changeset
    39
    fh = open(cf, 'r')
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    40
    cp = ConfigParser()
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    41
    cp.readfp(fh)
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    42
    fh.close()
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    43
    return cp
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    44
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    45
def update_cfg_file(cp, cf):
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    46
    copy2(cf, cf+'.bak.'+str(time()))
181
866a6d679fce update_config: do not add options w/ default values.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 168
diff changeset
    47
    fh = open(cf, 'w')
104
c0b5afb89088 Restored update_*_0.4.x-0.5.p*, modified upgrade.sh for v. 0.5.1
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    48
    cp.write(fh)
c0b5afb89088 Restored update_*_0.4.x-0.5.p*, modified upgrade.sh for v. 0.5.1
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    49
    fh.close()
c0b5afb89088 Restored update_*_0.4.x-0.5.p*, modified upgrade.sh for v. 0.5.1
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    50
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    51
def add_sections(cp, sections):
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    52
    for section in sections:
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    53
        if not cp.has_section(section):
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    54
            cp.add_section(section)
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    55
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    56
def move_option(cp, src, dst):
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    57
    ds, do = dst.split('.')
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    58
    if not cp.has_option(ds, do):
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    59
        ss, so = src.split('.')
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    60
        cp.set(ds, do, cp.get(ss, so))
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    61
        cp.remove_option(ss, so)
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    62
        sect_opt.append((dst, 'R'))
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    63
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    64
def add_option(cp, dst, val):
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    65
    ds, do = dst.split('.')
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    66
    if not cp.has_option(ds, do):
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    67
        cp.set(ds, do, val)
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    68
        sect_opt.append((dst, 'N'))
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    69
264
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
    70
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
    71
def set_dovecot_version(cp):
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
    72
    if len(os.sys.argv) > 1:
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
    73
        dovecot_version = os.sys.argv[1].strip()
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
    74
        if not dovecot_version:
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
    75
            dovecot_version = '1.2.11'
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
    76
    else:
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
    77
        dovecot_version = '1.2.11'
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
    78
    cp.set('misc', 'dovecot_version', dovecot_version)
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
    79
    sect_opt.append(('misc.dovecot_version', 'M'))
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
    80
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
    81
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    82
def get_option(cp, src):
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    83
    ss, so = src.split('.')
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    84
    return cp.get(ss, so)
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    85
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    86
def upd_052(cp):
181
866a6d679fce update_config: do not add options w/ default values.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 168
diff changeset
    87
    global had_config
270
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
    88
    global had_gid_mail
181
866a6d679fce update_config: do not add options w/ default values.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 168
diff changeset
    89
866a6d679fce update_config: do not add options w/ default values.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 168
diff changeset
    90
    had_config = cp.remove_section('config')
270
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
    91
    had_gid_mail = cp.remove_option('misc', 'gid_mail')
229
0fb2f12648a7 vmm.cfg: renamed maildir.folders to mailbox.folders. maildir.name
Pascal Volk <neverseen@users.sourceforge.net>
parents: 181
diff changeset
    92
    add_sections(cp, ('domain', 'account', 'mailbox'))
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    93
    if cp.has_section('domdir'):
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    94
        for src, dst in (('domdir.mode',   'domain.directory_mode'),
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    95
                         ('domdir.delete', 'domain.delete_directory'),
168
fd496561acc6 vmm.cfg: a few re-renamed configuration options.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 167
diff changeset
    96
                         ('domdir.base',   'misc.base_directory')):
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    97
            move_option(cp, src, dst)
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    98
        cp.remove_section('domdir')
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    99
    if cp.has_section('services'):
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   100
        for service in cp.options('services'):
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   101
            move_option(cp, 'services.%s'%service, 'account.%s'%service)
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   102
        cp.remove_section('services')
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   103
    for src, dst in (('maildir.mode',      'account.directory_mode'),
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   104
                     ('maildir.diskusage', 'account.disk_usage'),
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   105
                     ('maildir.delete',    'account.delete_directory'),
229
0fb2f12648a7 vmm.cfg: renamed maildir.folders to mailbox.folders. maildir.name
Pascal Volk <neverseen@users.sourceforge.net>
parents: 181
diff changeset
   106
                     ('maildir.folders',   'mailbox.folders'),
298
ee89399346cb VMM/Config: Added mailbox.root setting.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 270
diff changeset
   107
                     ('maildir.name',      'mailbox.root'),
168
fd496561acc6 vmm.cfg: a few re-renamed configuration options.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 167
diff changeset
   108
                     ('misc.forcedel',     'domain.force_deletion'),
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   109
                     ('misc.passwdscheme', 'misc.password_scheme'),
168
fd496561acc6 vmm.cfg: a few re-renamed configuration options.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 167
diff changeset
   110
                     ('misc.dovecotvers',  'misc.dovecot_version')):
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   111
        move_option(cp, src, dst)
229
0fb2f12648a7 vmm.cfg: renamed maildir.folders to mailbox.folders. maildir.name
Pascal Volk <neverseen@users.sourceforge.net>
parents: 181
diff changeset
   112
    cp.remove_section('maildir')
358
6fabb9cd212d update_config: Set pyPgSQL, maybe there is no psycopg2 installed.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 298
diff changeset
   113
    add_option(cp, 'database.module', 'pyPgSQL')
264
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
   114
    set_dovecot_version(cp)
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
   115
104
c0b5afb89088 Restored update_*_0.4.x-0.5.p*, modified upgrade.sh for v. 0.5.1
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   116
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   117
# def main():
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   118
if __name__ == '__main__':
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   119
    sect_opt = []
181
866a6d679fce update_config: do not add options w/ default values.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 168
diff changeset
   120
    had_config = False
270
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   121
    had_gid_mail = False
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   122
    cf = get_config_file()
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   123
    cp = get_cfg_parser(cf)
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   124
    update(cp)
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   125
    if len(sect_opt):
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   126
        update_cfg_file(cp, cf)
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   127
        sect_opt.sort()
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   128
        print 'Please have a look at your configuration: %s' %cf
264
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
   129
        print 'This are your Modified/Renamed/New settings:'
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   130
        for s_o, st in sect_opt:
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   131
            print '%s   %s = %s' % (st, s_o, get_option(cp, s_o))
270
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   132
        if had_config:
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   133
            print '\nRemoved section "config" with option "done" (obsolte)'
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   134
        if had_gid_mail:
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   135
            print '\nRemoved option "gid_mail" from section "misc" (obsolte)\n'
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   136
        os.sys.exit(0)
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   137
    if had_config or had_gid_mail:
181
866a6d679fce update_config: do not add options w/ default values.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 168
diff changeset
   138
        update_cfg_file(cp, cf)
270
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   139
        if had_config:
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   140
            print '\nRemoved section "config" with option "done" (obsolte)'
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   141
        if had_gid_mail:
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   142
            print '\nRemoved option "gid_mail" from section "misc" (obsolte)\n'