#!/usr/bin/env python3 # -*- coding: utf-8 -*- import utils def setup(interactive=True): dir_path = utils.get_dir(__file__) cmds = [ 'DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server mysql-client', 'cp "%s/mysql.cnf" "/etc/mysql/mysql.cnf"' % dir_path, '[ -L /etc/mysql/my.cnf ] || (mv /etc/mysql/my.cnf /etc/mysql/my.cnf.back && ln -sfn /etc/mysql/mysql.cnf /etc/mysql/my.cnf)', # Compatibility with mysql 5.5 'mkdir -p /etc/systemd/system/mysql.service.d', 'cp "%s/override.conf" "/etc/systemd/system/mysql.service.d/override.conf"' % dir_path, '/etc/init.d/mysql restart', ] MYSQL_ROOT_PWD = utils.get_conf('MYSQL_ROOT_PWD') if MYSQL_ROOT_PWD: # Set password if any cmds.append('mysqladmin -u root password "%s"' % MYSQL_ROOT_PWD) utils.run_commands(cmds) if not MYSQL_ROOT_PWD: utils.log('No root password was set in the configuration file.\nUse the following command to change it:\n mysqladmin -u root password <pwd>')