author | Pascal Volk <user@localhost.localdomain.org> |
Mon, 05 Nov 2012 21:57:37 +0000 | |
branch | v0.7.x |
changeset 638 | 0de0b9e75c9f |
parent 623 | d7101e496795 |
child 643 | df1e3b67882a |
child 675 | d24f094d1cb5 |
permissions | -rwxr-xr-x |
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 |
623
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
11 |
|
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
12 |
pre_060 = False |
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
13 |
|
483
fb210a116f18
update_config: Write the old package install dir to a tmp file.
Pascal Volk <user@localhost.localdomain.org>
parents:
459
diff
changeset
|
14 |
try: |
fb210a116f18
update_config: Write the old package install dir to a tmp file.
Pascal Volk <user@localhost.localdomain.org>
parents:
459
diff
changeset
|
15 |
from VirtualMailManager.constants.VERSION import VERSION |
623
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
16 |
pre_060 = True |
483
fb210a116f18
update_config: Write the old package install dir to a tmp file.
Pascal Volk <user@localhost.localdomain.org>
parents:
459
diff
changeset
|
17 |
except ImportError: |
623
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
18 |
try: |
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
19 |
from VirtualMailManager.constants import VERSION |
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
20 |
except ImportError: |
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
21 |
os.sys.stderr.write('error: no vmm version information found\n') |
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
22 |
raise SystemExit(2) |
483
fb210a116f18
update_config: Write the old package install dir to a tmp file.
Pascal Volk <user@localhost.localdomain.org>
parents:
459
diff
changeset
|
23 |
|
fb210a116f18
update_config: Write the old package install dir to a tmp file.
Pascal Volk <user@localhost.localdomain.org>
parents:
459
diff
changeset
|
24 |
# we have to remove the old CamelCase files |
623
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
25 |
if pre_060: |
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
26 |
import VirtualMailManager |
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
27 |
vmm_inst_dir = os.path.dirname(VirtualMailManager.__file__) |
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
28 |
tmp_info = open('/tmp/vmm_inst_dir', 'w') |
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
29 |
tmp_info.write(vmm_inst_dir) |
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
30 |
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
|
31 |
|
436
d296a020f440
update_config: Set database.module to pyPgSQL only when psycopg2
Pascal Volk <neverseen@users.sourceforge.net>
parents:
366
diff
changeset
|
32 |
try: |
d296a020f440
update_config: Set database.module to pyPgSQL only when psycopg2
Pascal Volk <neverseen@users.sourceforge.net>
parents:
366
diff
changeset
|
33 |
import psycopg2 |
d296a020f440
update_config: Set database.module to pyPgSQL only when psycopg2
Pascal Volk <neverseen@users.sourceforge.net>
parents:
366
diff
changeset
|
34 |
except ImportError: |
d296a020f440
update_config: Set database.module to pyPgSQL only when psycopg2
Pascal Volk <neverseen@users.sourceforge.net>
parents:
366
diff
changeset
|
35 |
has_psycopg2 = False |
d296a020f440
update_config: Set database.module to pyPgSQL only when psycopg2
Pascal Volk <neverseen@users.sourceforge.net>
parents:
366
diff
changeset
|
36 |
else: |
d296a020f440
update_config: Set database.module to pyPgSQL only when psycopg2
Pascal Volk <neverseen@users.sourceforge.net>
parents:
366
diff
changeset
|
37 |
has_psycopg2 = True |
118
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
38 |
|
623
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
39 |
|
118
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
40 |
def get_config_file(): |
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
41 |
f = None |
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
42 |
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
|
43 |
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
|
44 |
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
|
45 |
f = tmp |
118
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
46 |
break |
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
47 |
if f: |
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
48 |
return f |
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
49 |
else: |
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
50 |
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
|
51 |
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
|
52 |
|
623
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
53 |
|
118
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
54 |
def update(cp): |
167
bb58aedefa3a
update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
162
diff
changeset
|
55 |
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
|
56 |
upd_052(cp) |
bb58aedefa3a
update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
162
diff
changeset
|
57 |
elif VERSION == '0.6.0': |
623
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
58 |
os.sys.stdout.write('info: vmm.cfg: nothing to do for version %s\n' % |
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
59 |
VERSION) |
167
bb58aedefa3a
update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
162
diff
changeset
|
60 |
return |
118
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
61 |
else: |
623
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
62 |
os.sys.stderr.write('error: the version %s is not supported by this ' |
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
63 |
'script\n' % VERSION) |
167
bb58aedefa3a
update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
162
diff
changeset
|
64 |
raise SystemExit(3) |
118
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
65 |
|
623
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
66 |
|
118
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
67 |
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
|
68 |
fh = open(cf, 'r') |
118
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
69 |
cp = ConfigParser() |
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
70 |
cp.readfp(fh) |
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
71 |
fh.close() |
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
72 |
return cp |
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
73 |
|
623
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
74 |
|
118
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
75 |
def update_cfg_file(cp, cf): |
623
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
76 |
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
|
77 |
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
|
78 |
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
|
79 |
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
|
80 |
|
623
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
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 add_sections(cp, sections): |
bb58aedefa3a
update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
162
diff
changeset
|
83 |
for section in sections: |
bb58aedefa3a
update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
162
diff
changeset
|
84 |
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
|
85 |
cp.add_section(section) |
bb58aedefa3a
update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
162
diff
changeset
|
86 |
|
623
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
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 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
|
89 |
ds, do = dst.split('.') |
bb58aedefa3a
update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
162
diff
changeset
|
90 |
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
|
91 |
ss, so = src.split('.') |
bb58aedefa3a
update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
162
diff
changeset
|
92 |
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
|
93 |
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
|
94 |
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
|
95 |
|
623
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
96 |
|
167
bb58aedefa3a
update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
162
diff
changeset
|
97 |
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
|
98 |
ds, do = dst.split('.') |
bb58aedefa3a
update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
162
diff
changeset
|
99 |
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
|
100 |
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
|
101 |
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
|
102 |
|
264
04fea4d8b900
Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents:
229
diff
changeset
|
103 |
|
04fea4d8b900
Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents:
229
diff
changeset
|
104 |
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
|
105 |
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
|
106 |
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
|
107 |
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
|
108 |
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
|
109 |
else: |
04fea4d8b900
Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents:
229
diff
changeset
|
110 |
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
|
111 |
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
|
112 |
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
|
113 |
|
04fea4d8b900
Use the complete Dovecot version, not only the concatenated major
Pascal Volk <neverseen@users.sourceforge.net>
parents:
229
diff
changeset
|
114 |
|
167
bb58aedefa3a
update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
162
diff
changeset
|
115 |
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
|
116 |
ss, so = src.split('.') |
bb58aedefa3a
update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
162
diff
changeset
|
117 |
return cp.get(ss, so) |
118
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
118 |
|
623
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
119 |
|
167
bb58aedefa3a
update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
162
diff
changeset
|
120 |
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
|
121 |
global had_config |
270
d3389645a91d
configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
264
diff
changeset
|
122 |
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
|
123 |
|
866a6d679fce
update_config: do not add options w/ default values.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
168
diff
changeset
|
124 |
had_config = cp.remove_section('config') |
270
d3389645a91d
configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
264
diff
changeset
|
125 |
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
|
126 |
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
|
127 |
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
|
128 |
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
|
129 |
('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
|
130 |
('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
|
131 |
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
|
132 |
cp.remove_section('domdir') |
bb58aedefa3a
update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
162
diff
changeset
|
133 |
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
|
134 |
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
|
135 |
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
|
136 |
cp.remove_section('services') |
bb58aedefa3a
update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
162
diff
changeset
|
137 |
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
|
138 |
('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
|
139 |
('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
|
140 |
('maildir.folders', 'mailbox.folders'), |
298
ee89399346cb
VMM/Config: Added mailbox.root setting.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
270
diff
changeset
|
141 |
('maildir.name', 'mailbox.root'), |
168
fd496561acc6
vmm.cfg: a few re-renamed configuration options.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
167
diff
changeset
|
142 |
('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
|
143 |
('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
|
144 |
('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
|
145 |
('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
|
146 |
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
|
147 |
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
|
148 |
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
|
149 |
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
|
150 |
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
|
151 |
|
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
|
152 |
|
118
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
153 |
# def main(): |
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
154 |
if __name__ == '__main__': |
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
155 |
sect_opt = [] |
181
866a6d679fce
update_config: do not add options w/ default values.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
168
diff
changeset
|
156 |
had_config = False |
270
d3389645a91d
configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
264
diff
changeset
|
157 |
had_gid_mail = False |
118
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
158 |
cf = get_config_file() |
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
159 |
cp = get_cfg_parser(cf) |
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
160 |
update(cp) |
167
bb58aedefa3a
update_config.py: adjusted functions stuff to renamed settings.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
162
diff
changeset
|
161 |
if len(sect_opt): |
118
cf85d78486ce
Rewrote upgrade script and config update script
Pascal Volk <neverseen@users.sourceforge.net>
parents:
104
diff
changeset
|
162 |
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
|
163 |
sect_opt.sort() |
623
d7101e496795
update_config: Updated to work with version 0.6.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
164 |
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
|
165 |
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
|
166 |
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
|
167 |
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
|
168 |
if had_config: |
d3389645a91d
configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
264
diff
changeset
|
169 |
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
|
170 |
if had_gid_mail: |
d3389645a91d
configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
264
diff
changeset
|
171 |
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
|
172 |
os.sys.exit(0) |
d3389645a91d
configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
264
diff
changeset
|
173 |
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
|
174 |
update_cfg_file(cp, cf) |
270
d3389645a91d
configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
264
diff
changeset
|
175 |
if had_config: |
d3389645a91d
configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
264
diff
changeset
|
176 |
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
|
177 |
if had_gid_mail: |
d3389645a91d
configuration: Dropped setting misc.gid_mail.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
264
diff
changeset
|
178 |
print '\nRemoved option "gid_mail" from section "misc" (obsolte)\n' |