update_config_0.4.x-0.5.py
author Pascal Volk <neverseen@users.sourceforge.net>
Tue, 07 Oct 2008 02:18:45 +0000
changeset 91 0e5b2835414d
parent 86 e43e4e7e9ec0
permissions -rwxr-xr-x
* 'INSTALL' - Added a configuration hint for smtpd_sasl_local_domain
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
68
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     1
#!/usr/bin/env python
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     2
# -*- coding: UTF-8 -*-
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     3
# Copyright 2008 VEB IT
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     4
# See COPYING for distribution information.
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     5
# $Id$
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     6
86
e43e4e7e9ec0 * 'VirtualMailManager/ext/Postconf.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 68
diff changeset
     7
import sys
68
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     8
from ConfigParser import ConfigParser
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     9
from shutil import copy2
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    10
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    11
cf = '/usr/local/etc/vmm.cfg'
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    12
fh = file(cf, 'r')
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    13
cp = ConfigParser()
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    14
cp.readfp(fh)
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    15
fh.close()
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    16
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    17
if not cp.has_option('maildir', 'name') or not cp.has_option('maildir',
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    18
        'folders') or cp.has_option('maildir', 'folder'):
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    19
    copy2(cf, cf+'.bak_upd_0.4.x-0.5')
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    20
    fh = file(cf, 'w')
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    21
    if not cp.has_option('maildir', 'name'):
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    22
        if cp.has_option('maildir', 'folder'):
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    23
            cp.set('maildir', 'name', cp.get('maildir', 'folder'))
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    24
            cp.remove_option('maildir', 'folder')
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    25
        else:
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    26
            cp.set('maildir', 'name', 'Maildir')
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    27
    if not cp.has_option('maildir', 'folders'):
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    28
        cp.set('maildir', 'folders', 'Drafts:Sent:Templates:Trash')
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    29
    if cp.has_option('maildir', 'folder'):
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    30
        cp.remove_option('maildir', 'folder')
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    31
    cp.write(fh)
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    32
    fh.close()
86
e43e4e7e9ec0 * 'VirtualMailManager/ext/Postconf.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 68
diff changeset
    33
e43e4e7e9ec0 * 'VirtualMailManager/ext/Postconf.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 68
diff changeset
    34
if not cp.has_option('bin', 'postconf'):
e43e4e7e9ec0 * 'VirtualMailManager/ext/Postconf.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 68
diff changeset
    35
    fh = file(cf, 'w')
e43e4e7e9ec0 * 'VirtualMailManager/ext/Postconf.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 68
diff changeset
    36
    try:
e43e4e7e9ec0 * 'VirtualMailManager/ext/Postconf.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 68
diff changeset
    37
        postconf = sys.argv[1].strip()
e43e4e7e9ec0 * 'VirtualMailManager/ext/Postconf.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 68
diff changeset
    38
        if len(postconf):
e43e4e7e9ec0 * 'VirtualMailManager/ext/Postconf.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 68
diff changeset
    39
            cp.set('bin', 'postconf', postconf)
e43e4e7e9ec0 * 'VirtualMailManager/ext/Postconf.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 68
diff changeset
    40
        else: # possible?
e43e4e7e9ec0 * 'VirtualMailManager/ext/Postconf.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 68
diff changeset
    41
            cp.set('bin', 'postconf', '/usr/sbin/postconf')
e43e4e7e9ec0 * 'VirtualMailManager/ext/Postconf.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 68
diff changeset
    42
    except IndexError:
e43e4e7e9ec0 * 'VirtualMailManager/ext/Postconf.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 68
diff changeset
    43
        cp.set('bin', 'postconf', '/usr/sbin/postconf')
e43e4e7e9ec0 * 'VirtualMailManager/ext/Postconf.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 68
diff changeset
    44
    cp.write(fh)
e43e4e7e9ec0 * 'VirtualMailManager/ext/Postconf.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 68
diff changeset
    45
    fh.close()
e43e4e7e9ec0 * 'VirtualMailManager/ext/Postconf.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 68
diff changeset
    46
    print
e43e4e7e9ec0 * 'VirtualMailManager/ext/Postconf.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 68
diff changeset
    47
    print "Please have a look at your %s" %cf
e43e4e7e9ec0 * 'VirtualMailManager/ext/Postconf.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 68
diff changeset
    48
    print "and verify the value from option 'postconf' in section 'bin'."
e43e4e7e9ec0 * 'VirtualMailManager/ext/Postconf.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 68
diff changeset
    49
    print
e43e4e7e9ec0 * 'VirtualMailManager/ext/Postconf.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 68
diff changeset
    50