update_config.py
author "martin f. krafft" <madduck@debian.org>
Tue, 07 Aug 2012 21:54:39 +0000
changeset 583 a479c38931c4
parent 568 14abdd04ddf5
child 623 d7101e496795
permissions -rwxr-xr-x
If an alias has multiple destinations, multiple records exist, due to the nature of the database. address_list would then return the same alias multiple times, which does not add any information, eats screen space and is potentially confusing. Therefore, we SELECT DISTINCTly from the alias table. Signed-off-by: martin f. krafft <madduck@debian.org> --- VirtualMailManager/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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 -*-
568
14abdd04ddf5 Updated copyright notices to include the year 2012.
Pascal Volk <user@localhost.localdomain.org>
parents: 483
diff changeset
     3
# Copyright (c) 2008 - 2012, 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
483
fb210a116f18 update_config: Write the old package install dir to a tmp file.
Pascal Volk <user@localhost.localdomain.org>
parents: 459
diff changeset
    11
try:
fb210a116f18 update_config: Write the old package install dir to a tmp file.
Pascal Volk <user@localhost.localdomain.org>
parents: 459
diff changeset
    12
    from VirtualMailManager.constants.VERSION import VERSION
fb210a116f18 update_config: Write the old package install dir to a tmp file.
Pascal Volk <user@localhost.localdomain.org>
parents: 459
diff changeset
    13
except ImportError:
fb210a116f18 update_config: Write the old package install dir to a tmp file.
Pascal Volk <user@localhost.localdomain.org>
parents: 459
diff changeset
    14
    os.sys.stderr.write('error: no pre 0.6.0 version information found\n')
fb210a116f18 update_config: Write the old package install dir to a tmp file.
Pascal Volk <user@localhost.localdomain.org>
parents: 459
diff changeset
    15
    raise SystemExit(2)
fb210a116f18 update_config: Write the old package install dir to a tmp file.
Pascal Volk <user@localhost.localdomain.org>
parents: 459
diff changeset
    16
fb210a116f18 update_config: Write the old package install dir to a tmp file.
Pascal Volk <user@localhost.localdomain.org>
parents: 459
diff changeset
    17
# we have to remove the old CamelCase files
fb210a116f18 update_config: Write the old package install dir to a tmp file.
Pascal Volk <user@localhost.localdomain.org>
parents: 459
diff changeset
    18
import VirtualMailManager
fb210a116f18 update_config: Write the old package install dir to a tmp file.
Pascal Volk <user@localhost.localdomain.org>
parents: 459
diff changeset
    19
vmm_inst_dir = os.path.dirname(VirtualMailManager.__file__)
fb210a116f18 update_config: Write the old package install dir to a tmp file.
Pascal Volk <user@localhost.localdomain.org>
parents: 459
diff changeset
    20
tmp_info = open('/tmp/vmm_inst_dir', 'w')
fb210a116f18 update_config: Write the old package install dir to a tmp file.
Pascal Volk <user@localhost.localdomain.org>
parents: 459
diff changeset
    21
tmp_info.write(vmm_inst_dir)
fb210a116f18 update_config: Write the old package install dir to a tmp file.
Pascal Volk <user@localhost.localdomain.org>
parents: 459
diff changeset
    22
tmp_info.close()
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
    23
436
d296a020f440 update_config: Set database.module to pyPgSQL only when psycopg2
Pascal Volk <neverseen@users.sourceforge.net>
parents: 366
diff changeset
    24
try:
d296a020f440 update_config: Set database.module to pyPgSQL only when psycopg2
Pascal Volk <neverseen@users.sourceforge.net>
parents: 366
diff changeset
    25
    import psycopg2
d296a020f440 update_config: Set database.module to pyPgSQL only when psycopg2
Pascal Volk <neverseen@users.sourceforge.net>
parents: 366
diff changeset
    26
except ImportError:
d296a020f440 update_config: Set database.module to pyPgSQL only when psycopg2
Pascal Volk <neverseen@users.sourceforge.net>
parents: 366
diff changeset
    27
    has_psycopg2 = False
d296a020f440 update_config: Set database.module to pyPgSQL only when psycopg2
Pascal Volk <neverseen@users.sourceforge.net>
parents: 366
diff changeset
    28
