Changeset View
Changeset View
Standalone View
Standalone View
pykolab/setup/setup_mysql.py
Show All 11 Lines | |||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
# GNU General Public License for more details. | # GNU General Public License for more details. | ||||
# You should have received a copy of the GNU General Public License | # You should have received a copy of the GNU General Public License | ||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
# | # | ||||
from __future__ import print_function | |||||
import os | import os | ||||
import subprocess | import subprocess | ||||
import tempfile | import tempfile | ||||
import time | import time | ||||
import components | import components | ||||
import pykolab | import pykolab | ||||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | if conf.mysqlserver != 'existing': | ||||
answer = 3 | answer = 3 | ||||
if answer == 0: | if answer == 0: | ||||
answer = utils.ask_menu(_("What MySQL server are we setting up?"), options) | answer = utils.ask_menu(_("What MySQL server are we setting up?"), options) | ||||
else: | else: | ||||
answer = 1 | answer = 1 | ||||
if answer == "1" or answer == 1: | if answer == "1" or answer == 1: | ||||
if not conf.mysqlrootpw: | if not conf.mysqlrootpw: | ||||
print >> sys.stderr, utils.multiline_message( | print(utils.multiline_message( | ||||
_(""" | _(""" | ||||
Please supply the root password for MySQL, so we can set | Please supply the root password for MySQL, so we can set | ||||
up user accounts for other components that use MySQL. | up user accounts for other components that use MySQL. | ||||
""") | """) | ||||
) | ), file=sys.stderr) | ||||
mysql_root_password = utils.ask_question( | mysql_root_password = utils.ask_question( | ||||
_("MySQL root password"), | _("MySQL root password"), | ||||
password=True | password=True | ||||
) | ) | ||||
else: | else: | ||||
mysql_root_password = conf.mysqlrootpw | mysql_root_password = conf.mysqlrootpw | ||||
elif answer == "2" or answer == 2: | elif answer == "2" or answer == 2: | ||||
mysql_root_password = 'unix_socket' | mysql_root_password = 'unix_socket' | ||||
else: | else: | ||||
print >> sys.stderr, utils.multiline_message( | print(utils.multiline_message( | ||||
_(""" | _(""" | ||||
Please supply a root password for MySQL. This password | Please supply a root password for MySQL. This password | ||||
will be the administrative user for this MySQL server, | will be the administrative user for this MySQL server, | ||||
and it should be kept a secret. After this setup process | and it should be kept a secret. After this setup process | ||||
has completed, Kolab is going to discard and forget | has completed, Kolab is going to discard and forget | ||||
about this password, but you will need it for | about this password, but you will need it for | ||||
administrative tasks in MySQL. | administrative tasks in MySQL. | ||||
""") | """) | ||||
) | ), file=sys.stderr) | ||||
mysql_root_password = utils.ask_question( | mysql_root_password = utils.ask_question( | ||||
_("MySQL root password"), | _("MySQL root password"), | ||||
default=utils.generate_password(), | default=utils.generate_password(), | ||||
password=True, | password=True, | ||||
confirm=True | confirm=True | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | for root, directories, filenames in os.walk('/usr/share/doc/'): | ||||
schema_file = os.path.join(root, filename) | schema_file = os.path.join(root, filename) | ||||
if schema_file is not None: | if schema_file is not None: | ||||
p1 = subprocess.Popen(['echo', 'create database kolab;'], stdout=subprocess.PIPE) | p1 = subprocess.Popen(['echo', 'create database kolab;'], stdout=subprocess.PIPE) | ||||
p2 = subprocess.Popen(['mysql', '--defaults-file=/tmp/kolab-setup-my.cnf'], stdin=p1.stdout) | p2 = subprocess.Popen(['mysql', '--defaults-file=/tmp/kolab-setup-my.cnf'], stdin=p1.stdout) | ||||
p1.stdout.close() | p1.stdout.close() | ||||
p2.communicate() | p2.communicate() | ||||
print >> sys.stderr, utils.multiline_message( | print(utils.multiline_message( | ||||
_(""" | _(""" | ||||
Please supply a password for the MySQL user 'kolab'. | Please supply a password for the MySQL user 'kolab'. | ||||
This password will be used by Kolab services, such as | This password will be used by Kolab services, such as | ||||
the Web Administration Panel. | the Web Administration Panel. | ||||
""") | """) | ||||
) | ), file=sys.stderr) | ||||
mysql_kolab_password = utils.ask_question( | mysql_kolab_password = utils.ask_question( | ||||
_("MySQL kolab password"), | _("MySQL kolab password"), | ||||
default=utils.generate_password(), | default=utils.generate_password(), | ||||
password=True, | password=True, | ||||
confirm=True | confirm=True | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines |