Add --mysqlclient and cleanup code
This commit is contained in:
@@ -63,6 +63,9 @@ class WOStackController(CementBaseController):
|
||||
dict(help='Install PHP 7.3 stack', action='store_true')),
|
||||
(['--mysql'],
|
||||
dict(help='Install MySQL stack', action='store_true')),
|
||||
(['--mysqlclient'],
|
||||
dict(help='Install MySQL client for remote MySQL server',
|
||||
action='store_true')),
|
||||
(['--wpcli'],
|
||||
dict(help='Install WPCLI stack', action='store_true')),
|
||||
(['--phpmyadmin'],
|
||||
@@ -107,12 +110,10 @@ class WOStackController(CementBaseController):
|
||||
if ((not pargs.web) and (not pargs.admin) and
|
||||
(not pargs.nginx) and (not pargs.php) and
|
||||
(not pargs.mysql) and (not pargs.wpcli) and
|
||||
(not pargs.phpmyadmin) and
|
||||
(not pargs.composer) and
|
||||
(not pargs.netdata) and
|
||||
(not pargs.dashboard) and
|
||||
(not pargs.fail2ban) and
|
||||
(not pargs.security) and
|
||||
(not pargs.phpmyadmin) and (not pargs.composer) and
|
||||
(not pargs.netdata) and (not pargs.dashboard) and
|
||||
(not pargs.fail2ban) and (not pargs.security)
|
||||
and (not pargs.mysqlclient) and
|
||||
(not pargs.adminer) and (not pargs.utils) and
|
||||
(not pargs.redis) and (not pargs.proftpd) and
|
||||
(not pargs.phpredisadmin) and
|
||||
@@ -218,9 +219,10 @@ class WOStackController(CementBaseController):
|
||||
"/usr/bin/mysqltuner",
|
||||
"MySQLTuner"]]
|
||||
|
||||
else:
|
||||
Log.debug(self, "MySQL connection is already alive")
|
||||
Log.info(self, "MySQL connection is already alive")
|
||||
if pargs.mysqlclient:
|
||||
Log.debug(self, "Setting apt_packages variable "
|
||||
"for MySQL Client")
|
||||
apt_packages = apt_packages + WOVariables.wo_mysql_client
|
||||
|
||||
# WP-CLI
|
||||
if pargs.wpcli:
|
||||
|
||||
@@ -25,7 +25,8 @@ from wo.core.variables import WOVariables
|
||||
def pre_pref(self, apt_packages):
|
||||
"""Pre settings to do before installation packages"""
|
||||
|
||||
if set(WOVariables.wo_mysql).issubset(set(apt_packages)):
|
||||
if (set(WOVariables.wo_mysql).issubset(set(apt_packages)) or
|
||||
set(WOVariables.wo_mysql_client).issubset(set(apt_packages))):
|
||||
# add mariadb repository excepted on raspbian and ubuntu 19.04
|
||||
if (not WOVariables.wo_distro == 'raspbian'):
|
||||
Log.info(self, "Adding repository for MySQL, please wait...")
|
||||
@@ -42,71 +43,47 @@ def pre_pref(self, apt_packages):
|
||||
keyserver="keyserver.ubuntu.com")
|
||||
WORepo.add_key(self, '0xF1656F24C74CD1D8',
|
||||
keyserver="keyserver.ubuntu.com")
|
||||
if set(WOVariables.wo_mysql).issubset(set(apt_packages)):
|
||||
# generate random 24 characters root password
|
||||
chars = ''.join(random.sample(string.ascii_letters, 24))
|
||||
# configure MySQL non-interactive install
|
||||
if (not WOVariables.wo_distro == 'raspbian'):
|
||||
Log.debug(self, "Pre-seeding MySQL")
|
||||
Log.debug(self, "echo \"mariadb-server-10.3 "
|
||||
"mysql-server/root_password "
|
||||
"password \" | "
|
||||
"debconf-set-selections")
|
||||
try:
|
||||
WOShellExec.cmd_exec(self, "echo \"mariadb-server-10.3 "
|
||||
"mysql-server/root_password "
|
||||
"password {chars}\" | "
|
||||
"debconf-set-selections"
|
||||
.format(chars=chars),
|
||||
log=False)
|
||||
except CommandExecutionError as e:
|
||||
Log.debug(self, "{0}".format(e))
|
||||
Log.error("Failed to initialize MySQL package")
|
||||
|
||||
Log.debug(self, "echo \"mariadb-server-10.3 "
|
||||
"mysql-server/root_password_again "
|
||||
"password \" | "
|
||||
"debconf-set-selections")
|
||||
try:
|
||||
WOShellExec.cmd_exec(self, "echo \"mariadb-server-10.3 "
|
||||
"mysql-server/root_password_again "
|
||||
"password {chars}\" | "
|
||||
"debconf-set-selections"
|
||||
.format(chars=chars),
|
||||
log=False)
|
||||
except CommandExecutionError as e:
|
||||
Log.debug(self, "{0}".format(e))
|
||||
Log.error("Failed to initialize MySQL package")
|
||||
mariadb_ver = '10.3'
|
||||
else:
|
||||
Log.debug(self, "Pre-seeding MySQL")
|
||||
Log.debug(self, "echo \"mariadb-server-10.1 "
|
||||
"mysql-server/root_password "
|
||||
"password \" | "
|
||||
"debconf-set-selections")
|
||||
try:
|
||||
WOShellExec.cmd_exec(self, "echo \"mariadb-server-10.1 "
|
||||
"mysql-server/root_password "
|
||||
"password {chars}\" | "
|
||||
"debconf-set-selections"
|
||||
.format(chars=chars),
|
||||
log=False)
|
||||
except CommandExecutionError as e:
|
||||
Log.debug(self, "{0}".format(e))
|
||||
Log.error("Failed to initialize MySQL package")
|
||||
mariadb_ver = '10.1'
|
||||
|
||||
Log.debug(self, "echo \"mariadb-server-10.1 "
|
||||
"mysql-server/root_password_again "
|
||||
"password \" | "
|
||||
"debconf-set-selections")
|
||||
try:
|
||||
WOShellExec.cmd_exec(self, "echo \"mariadb-server-10.1 "
|
||||
"mysql-server/root_password_again "
|
||||
"password {chars}\" | "
|
||||
"debconf-set-selections"
|
||||
.format(chars=chars),
|
||||
log=False)
|
||||
except CommandExecutionError as e:
|
||||
Log.debug(self, "{0}".format(e))
|
||||
Log.error(self, "Failed to initialize MySQL package")
|
||||
Log.debug(self, "Pre-seeding MySQL")
|
||||
Log.debug(self, "echo \"mariadb-server-{0} "
|
||||
"mysql-server/root_password "
|
||||
"password \" | "
|
||||
"debconf-set-selections"
|
||||
.format(mariadb_ver))
|
||||
try:
|
||||
WOShellExec.cmd_exec(self, "echo \"mariadb-server-{0} "
|
||||
"mysql-server/root_password "
|
||||
"password {chars}\" | "
|
||||
"debconf-set-selections"
|
||||
.format(mariadb_ver, chars=chars),
|
||||
log=False)
|
||||
except CommandExecutionError as e:
|
||||
Log.debug(self, "{0}".format(e))
|
||||
Log.error("Failed to initialize MySQL package")
|
||||
|
||||
Log.debug(self, "echo \"mariadb-server-{0} "
|
||||
"mysql-server/root_password_again "
|
||||
"password \" | "
|
||||
"debconf-set-selections"
|
||||
.format(mariadb_ver))
|
||||
try:
|
||||
WOShellExec.cmd_exec(self, "echo \"mariadb-server-{0} "
|
||||
"mysql-server/root_password_again "
|
||||
"password {chars}\" | "
|
||||
"debconf-set-selections"
|
||||
.format(mariadb_ver, chars=chars),
|
||||
log=False)
|
||||
except CommandExecutionError as e:
|
||||
Log.debug(self, "{0}".format(e))
|
||||
Log.error("Failed to initialize MySQL package")
|
||||
# generate my.cnf root credentials
|
||||
mysql_config = """
|
||||
[client]
|
||||
@@ -695,7 +672,7 @@ def post_pref(self, apt_packages, packages):
|
||||
# Parse /etc/php/7.2/fpm/php-fpm.conf
|
||||
data = dict(pid="/run/php/php7.2-fpm.pid",
|
||||
error_log="/var/log/php/7.2/fpm.log",
|
||||
include="/etc/php/7.2/fpm/pool.d/*.conf")
|
||||
include="/etc/php/7.2/fpm/pool.d/*.conf")
|
||||
Log.debug(self, "writting php7.2 configuration into "
|
||||
"/etc/php/7.2/fpm/php-fpm.conf")
|
||||
wo_php_fpm = open('/etc/php/7.2/fpm/php-fpm.conf',
|
||||
@@ -858,8 +835,8 @@ def post_pref(self, apt_packages, packages):
|
||||
|
||||
# Parse /etc/php/7.3/fpm/php-fpm.conf
|
||||
data = dict(pid="/run/php/php7.3-fpm.pid",
|
||||
error_log="/var/log/php7.3-fpm.log",
|
||||
include="/etc/php/7.3/fpm/pool.d/*.conf")
|
||||
error_log="/var/log/php7.3-fpm.log",
|
||||
include="/etc/php/7.3/fpm/pool.d/*.conf")
|
||||
Log.debug(self, "writting php 7.3 configuration into "
|
||||
"/etc/php/7.3/fpm/php-fpm.conf")
|
||||
wo_php_fpm = open('/etc/php/7.3/fpm/php-fpm.conf',
|
||||
|
||||
Reference in New Issue
Block a user