Branch 'pykolab-0.6' - pykolab/setup

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Sat Nov 30 15:13:46 CET 2013


 pykolab/setup/setup_roundcube.py |   37 ++++++++++++++++++++++++++++++++-----
 pykolab/setup/setup_syncroton.py |   37 ++++++++++++++++++++++++++++++++-----
 2 files changed, 64 insertions(+), 10 deletions(-)

New commits:
commit b57019da82bd2a9ff972a1ee979e064c1b785136
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Sat Nov 30 15:12:51 2013 +0100

    See if /tmp/kolab-setup-my.cnf exists for the setup of roundcube and syncroton databases

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)




More information about the commits mailing list