|
1 #!/usr/bin/env python |
|
2 # -*- coding: UTF-8 -*- |
|
3 # Copyright (c) 2008 - 2009, VEB IT |
|
4 # See COPYING for distribution information. |
|
5 |
|
6 import sys |
|
7 from ConfigParser import ConfigParser |
|
8 from shutil import copy2 |
|
9 |
|
10 cf = '/usr/local/etc/vmm.cfg' |
|
11 fh = file(cf, 'r') |
|
12 cp = ConfigParser() |
|
13 cp.readfp(fh) |
|
14 fh.close() |
|
15 |
|
16 if not cp.has_option('maildir', 'name') or not cp.has_option('maildir', |
|
17 'folders') or cp.has_option('maildir', 'folder'): |
|
18 copy2(cf, cf+'.bak_upd_0.4.x-0.5') |
|
19 fh = file(cf, 'w') |
|
20 if not cp.has_option('maildir', 'name'): |
|
21 if cp.has_option('maildir', 'folder'): |
|
22 cp.set('maildir', 'name', cp.get('maildir', 'folder')) |
|
23 cp.remove_option('maildir', 'folder') |
|
24 else: |
|
25 cp.set('maildir', 'name', 'Maildir') |
|
26 if not cp.has_option('maildir', 'folders'): |
|
27 cp.set('maildir', 'folders', 'Drafts:Sent:Templates:Trash') |
|
28 if cp.has_option('maildir', 'folder'): |
|
29 cp.remove_option('maildir', 'folder') |
|
30 cp.write(fh) |
|
31 fh.close() |
|
32 |
|
33 if not cp.has_option('bin', 'postconf'): |
|
34 fh = file(cf, 'w') |
|
35 try: |
|
36 postconf = sys.argv[1].strip() |
|
37 if len(postconf): |
|
38 cp.set('bin', 'postconf', postconf) |
|
39 else: # possible? |
|
40 cp.set('bin', 'postconf', '/usr/sbin/postconf') |
|
41 except IndexError: |
|
42 cp.set('bin', 'postconf', '/usr/sbin/postconf') |
|
43 cp.write(fh) |
|
44 fh.close() |
|
45 print |
|
46 print "Please have a look at your %s" %cf |
|
47 print "and verify the value from option 'postconf' in section 'bin'." |
|
48 print |
|
49 |