update_config.py
author Pascal Volk <neverseen@users.sourceforge.net>
Fri, 28 Oct 2011 15:51:31 +0000
branchv0.6.x
changeset 437 9823548b2717
parent 436 d296a020f440
child 459 033a0436894f
permissions -rwxr-xr-x
pgsql: Added new table `service_set'. Moved columns `smtp', `pop3' `imap' and `sieve' from the `users' table to the new `service_set' table.
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
436
d296a020f440 update_config: Set database.module to pyPgSQL only when psycopg2
Pascal Volk <neverseen@users.sourceforge.net>
parents: 366
diff changeset
    13
try:
d296a020f440 update_config: Set database.module to pyPgSQL only when psycopg2
Pascal Volk <neverseen@users.sourceforge.net>
parents: 366
diff changeset
    14
    import psycopg2
d296a020f440 update_config: Set database.module to pyPgSQL only when psycopg2
Pascal Volk <neverseen@users.sourceforge.net>
parents: 366
diff changeset
    15
except ImportError:
d296a020f440 update_config: Set database.module to pyPgSQL only when psycopg2
Pascal Volk <neverseen@users.sourceforge.net>
parents: 366
diff changeset
    16
    has_psycopg2 = False
d296a020f440 update_config: Set database.module to pyPgSQL only when psycopg2
Pascal Volk <neverseen@users.sourceforge.net>
parents: 366
diff changeset
    17
else:
d296a020f440 update_config: Set database.module to pyPgSQL only when psycopg2
Pascal Volk <neverseen@users.sourceforge.net>
parents: 366
diff changeset
    18
    has_psycopg2 = True
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    19
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    20
def get_config_file():
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    21
    f = None
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    22
    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
    23
        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
    24
        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
    25
            f = tmp
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    26
            break
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    27
    if f:
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    28
        return f
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    29
    else:
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    30
        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
    31
        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
    32
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    33
def update(cp):
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    34
    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
    35
        upd_052(cp)
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    36
    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
    37
        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
    38
        return
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    39
    else:
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    40
        os.sys.stderr.write(
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    41
            '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
    42
        raise SystemExit(3)
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    43
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    44
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
    45
    fh = open(cf, 'r')
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    46
    cp = ConfigParser()
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    47
    cp.readfp(fh)
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    48
    fh.close()
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    49
    return cp
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    50
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    51
def update_cfg_file(cp, cf):
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    52
    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
    53
    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
    54
    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
    55
    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
    56
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    57
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
    58
    for section in sections:
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    59
        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
    60
            cp.add_section(section)
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    61
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    62
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
    63
    ds, do = dst.split('.')
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    64
    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
    65
        ss, so = src.split('.')
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    66
        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
    67
        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
    68
        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
    69
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    70
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
    71
    ds, do = dst.split('.')
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    72
    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
    73
        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
    74
        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
    75
264
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
    76
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
    77
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
    78
    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
    79
        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
    80
        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
    81
            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
    82
    else:
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
    83
        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
    84
    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
    85
    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
    86
04fea4d8b900 Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents: 229
diff changeset
    87
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    88
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
    89
    ss, so = src.split('.')
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    90
    return cp.get(ss, so)
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
    91
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
    92
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
    93
    global had_config
270
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
    94
    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
    95
866a6d679fce update_config: do not add options w/ default values.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 168
diff changeset
    96
    had_config = cp.remove_section('config')
270
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
    97
    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
    98
    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
    99
    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
   100
        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
   101
                         ('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
   102
                         ('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
   103
            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
   104
        cp.remove_section('domdir')
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   105
    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
   106
        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
   107
            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
   108
        cp.remove_section('services')
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   109
    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
   110
                     ('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
   111
                     ('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
   112
                     ('maildir.folders',   'mailbox.folders'),
298
ee89399346cb VMM/Config: Added mailbox.root setting.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 270
diff changeset
   113
                     ('maildir.name',      'mailbox.root'),
168
fd496561acc6 vmm.cfg: a few re-renamed configuration options.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 167
diff changeset
   114
                     ('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
   115
                     ('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
   116
                     ('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
   117
        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
   118
    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
   119
    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
   120
        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
   121
    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
   122
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
   123
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   124
# def main():
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   125
if __name__ == '__main__':
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   126
    sect_opt = []
181
866a6d679fce update_config: do not add options w/ default values.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 168
diff changeset
   127
    had_config = False
270
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   128
    had_gid_mail = False
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   129
    cf = get_config_file()
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   130
    cp = get_cfg_parser(cf)
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   131
    update(cp)
167
bb58aedefa3a update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 162
diff changeset
   132
    if len(sect_opt):
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   133
        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
   134
        sect_opt.sort()
118
cf85d78486ce Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents: 104
diff changeset
   135
        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
   136
        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
   137
        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
   138
            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
   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'
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   143
        os.sys.exit(0)
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   144
    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
   145
        update_cfg_file(cp, cf)
270
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   146
        if had_config:
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   147
            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
   148
        if had_gid_mail:
d3389645a91d configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 264
diff changeset
   149
            print '\nRemoved option "gid_mail" from section "misc" (obsolte)\n'