Merge pull request #381 from WordOps/updating-configuration

Updating configuration
This commit is contained in:
VirtuBox
2021-05-20 17:11:54 +02:00
committed by GitHub
13 changed files with 96 additions and 60 deletions

View File

@@ -810,11 +810,11 @@ def sitebackup(self, data):
if data['wo_db_name']:
Log.info(self, 'Backing up database \t\t', end='')
try:
if not WOShellExec.cmd_exec(self, "mysqldump --single-transaction "
"{0} | zstd -T0 -c"
"> {1}/{0}.zst"
.format(data['wo_db_name'],
backup_path)):
if not WOShellExec.cmd_exec(
self, "mysqldump --single-transaction --hex-blob "
"{0} | zstd -c > {1}/{0}.zst"
.format(data['wo_db_name'],
backup_path)):
Log.info(self,
"[" + Log.ENDC + Log.FAIL + "Fail" + Log.OKBLUE + "]")
raise SiteError("mysqldump failed to backup database")

View File

@@ -146,8 +146,18 @@ class WOStackController(CementBaseController):
pargs.proftpd = True
if pargs.web:
if self.app.config.has_section('php'):
config_php_ver = self.app.config.get(
'php', 'version')
if config_php_ver == '7.2':
pargs.php72 = True
elif config_php_ver == '7.3':
pargs.php73 = True
elif config_php_ver == '7.4':
pargs.php74 = True
else:
pargs.php74 = True
pargs.nginx = True
pargs.php73 = True
pargs.mysql = True
pargs.wpcli = True
pargs.sendmail = True
@@ -476,7 +486,7 @@ class WOStackController(CementBaseController):
if not (WOAptGet.is_installed(self, 'php7.2-fpm') or
WOAptGet.is_installed(self, 'php7.3-fpm') or
WOAptGet.is_installed(self, 'php7.4-fpm')):
pargs.php = True
pargs.php74 = True
Log.debug(self, "Setting packages variable for utils")
packages = packages + [[
"https://raw.githubusercontent.com"

View File

@@ -51,6 +51,7 @@ def pre_pref(self, apt_packages):
[client]
user = root
password = {chars}
socket = /run/mysqld/mysqld.sock
""".format(chars=chars)
config = configparser.ConfigParser()
config.read_string(mysql_config)
@@ -924,7 +925,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
# create mysql config if it doesn't exist
if "mariadb-server" in apt_packages:
WOGit.add(self, ["/etc/mysql"], msg="Adding MySQL into Git")
if not os.path.isfile("/etc/mysql/my.cnf"):
if not os.path.exists("/etc/mysql/my.cnf"):
config = ("[mysqld]\nwait_timeout = 30\n"
"interactive_timeout=60\nperformance_schema = 0"
"\nquery_cache_type = 1")
@@ -939,16 +940,11 @@ def post_pref(self, apt_packages, packages, upgrade=False):
config = configparser.ConfigParser()
config.read('/etc/mysql/conf.d/my.cnf.tmp')
chars = config['client']['password']
WOShellExec.cmd_exec(
self,
'mysql -e "ALTER USER root@localhost '
'IDENTIFIED VIA mysql_native_password;"')
WOShellExec.cmd_exec(
self,
'mysql -e "SET PASSWORD = '
'PASSWORD(\'{0}\');"'.format(chars))
WOShellExec.cmd_exec(
self, 'mysql -e "flush privileges;"')
'PASSWORD(\'{0}\'); flush privileges;"'
.format(chars))
WOFileUtils.mvfile(
self, '/etc/mysql/conf.d/my.cnf.tmp',
'/etc/mysql/conf.d/my.cnf')
@@ -956,6 +952,30 @@ def post_pref(self, apt_packages, packages, upgrade=False):
Log.error(self, "Unable to set MySQL password")
WOGit.add(self, ["/etc/mysql"],
msg="Adding MySQL into Git")
elif os.path.exists('/etc/mysql/conf.d/my.cnf'):
if ((WOAptGet.is_installed(
self, 'mariadb-server-10.5')) and
not (WOFileUtils.grepcheck(
self, '/etc/mysql/conf.d/my.cnf', 'socket'))):
try:
config = configparser.ConfigParser()
config.read('/etc/mysql/conf.d/my.cnf')
chars = config['client']['password']
WOShellExec.cmd_exec(
self,
'mysql -e "ALTER USER root@localhost '
'IDENTIFIED VIA unix_socket OR '
'mysql_native_password; '
'SET PASSWORD = PASSWORD(\'{0}\'); '
'flush privileges;"'.format(chars))
WOFileUtils.textappend(
self, '/etc/mysql/conf.d/my.cnf',
'socket = /run/mysqld/mysqld.sock')
except CommandExecutionError:
Log.error(self, "Unable to set MySQL password")
WOGit.add(self, ["/etc/mysql"],
msg="Adding MySQL into Git")
Log.wait(self, "Tuning MariaDB configuration")
if not os.path.isfile("/etc/mysql/my.cnf.default-pkg"):
WOFileUtils.copyfile(self, "/etc/mysql/my.cnf",
@@ -1660,7 +1680,7 @@ def pre_stack(self):
'sysctl.mustache', data, True)
# use tcp_bbr congestion algorithm only on new kernels
if (WOVar.wo_platform_codename == 'bionic' or
WOVar.wo_platform_codename == 'disco' or
WOVar.wo_platform_codename == 'focal' or
WOVar.wo_platform_codename == 'buster'):
try:
WOShellExec.cmd_exec(

View File

@@ -78,8 +78,8 @@ class WOStackStatusController(CementBaseController):
if pargs.mysql:
if ((WOVar.wo_mysql_host == "localhost") or
(WOVar.wo_mysql_host == "127.0.0.1")):
if os.path.exists('/etc/systemd/system/mysql.service'):
services = services + ['mysql']
if os.path.exists('/lib/systemd/system/mariadb.service'):
services = services + ['mariadb']
else:
Log.info(self, "MySQL is not installed")
else:
@@ -176,8 +176,8 @@ class WOStackStatusController(CementBaseController):
if pargs.mysql:
if ((WOVar.wo_mysql_host == "localhost") or
(WOVar.wo_mysql_host == "127.0.0.1")):
if os.path.exists('/etc/systemd/system/mysql.service'):
services = services + ['mysql']
if os.path.exists('/lib/systemd/system/mariadb.service'):
services = services + ['mariadb']
else:
Log.info(self, "MySQL is not installed")
else:
@@ -275,8 +275,8 @@ class WOStackStatusController(CementBaseController):
if pargs.mysql:
if ((WOVar.wo_mysql_host == "localhost") or
(WOVar.wo_mysql_host == "127.0.0.1")):
if os.path.exists('/etc/systemd/system/mysql.service'):
services = services + ['mysql']
if os.path.exists('/lib/systemd/system/mariadb.service'):
services = services + ['mariadb']
else:
Log.info(self, "MySQL is not installed")
else:
@@ -377,8 +377,8 @@ class WOStackStatusController(CementBaseController):
if pargs.mysql:
if ((WOVar.wo_mysql_host == "localhost") or
(WOVar.wo_mysql_host == "127.0.0.1")):
if os.path.exists('/etc/systemd/system/mysql.service'):
services = services + ['mysql']
if os.path.exists('/lib/systemd/system/mariadb.service'):
services = services + ['mariadb']
else:
Log.info(self, "MySQL is not installed")
else:
@@ -487,7 +487,7 @@ class WOStackStatusController(CementBaseController):
if pargs.mysql:
if ((WOVar.wo_mysql_host == "localhost") or
(WOVar.wo_mysql_host == "127.0.0.1")):
if os.path.exists('/etc/systemd/system/mysql.service'):
if os.path.exists('/lib/systemd/system/mariadb.service'):
services = services + ['mysql']
else:
Log.info(self, "MySQL is not installed")

View File

@@ -64,10 +64,10 @@ max_heap_table_size = {{tmp_table_size}}M
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched. On error, make copy and try a repair.
myisam_recover_options = BACKUP
key_buffer_size = 128M
key_buffer_size = 16M
open-files-limit = 500000
table_open_cache = 16000
myisam_sort_buffer_size = 512M
myisam_sort_buffer_size = 128M
concurrent_insert = 2
read_buffer_size = 2M
read_rnd_buffer_size = 1M