update_config.py
branchv0.6.x
changeset 181 866a6d679fce
parent 168 fd496561acc6
child 229 0fb2f12648a7
--- a/update_config.py	Mon Feb 01 18:46:17 2010 +0000
+++ b/update_config.py	Mon Feb 01 19:57:42 2010 +0000
@@ -36,7 +36,7 @@
         raise SystemExit(3)
 
 def get_cfg_parser(cf):
-    fh = file(cf, 'r')
+    fh = open(cf, 'r')
     cp = ConfigParser()
     cp.readfp(fh)
     fh.close()
@@ -44,7 +44,7 @@
 
 def update_cfg_file(cp, cf):
     copy2(cf, cf+'.bak.'+str(time()))
-    fh = file(cf, 'w')
+    fh = open(cf, 'w')
     cp.write(fh)
     fh.close()
 
@@ -72,6 +72,9 @@
     return cp.get(ss, so)
 
 def upd_052(cp):
+    global had_config
+
+    had_config = cp.remove_section('config')
     add_sections(cp, ('domain', 'account'))
     if cp.has_section('domdir'):
         for src, dst in (('domdir.mode',   'domain.directory_mode'),
@@ -90,23 +93,23 @@
                      ('misc.passwdscheme', 'misc.password_scheme'),
                      ('misc.dovecotvers',  'misc.dovecot_version')):
         move_option(cp, src, dst)
-    for dst, val in (('account.random_password', 'false'),
-                     ('account.password_length', '8'),
-                     ('domain.auto_postmaster',  'true')):
-        add_option(cp, dst, val)
 
 # def main():
 if __name__ == '__main__':
     sect_opt = []
+    had_config = False
     cf = get_config_file()
     cp = get_cfg_parser(cf)
     update(cp)
     if len(sect_opt):
+        had_config = False
         update_cfg_file(cp, cf)
         sect_opt.sort()
         print 'Please have a look at your configuration: %s' %cf
         print 'This are your Renamed/New settings:'
         for s_o, st in sect_opt:
             print '%s   %s = %s' % (st, s_o, get_option(cp, s_o))
+    if had_config:
+        update_cfg_file(cp, cf)
+        print 'Removed section "config" with option "done" (obsolte)'
         print
-