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',
|
||||
|
||||
@@ -40,6 +40,12 @@ http {
|
||||
reset_timedout_connection on;
|
||||
more_set_headers "X-Powered-By : WordOps";
|
||||
|
||||
open_file_cache max=50000 inactive=60s;
|
||||
open_file_cache_errors off;
|
||||
open_file_cache_min_uses 2;
|
||||
open_file_cache_valid 120s;
|
||||
open_log_file_cache max=10000 inactive=30s min_uses=2;
|
||||
|
||||
# Limit Request
|
||||
limit_req_status 403;
|
||||
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
|
||||
|
||||
@@ -110,39 +110,26 @@ class WOVariables():
|
||||
# PHP repo and packages
|
||||
if wo_distro == 'ubuntu':
|
||||
wo_php_repo = "ppa:ondrej/php"
|
||||
wo_php = ["php7.2-fpm", "php7.2-curl", "php7.2-gd", "php7.2-imap",
|
||||
"php7.2-readline", "php7.2-common", "php7.2-recode",
|
||||
"php7.2-cli", "php7.2-mbstring",
|
||||
"php7.2-bcmath", "php7.2-mysql", "php7.2-opcache",
|
||||
"php7.2-zip", "php7.2-xml", "php7.2-soap"]
|
||||
wo_php73 = ["php7.3-fpm", "php7.3-curl", "php7.3-gd", "php7.3-imap",
|
||||
"php7.3-readline", "php7.3-common", "php7.3-recode",
|
||||
"php7.3-cli", "php7.3-mbstring",
|
||||
"php7.3-bcmath", "php7.3-mysql", "php7.3-opcache",
|
||||
"php7.3-zip", "php7.3-xml", "php7.3-soap"]
|
||||
wo_php_extra = ["php-memcached", "php-imagick",
|
||||
"graphviz", "php-xdebug", "php-msgpack", "php-redis"]
|
||||
wo_php_key = ''
|
||||
else:
|
||||
wo_php_repo = (
|
||||
"deb https://packages.sury.org/php/ {codename} main"
|
||||
.format(codename=wo_platform_codename))
|
||||
wo_php = ["php7.2-fpm", "php7.2-curl", "php7.2-gd", "php7.2-imap",
|
||||
"php7.2-readline", "php7.2-common", "php7.2-recode",
|
||||
"php7.2-cli", "php7.2-mbstring",
|
||||
"php7.2-bcmath", "php7.2-mysql", "php7.2-opcache",
|
||||
"php7.2-zip", "php7.2-xml", "php7.2-soap"]
|
||||
wo_php73 = ["php7.3-fpm", "php7.3-curl", "php7.3-gd", "php7.3-imap",
|
||||
"php7.3-readline", "php7.3-common", "php7.3-recode",
|
||||
"php7.3-cli", "php7.3-mbstring",
|
||||
"php7.3-bcmath", "php7.3-mysql", "php7.3-opcache",
|
||||
"php7.3-zip", "php7.3-xml", "php7.3-soap"]
|
||||
wo_php_extra = ["php-memcached", "php-imagick",
|
||||
"graphviz", "php-xdebug", "php-msgpack",
|
||||
"php-redis", "php-mysql"]
|
||||
|
||||
wo_php_key = 'AC0E47584A7A714D'
|
||||
|
||||
wo_php = ["php7.2-fpm", "php7.2-curl", "php7.2-gd", "php7.2-imap",
|
||||
"php7.2-readline", "php7.2-common", "php7.2-recode",
|
||||
"php7.2-cli", "php7.2-mbstring",
|
||||
"php7.2-bcmath", "php7.2-mysql", "php7.2-opcache",
|
||||
"php7.2-zip", "php7.2-xml", "php7.2-soap"]
|
||||
wo_php73 = ["php7.3-fpm", "php7.3-curl", "php7.3-gd", "php7.3-imap",
|
||||
"php7.3-readline", "php7.3-common", "php7.3-recode",
|
||||
"php7.3-cli", "php7.3-mbstring",
|
||||
"php7.3-bcmath", "php7.3-mysql", "php7.3-opcache",
|
||||
"php7.3-zip", "php7.3-xml", "php7.3-soap"]
|
||||
wo_php_extra = ["php-memcached", "php-imagick",
|
||||
"graphviz", "php-xdebug", "php-msgpack", "php-redis"]
|
||||
|
||||
# MySQL repo and packages
|
||||
if wo_distro == 'ubuntu':
|
||||
wo_mysql_repo = ("deb [arch=amd64,ppc64el] "
|
||||
@@ -155,11 +142,9 @@ class WOVariables():
|
||||
"10.3/debian {codename} main"
|
||||
.format(codename=wo_platform_codename))
|
||||
|
||||
if wo_platform_codename == 'jessie':
|
||||
wo_mysql = ["mariadb-server", "percona-toolkit",
|
||||
"python3-mysql.connector"]
|
||||
else:
|
||||
wo_mysql = ["mariadb-server", "percona-toolkit", "python3-mysqldb"]
|
||||
wo_mysql = ["mariadb-server", "percona-toolkit", "python3-mysqldb"]
|
||||
|
||||
wo_mysql_client = ["mariadb-client", "python3-mysqldb"]
|
||||
|
||||
wo_fail2ban = ["fail2ban"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user