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')),
|
dict(help='Install PHP 7.3 stack', action='store_true')),
|
||||||
(['--mysql'],
|
(['--mysql'],
|
||||||
dict(help='Install MySQL stack', action='store_true')),
|
dict(help='Install MySQL stack', action='store_true')),
|
||||||
|
(['--mysqlclient'],
|
||||||
|
dict(help='Install MySQL client for remote MySQL server',
|
||||||
|
action='store_true')),
|
||||||
(['--wpcli'],
|
(['--wpcli'],
|
||||||
dict(help='Install WPCLI stack', action='store_true')),
|
dict(help='Install WPCLI stack', action='store_true')),
|
||||||
(['--phpmyadmin'],
|
(['--phpmyadmin'],
|
||||||
@@ -107,12 +110,10 @@ class WOStackController(CementBaseController):
|
|||||||
if ((not pargs.web) and (not pargs.admin) and
|
if ((not pargs.web) and (not pargs.admin) and
|
||||||
(not pargs.nginx) and (not pargs.php) and
|
(not pargs.nginx) and (not pargs.php) and
|
||||||
(not pargs.mysql) and (not pargs.wpcli) and
|
(not pargs.mysql) and (not pargs.wpcli) and
|
||||||
(not pargs.phpmyadmin) and
|
(not pargs.phpmyadmin) and (not pargs.composer) and
|
||||||
(not pargs.composer) and
|
(not pargs.netdata) and (not pargs.dashboard) and
|
||||||
(not pargs.netdata) and
|
(not pargs.fail2ban) and (not pargs.security)
|
||||||
(not pargs.dashboard) and
|
and (not pargs.mysqlclient) and
|
||||||
(not pargs.fail2ban) and
|
|
||||||
(not pargs.security) and
|
|
||||||
(not pargs.adminer) and (not pargs.utils) and
|
(not pargs.adminer) and (not pargs.utils) and
|
||||||
(not pargs.redis) and (not pargs.proftpd) and
|
(not pargs.redis) and (not pargs.proftpd) and
|
||||||
(not pargs.phpredisadmin) and
|
(not pargs.phpredisadmin) and
|
||||||
@@ -218,9 +219,10 @@ class WOStackController(CementBaseController):
|
|||||||
"/usr/bin/mysqltuner",
|
"/usr/bin/mysqltuner",
|
||||||
"MySQLTuner"]]
|
"MySQLTuner"]]
|
||||||
|
|
||||||
else:
|
if pargs.mysqlclient:
|
||||||
Log.debug(self, "MySQL connection is already alive")
|
Log.debug(self, "Setting apt_packages variable "
|
||||||
Log.info(self, "MySQL connection is already alive")
|
"for MySQL Client")
|
||||||
|
apt_packages = apt_packages + WOVariables.wo_mysql_client
|
||||||
|
|
||||||
# WP-CLI
|
# WP-CLI
|
||||||
if pargs.wpcli:
|
if pargs.wpcli:
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ from wo.core.variables import WOVariables
|
|||||||
def pre_pref(self, apt_packages):
|
def pre_pref(self, apt_packages):
|
||||||
"""Pre settings to do before installation 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
|
# add mariadb repository excepted on raspbian and ubuntu 19.04
|
||||||
if (not WOVariables.wo_distro == 'raspbian'):
|
if (not WOVariables.wo_distro == 'raspbian'):
|
||||||
Log.info(self, "Adding repository for MySQL, please wait...")
|
Log.info(self, "Adding repository for MySQL, please wait...")
|
||||||
@@ -42,71 +43,47 @@ def pre_pref(self, apt_packages):
|
|||||||
keyserver="keyserver.ubuntu.com")
|
keyserver="keyserver.ubuntu.com")
|
||||||
WORepo.add_key(self, '0xF1656F24C74CD1D8',
|
WORepo.add_key(self, '0xF1656F24C74CD1D8',
|
||||||
keyserver="keyserver.ubuntu.com")
|
keyserver="keyserver.ubuntu.com")
|
||||||
|
if set(WOVariables.wo_mysql).issubset(set(apt_packages)):
|
||||||
# generate random 24 characters root password
|
# generate random 24 characters root password
|
||||||
chars = ''.join(random.sample(string.ascii_letters, 24))
|
chars = ''.join(random.sample(string.ascii_letters, 24))
|
||||||
# configure MySQL non-interactive install
|
# configure MySQL non-interactive install
|
||||||
if (not WOVariables.wo_distro == 'raspbian'):
|
if (not WOVariables.wo_distro == 'raspbian'):
|
||||||
Log.debug(self, "Pre-seeding MySQL")
|
mariadb_ver = '10.3'
|
||||||
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")
|
|
||||||
else:
|
else:
|
||||||
Log.debug(self, "Pre-seeding MySQL")
|
mariadb_ver = '10.1'
|
||||||
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")
|
|
||||||
|
|
||||||
Log.debug(self, "echo \"mariadb-server-10.1 "
|
Log.debug(self, "Pre-seeding MySQL")
|
||||||
"mysql-server/root_password_again "
|
Log.debug(self, "echo \"mariadb-server-{0} "
|
||||||
"password \" | "
|
"mysql-server/root_password "
|
||||||
"debconf-set-selections")
|
"password \" | "
|
||||||
try:
|
"debconf-set-selections"
|
||||||
WOShellExec.cmd_exec(self, "echo \"mariadb-server-10.1 "
|
.format(mariadb_ver))
|
||||||
"mysql-server/root_password_again "
|
try:
|
||||||
"password {chars}\" | "
|
WOShellExec.cmd_exec(self, "echo \"mariadb-server-{0} "
|
||||||
"debconf-set-selections"
|
"mysql-server/root_password "
|
||||||
.format(chars=chars),
|
"password {chars}\" | "
|
||||||
log=False)
|
"debconf-set-selections"
|
||||||
except CommandExecutionError as e:
|
.format(mariadb_ver, chars=chars),
|
||||||
Log.debug(self, "{0}".format(e))
|
log=False)
|
||||||
Log.error(self, "Failed to initialize MySQL package")
|
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
|
# generate my.cnf root credentials
|
||||||
mysql_config = """
|
mysql_config = """
|
||||||
[client]
|
[client]
|
||||||
@@ -695,7 +672,7 @@ def post_pref(self, apt_packages, packages):
|
|||||||
# Parse /etc/php/7.2/fpm/php-fpm.conf
|
# Parse /etc/php/7.2/fpm/php-fpm.conf
|
||||||
data = dict(pid="/run/php/php7.2-fpm.pid",
|
data = dict(pid="/run/php/php7.2-fpm.pid",
|
||||||
error_log="/var/log/php/7.2/fpm.log",
|
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 "
|
Log.debug(self, "writting php7.2 configuration into "
|
||||||
"/etc/php/7.2/fpm/php-fpm.conf")
|
"/etc/php/7.2/fpm/php-fpm.conf")
|
||||||
wo_php_fpm = open('/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
|
# Parse /etc/php/7.3/fpm/php-fpm.conf
|
||||||
data = dict(pid="/run/php/php7.3-fpm.pid",
|
data = dict(pid="/run/php/php7.3-fpm.pid",
|
||||||
error_log="/var/log/php7.3-fpm.log",
|
error_log="/var/log/php7.3-fpm.log",
|
||||||
include="/etc/php/7.3/fpm/pool.d/*.conf")
|
include="/etc/php/7.3/fpm/pool.d/*.conf")
|
||||||
Log.debug(self, "writting php 7.3 configuration into "
|
Log.debug(self, "writting php 7.3 configuration into "
|
||||||
"/etc/php/7.3/fpm/php-fpm.conf")
|
"/etc/php/7.3/fpm/php-fpm.conf")
|
||||||
wo_php_fpm = open('/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;
|
reset_timedout_connection on;
|
||||||
more_set_headers "X-Powered-By : WordOps";
|
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 Request
|
||||||
limit_req_status 403;
|
limit_req_status 403;
|
||||||
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
|
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
|
||||||
|
|||||||
@@ -110,39 +110,26 @@ class WOVariables():
|
|||||||
# PHP repo and packages
|
# PHP repo and packages
|
||||||
if wo_distro == 'ubuntu':
|
if wo_distro == 'ubuntu':
|
||||||
wo_php_repo = "ppa:ondrej/php"
|
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 = ''
|
wo_php_key = ''
|
||||||
else:
|
else:
|
||||||
wo_php_repo = (
|
wo_php_repo = (
|
||||||
"deb https://packages.sury.org/php/ {codename} main"
|
"deb https://packages.sury.org/php/ {codename} main"
|
||||||
.format(codename=wo_platform_codename))
|
.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_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
|
# MySQL repo and packages
|
||||||
if wo_distro == 'ubuntu':
|
if wo_distro == 'ubuntu':
|
||||||
wo_mysql_repo = ("deb [arch=amd64,ppc64el] "
|
wo_mysql_repo = ("deb [arch=amd64,ppc64el] "
|
||||||
@@ -155,11 +142,9 @@ class WOVariables():
|
|||||||
"10.3/debian {codename} main"
|
"10.3/debian {codename} main"
|
||||||
.format(codename=wo_platform_codename))
|
.format(codename=wo_platform_codename))
|
||||||
|
|
||||||
if wo_platform_codename == 'jessie':
|
wo_mysql = ["mariadb-server", "percona-toolkit", "python3-mysqldb"]
|
||||||
wo_mysql = ["mariadb-server", "percona-toolkit",
|
|
||||||
"python3-mysql.connector"]
|
wo_mysql_client = ["mariadb-client", "python3-mysqldb"]
|
||||||
else:
|
|
||||||
wo_mysql = ["mariadb-server", "percona-toolkit", "python3-mysqldb"]
|
|
||||||
|
|
||||||
wo_fail2ban = ["fail2ban"]
|
wo_fail2ban = ["fail2ban"]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user