diff --git a/ee/cli/plugins/mailscannerstack.py b/ee/cli/plugins/mailscannerstack.py index 3f9b91be..b0bc7ee3 100644 --- a/ee/cli/plugins/mailscannerstack.py +++ b/ee/cli/plugins/mailscannerstack.py @@ -135,6 +135,14 @@ class EEMailScannerStack(EEStack): except CommandExecutionError as e: raise SiteError(" Unable to update ClamAV-Amavis config") + # If Amavis is going to be installed then configure Vimabadmin + # Amavis settings + vm_config = open('/etc/amavis/conf.d/50-user', + encoding='utf-8', mode='w') + self.app.render((data), '50-user.mustache', + out=vm_config) + vm_config.close() + EEGit.add(self, ["/etc/amavis"], msg="Adding Amavis into Git") EEService.restart_service(self, 'dovecot') EEService.reload_service(self, 'postfix') diff --git a/ee/cli/plugins/mailstack.py b/ee/cli/plugins/mailstack.py index b8e40b04..ca7bd3c3 100644 --- a/ee/cli/plugins/mailstack.py +++ b/ee/cli/plugins/mailstack.py @@ -41,15 +41,17 @@ class EEMailStack(EEStack): """ Check if requirements for this EEWebmailAdmin stack are fullfilled. """ - + # Install NGINX stack if not installed if not EENginxStack(self).is_installed(): self.log.info("Installing nginxstack") EENginxStack(self).install_stack() + # Install PHP stack if not installed if not EEPhpStack(self).is_installed(): self.log.info("Installing phpstack") EEPhpStack(self).install_stack() + # Install MySQL stack if not installed if not EEMysqlStack(self).is_installed(): self.log.info("Installing mysqlstack") EEMysqlStack(self).install_stack() @@ -60,7 +62,7 @@ class EEMailStack(EEStack): Add repository for packages to be downloaded from """ self.log.info("Adding MAIL repository, please wait...") - + # update repository information EEAptGet.update(self) def _pre_install_stack(self): @@ -564,5 +566,3 @@ class EEWebmailAdmin (EEStack): self._pre_install() self._install_vimbadmin() self._install_roundcube() - - diff --git a/ee/cli/plugins/mysqlstack.py b/ee/cli/plugins/mysqlstack.py index 46eec68a..f5000faf 100644 --- a/ee/cli/plugins/mysqlstack.py +++ b/ee/cli/plugins/mysqlstack.py @@ -9,6 +9,7 @@ from ee.core.apt_repo import EERepo from ee.cli.plugins.eestack import EEStack from ee.core.shellexec import EEShellExec from ee.core.shellexec import CommandExecutionError +from ee.core.download import EEDownload from ee.core.logging import Log from ee.cli.main import app @@ -54,6 +55,19 @@ class EEMysqlStack(EEStack): keyserver="keyserver.ubuntu.com") EEAptGet.update(self) + def setup_mysqltuner(self): + """ + + """ + EEDownload.download(self, [["https://raw.githubusercontent.com/" + "major/MySQLTuner-perl" + "/master/mysqltuner.pl", + "/usr/bin/mysqltuner", "MySQLTuner"]]) + # Set MySQLTuner permission + EEFileUtils.chmod(self, "/usr/bin/mysqltuner", 0o775) + + + def _pre_install_stack(self): """ Defines pre-install activities done before installing mysql stack @@ -108,7 +122,28 @@ class EEMysqlStack(EEStack): """ Defines activities done after installing mysql stack """ - pass + self.setup_mysqltuner() + if not os.path.isfile("/etc/mysql/my.cnf"): + config = ("[mysqld]\nwait_timeout = 30\n" + "interactive_timeout=60\nperformance_schema = 0" + "\nquery_cache_type = 1") + config_file = open("/etc/mysql/my.cnf", + encoding='utf-8', mode='w') + config_file.write(config) + config_file.close() + else: + try: + EEShellExec.cmd_exec(self, "sed -i \"/#max_conn" + "ections/a wait_timeout = 30 \\n" + "interactive_timeout = 60 \\n" + "performance_schema = 0\\n" + "query_cache_type = 1 \" " + "/etc/mysql/my.cnf") + except CommandExecutionError as e: + Log.error(self, "Unable to update MySQL file") + + EEGit.add(self, ["/etc/mysql"], msg="Adding MySQL into Git") + EEService.reload_service(self, 'mysql') def install_stack(self): """