else:
d296a020f440 update_config: Set database.module to pyPgSQL only when psycopg2
Pascal Volk <neverseen@users.sourceforge.net>
parents: 366
diff changeset
    29
    has_psycopg2 = True
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    30
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    31
def get_config_file():
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    32
    f = None
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    33
    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
    34
        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
    35
        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
    36
            f = tmp
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    37
            break
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    38
    if f:
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    39
        return f
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    40
    else:
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    41
        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
    42
        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
    43
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    44
def update(cp):
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    45
    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
    46
        upd_052(cp)
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    47
    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
    48
        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
    49
        return
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    50
    else:
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    51
        os.sys.stderr.write(
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    52
            '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
    53
        raise SystemExit(3)
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    54
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    55
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
    56
    fh = open(cf, 'r')
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    57
    cp = ConfigParser()
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    58
    cp.readfp(fh)
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    59
    fh.close()
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    60
    return cp
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    61
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    62
def update_cfg_file(cp, cf):
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    63
    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
    64
    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
    65
    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
    66
    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
    67
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    68
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
    69
    for section in sections:
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    70
        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
    71
            cp.add_section(section)
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    72
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    73
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
    74
    ds, do = dst.split('.')
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    75
    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
    76
        ss, so = src.split('.')
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    77
        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
    78
        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
    79
        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
    80
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    81
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
    82
    ds, do = dst.split('.')
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    83
    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
    84
        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
    85
        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
    86
264
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
    87
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
    88
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
    89
    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
    90
        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
    91
        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
    92
            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
    93
    else:
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
    94
        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
    95
    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
    96
    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
    97
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
    98
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    99
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
   100
    ss, so = src.split('.')
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   101
    return cp.get(ss, so)
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   102
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   103
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
   104
    global had_config
270
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   105
    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
   106
866a6d679fce update_config: do not add options w/ default values.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 168
diff changeset
   107
    had_config = cp.remove_section('config')
270
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   108
    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
   109
    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
   110
    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
   111
        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
   112
                         ('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
   113
                         ('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
   114
            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
   115
        cp.remove_section('domdir')
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   116
    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
   117
        for service in cp.options('services'):
459
033a0436894f update_config: Updated, so that the previous config modifications
Pascal Volk <neverseen@users.sourceforge.net>
parents: 436
diff changeset
   118
            move_option(cp, 'services.%s' % service, 'domain.%s' % service)
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   119
        cp.remove_section('services')
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   120
    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
   121
                     ('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
   122
                     ('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
   123
                     ('maildir.folders',   'mailbox.folders'),
298
ee89399346cb VMM/Config: Added mailbox.root setting.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 270
diff changeset
   124
                     ('maildir.name',      'mailbox.root'),
168
fd496561acc6 vmm.cfg: a few re-renamed configuration options.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 167
diff changeset
   125
                     ('misc.forcedel',     'domain.force_deletion'),
459
033a0436894f update_config: Updated, so that the previous config modifications
Pascal Volk <neverseen@users.sourceforge.net>
parents: 436
diff changeset
   126
                     ('misc.transport',    'domain.transport'),
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   127
                     ('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
   128
                     ('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
   129
        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
   130
    cp.remove_section('maildir')
436
d296a020f440 update_config: Set database.module to pyPgSQL only when psycopg2
Pascal Volk <neverseen@users.sourceforge.net>
parents: 366
diff changeset
   131
    if not has_psycopg2:
d296a020f440 update_config: Set database.module to pyPgSQL only when psycopg2
Pascal Volk <neverseen@users.sourceforge.net>
parents: 366
diff changeset
   132
        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
   133
    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
   134
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
   135
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   136
# def main():
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   137
if __name__ == '__main__':
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   138
    sect_opt = []
181
866a6d679fce update_config: do not add options w/ default values.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 168
diff changeset
   139
    had_config = False
270
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   140
    had_gid_mail = False
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   141
    cf = get_config_file()
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   142
    cp = get_cfg_parser(cf)
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   143
    update(cp)
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   144
    if len(sect_opt):
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   145
        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
   146
        sect_opt.sort()
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   147
        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
   148
        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
   149
        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
   150
            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
   151
        if had_config:
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   152
            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
   153
        if had_gid_mail:
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   154
            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
   155
        os.sys.exit(0)
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   156
    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
   157
        update_cfg_file(cp, cf)
270
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   158
        if had_config:
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   159
            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
   160
        if had_gid_mail:
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   161
            print '\nRemoved option "gid_mail" from section "misc" (obsolte)\n'