# HG changeset patch # User Pascal Volk # Date 1265054262 0 # Node ID 866a6d679fce7e600ba3fa056afc20da9f436716 # Parent f8279c90e99c34e53583b2b6a3c50723d09f75d0 update_config: do not add options w/ default values. remove config.done diff -r f8279c90e99c -r 866a6d679fce update_config.py --- 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 -