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