diff options
author | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2013-11-30 15:12:51 +0100 |
---|---|---|
committer | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2013-11-30 15:12:51 +0100 |
commit | 345c2d5e0950f433ffc83c590f0bdeb672b1a617 (patch) | |
tree | 006ff1e0c505ecc7d9224b4f7401a7ca6ec3f73e | |
parent | 98a10773fecb7db035158fdb3ec3690362eb4a16 (diff) | |
download | pykolab-345c2d5e0950f433ffc83c590f0bdeb672b1a617.tar.gz |
See if /tmp/kolab-setup-my.cnf exists for the setup of roundcube and syncroton databases
-rw-r--r-- | pykolab/setup/setup_roundcube.py | 37 | ||||
-rw-r--r-- | pykolab/setup/setup_syncroton.py | 37 |
2 files changed, 64 insertions, 10 deletions
diff --git a/pykolab/setup/setup_roundcube.py b/pykolab/setup/setup_roundcube.py index b53a314..215da69 100644 --- a/pykolab/setup/setup_roundcube.py +++ b/pykolab/setup/setup_roundcube.py @@ -136,11 +136,17 @@ def execute(*args, **kw): schema_files = [] for root, directories, filenames in os.walk('/usr/share/doc/'): - for filename in filenames: - if filename.startswith('mysql.initial') and filename.endswith('.sql'): - schema_filepath = os.path.join(root,filename) - if not schema_filepath in schema_files: - schema_files.append(schema_filepath) + for directory in directories: + if directory.startswith("roundcubemail"): + for root, directories, filenames in os.walk(os.path.join('/usr/share/doc/', directory)): + for filename in filenames: + if filename.startswith('mysql.initial') and filename.endswith('.sql'): + schema_filepath = os.path.join(root,filename) + if not schema_filepath in schema_files: + schema_files.append(schema_filepath) + + break + break if os.path.isdir('/usr/share/roundcubemail'): rcpath = '/usr/share/roundcubemail/' @@ -164,6 +170,27 @@ def execute(*args, **kw): if not schema_filepath in schema_files: schema_files.append(schema_filepath) + if not os.path.isfile('/tmp/kolab-setup-my.cnf'): + utils.multiline_message( + """Please supply the MySQL root password""" + ) + + mysql_root_password = utils.ask_question( + _("MySQL root password"), + password=True + ) + + data = """ +[mysql] +user=root +password='%s' +""" % (mysql_root_password) + + fp = open('/tmp/kolab-setup-my.cnf', 'w') + os.chmod('/tmp/kolab-setup-my.cnf', 0600) + fp.write(data) + fp.close() + p1 = subprocess.Popen(['echo', 'create database roundcube;'], stdout=subprocess.PIPE) p2 = subprocess.Popen(['mysql', '--defaults-file=/tmp/kolab-setup-my.cnf'], stdin=p1.stdout) p1.stdout.close() diff --git a/pykolab/setup/setup_syncroton.py b/pykolab/setup/setup_syncroton.py index 0722882..ce7099d 100644 --- a/pykolab/setup/setup_syncroton.py +++ b/pykolab/setup/setup_syncroton.py @@ -42,11 +42,38 @@ def description(): def execute(*args, **kw): schema_files = [] for root, directories, filenames in os.walk('/usr/share/doc/'): - for filename in filenames: - if filename.startswith('mysql.initial') and filename.endswith('.sql'): - schema_filepath = os.path.join(root,filename) - if not schema_filepath in schema_files: - schema_files.append(schema_filepath) + for directory in directories: + if directory.startswith("kolab-syncroton"): + for root, directories, filenames in os.walk(os.path.join('/usr/share/doc/', directory)): + for filename in filenames: + if filename.startswith('mysql.initial') and filename.endswith('.sql'): + schema_filepath = os.path.join(root,filename) + if not schema_filepath in schema_files: + schema_files.append(schema_filepath) + + break + break + + if not os.path.isfile('/tmp/kolab-setup-my.cnf'): + utils.multiline_message( + """Please supply the MySQL root password""" + ) + + mysql_root_password = utils.ask_question( + _("MySQL root password"), + password=True + ) + + data = """ +[mysql] +user=root +password='%s' +""" % (mysql_root_password) + + fp = open('/tmp/kolab-setup-my.cnf', 'w') + os.chmod('/tmp/kolab-setup-my.cnf', 0600) + fp.write(data) + fp.close() for schema_file in schema_files: p1 = subprocess.Popen(['cat', schema_file], stdout=subprocess.PIPE) |