update_config.py: adjusted functions stuff to renamed settings.
Finally renamed update_config_0.4.x-0.5.py to update_config.py - no more
version information in the filename.
*.sh: removed .svn directory exclusion from find command.
--- a/install.sh Wed Jan 13 00:08:44 2010 +0000
+++ b/install.sh Wed Jan 13 00:55:50 2010 +0000
@@ -50,7 +50,7 @@
[ -d ${MANDIR}/man5 ] || mkdir -m 0755 -p ${MANDIR}/man5
install -m 0644 ${INSTALL_OPTS} man5/vmm.cfg.5 ${MANDIR}/man5
-for l in $(find . -maxdepth 1 -mindepth 1 -type d \! -name man\? \! -name .svn)
+for l in $(find . -maxdepth 1 -mindepth 1 -type d \! -name man\?)
do
for s in man1 man5; do
[ -d ${MANDIR}/${l}/${s} ] || mkdir -m 0755 -p ${MANDIR}/${l}/${s}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/update_config.py Wed Jan 13 00:55:50 2010 +0000
@@ -0,0 +1,112 @@
+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2008 - 2010, Pascal Volk
+# See COPYING for distribution information.
+
+import os
+os.sys.path.remove(os.sys.path[0])
+from time import time
+from ConfigParser import ConfigParser
+from shutil import copy2
+from VirtualMailManager.constants.VERSION import VERSION
+
+
+def get_config_file():
+ f = None
+ for d in ('/root', '/usr/local/etc', '/etc'):
+ tmp = os.path.join(d, 'vmm.cfg')
+ if os.path.isfile(tmp):
+ f = tmp
+ break
+ if f:
+ return f
+ else:
+ os.sys.stderr.write('error: vmm.cfg not found\n')
+ raise SystemExit(2)
+
+def update(cp):
+ if VERSION == '0.5.2':
+ upd_052(cp)
+ elif VERSION == '0.6.0':
+ os.sys.stdout.write('info: nothing to do for version %s\n' % VERSION)
+ return
+ else:
+ os.sys.stderr.write(
+ 'error: the version %s is not supported by this script\n' % VERSION)
+ raise SystemExit(3)
+
+def get_cfg_parser(cf):
+ fh = file(cf, 'r')
+ cp = ConfigParser()
+ cp.readfp(fh)
+ fh.close()
+ return cp
+
+def update_cfg_file(cp, cf):
+ copy2(cf, cf+'.bak.'+str(time()))
+ fh = file(cf, 'w')
+ cp.write(fh)
+ fh.close()
+
+def add_sections(cp, sections):
+ for section in sections:
+ if not cp.has_section(section):
+ cp.add_section(section)
+
+def move_option(cp, src, dst):
+ ds, do = dst.split('.')
+ if not cp.has_option(ds, do):
+ ss, so = src.split('.')
+ cp.set(ds, do, cp.get(ss, so))
+ cp.remove_option(ss, so)
+ sect_opt.append((dst, 'R'))
+
+def add_option(cp, dst, val):
+ ds, do = dst.split('.')
+ if not cp.has_option(ds, do):
+ cp.set(ds, do, val)
+ sect_opt.append((dst, 'N'))
+
+def get_option(cp, src):
+ ss, so = src.split('.')
+ return cp.get(ss, so)
+
+def upd_052(cp):
+ add_sections(cp, ('domain', 'account'))
+ if cp.has_section('domdir'):
+ for src, dst in (('domdir.mode', 'domain.directory_mode'),
+ ('domdir.delete', 'domain.delete_directory'),
+ ('domdir.base', 'misc.base_dir')):
+ move_option(cp, src, dst)
+ cp.remove_section('domdir')
+ if cp.has_section('services'):
+ for service in cp.options('services'):
+ move_option(cp, 'services.%s'%service, 'account.%s'%service)
+ cp.remove_section('services')
+ for src, dst in (('maildir.mode', 'account.directory_mode'),
+ ('maildir.diskusage', 'account.disk_usage'),
+ ('maildir.delete', 'account.delete_directory'),
+ ('misc.forcedel', 'domain.force_del'),
+ ('misc.passwdscheme', 'misc.password_scheme'),
+ ('misc.dovecotvers', 'misc.dovecot_vers')):
+ move_option(cp, src, dst)
+ for dst, val in (('account.random_password', 'false'),
+ ('account.password_len', '8'),
+ ('domain.auto_postmaster', 'true')):
+ add_option(cp, dst, val)
+
+# def main():
+if __name__ == '__main__':
+ sect_opt = []
+ cf = get_config_file()
+ cp = get_cfg_parser(cf)
+ update(cp)
+ if len(sect_opt):
+ 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))
+ print
+
--- a/update_config_0.4.x-0.5.py Wed Jan 13 00:08:44 2010 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: UTF-8 -*-
-# Copyright (c) 2008 - 2010, Pascal Volk
-# See COPYING for distribution information.
-
-import os
-os.sys.path.remove(os.sys.path[0])
-from time import time
-from ConfigParser import ConfigParser
-from shutil import copy2
-from VirtualMailManager.constants.VERSION import VERSION
-
-
-def get_config_file():
- f = None
- for d in ('/root', '/usr/local/etc', '/etc'):
- tmp = os.path.join(d, 'vmm.cfg')
- if os.path.isfile(tmp):
- f = tmp
- break
- if f:
- return f
- else:
- os.sys.stderr.write('error: vmm.cfg not found\n')
- os.sys.exit(2)
-
-def update(cp):
- if VERSION == '0.4':
- upd_040(cp)
- elif VERSION == '0.5':
- upd_050(cp)
- elif VERSION == '0.5.1':
- upd_051(cp)
- elif VERSION == '0.5.2':
- os.sys.stdout.write('info: nothing to do for version %s\n' % VERSION)
- os.sys.exit(0)
- else:
- os.sys.stderr.write(
- 'error: the version %s is not supported by this script\n' % VERSION)
- os.sys.exit(3)
-
-def get_cfg_parser(cf):
- fh = file(cf, 'r')
- cp = ConfigParser()
- cp.readfp(fh)
- fh.close()
- return cp
-
-def update_cfg_file(cp, cf):
- copy2(cf, cf+'.bak.'+str(time()))
- fh = file(cf, 'w')
- cp.write(fh)
- fh.close()
-
-def upd_040(cp):
- if not cp.has_option('maildir', 'name') or not cp.has_option('maildir',
- 'folders') or cp.has_option('maildir', 'folder'):
- if not cp.has_option('maildir', 'name'):
- if cp.has_option('maildir', 'folder'):
- cp.set('maildir', 'name', cp.get('maildir', 'folder'))
- cp.remove_option('maildir', 'folder')
- sect_opt.append(('maildir', 'name'))
- else:
- cp.set('maildir', 'name', 'Maildir')
- sect_opt.append(('maildir', 'name'))
- if not cp.has_option('maildir', 'folders'):
- cp.set('maildir', 'folders', 'Drafts:Sent:Templates:Trash')
- sect_opt.append(('maildir', 'folders'))
- if cp.has_option('maildir', 'folder'):
- cp.remove_option('maildir', 'folder')
- upd_050(cp)
-
-def upd_050(cp):
- if not cp.has_option('bin', 'postconf'):
- try:
- postconf = os.sys.argv[1].strip()
- if len(postconf):
- cp.set('bin', 'postconf', postconf)
- sect_opt.append(('bin', 'postconf'))
- else: # possible?
- cp.set('bin', 'postconf', '/usr/sbin/postconf')
- sect_opt.append(('bin', 'postconf'))
- except IndexError:
- cp.set('bin', 'postconf', '/usr/sbin/postconf')
- sect_opt.append(('bin', 'postconf'))
- upd_051(cp)
-
-def upd_051(cp):
- if not cp.has_option('misc', 'dovecotvers') or cp.has_option('services',
- 'managesieve'):
- if not cp.has_option('misc', 'dovecotvers'):
- cp.set('misc', 'dovecotvers', os.sys.argv[2].strip())
- sect_opt.append(('misc', 'dovecotvers'))
- if cp.has_option('services', 'managesieve'):
- cp.set('services','sieve',cp.getboolean('services', 'managesieve'))
- cp.remove_option('services', 'managesieve')
- sect_opt.append(('services', 'sieve'))
-
-# def main():
-if __name__ == '__main__':
- sect_opt = []
- cf = get_config_file()
- cp = get_cfg_parser(cf)
- update(cp)
- if len(sect_opt):
- update_cfg_file(cp, cf)
- print 'Please have a look at your configuration: %s' %cf
- print 'and verify the value from:'
- for s_o in sect_opt:
- print ' [%s] %s' % s_o
- print
-
-
--- a/upgrade.sh Wed Jan 13 00:08:44 2010 +0000
+++ b/upgrade.sh Wed Jan 13 00:55:50 2010 +0000
@@ -29,7 +29,7 @@
fi
# update config file before installing the new files.
-./update_config_0.4.x-0.5.py ${POSTCONF} ${DOVECOT_VERS:-10}
+./update_config.py
rv=$?
if [ $rv -eq 2 ]; then
echo "please run the install.sh script"
@@ -66,7 +66,7 @@
[ -d ${MANDIR}/man5 ] || mkdir -m 0755 -p ${MANDIR}/man5
install -m 0644 ${INSTALL_OPTS} man5/vmm.cfg.5 ${MANDIR}/man5
-for l in $(find . -maxdepth 1 -mindepth 1 -type d \! -name man\? \! -name .svn)
+for l in $(find . -maxdepth 1 -mindepth 1 -type d \! -name man\?)
do
for s in man1 man5; do
[ -d ${MANDIR}/${l}/${s} ] || mkdir -m 0755 -p ${MANDIR}/${l}/${s}