From 5263ebe992944d8431a9a1e8ec7f67ffc0be81fc Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sun, 31 Mar 2019 17:14:17 +0200 Subject: [PATCH 01/24] fix phpmyadmin install --- CHANGELOG.md | 1 + install | 32 +++++++++++++++++--------------- wo/cli/plugins/stack.py | 23 ++++++++++++++++++++--- 3 files changed, 38 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d885c88..59c3e98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - WordOps configuration backup before upgrade - Previous acme.sh certs migration - "wo maintenance" command to perform server package update & cleanup +- Support for Netdata on backend : https://server.hostname:22222/netdata/ #### Changed diff --git a/install b/install index 7a315f6..43425a9 100644 --- a/install +++ b/install @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # ------------------------------------------------------------------------- # WordOps install and update script # ------------------------------------------------------------------------- @@ -425,7 +425,11 @@ wo_upgrade_nginx() { rm -f /tmp/nginx-wo.key sudo apt-get update - CHECK_NGINX_UPSTREAM_VERSION=$(grep "v3.9.5.1" /etc/nginx/conf.d/fastcgi.conf) + if [ -f /etc/nginx/common/release ]; then + CHECK_NGINX_UPSTREAM_VERSION=$(grep "$wo_version_new" /etc/nginx/common/release) + else + CHECK_NGINX_UPSTREAM_VERSION=$(grep "$wo_version_new" /etc/nginx/conf.d/fastcgi.conf) + fi if [ -z "$CHECK_NGINX_UPSTREAM_VERSION" ]; then # stop nginx @@ -456,6 +460,7 @@ wo_upgrade_nginx() { rm -f /etc/php/7.2/fpm/pool.d/{www.conf,www-two.conf,debug.conf} fi /usr/local/bin/wo stack install --nginx --php + echo "$wo_version_new" > /etc/nginx/common/release if [ -n "$CHECK_PHP73" ]; then apt-get remove php7.3-fpm -y -qq --purge rm -f /etc/php/7.3/fpm/pool.d/{www.conf,www-two.conf,debug.conf} @@ -535,13 +540,6 @@ wo_update_latest() { chmod 600 /root/.my.cnf fi fi - # Fix WordPress example.html issue - # Ref: http://wptavern.com/xss-vulnerability-in-jetpack-and-the-twenty-fifteen-default-theme-affects-millions-of-wordpress-users - CHECK_DEINSTALL_NGINX=$(dpkg --get-selections | grep -v deinstall | grep nginx) - if [ -z "$CHECK_DEINSTALL_NGINX" ]; then - cp /usr/lib/wo/templates/locations.mustache /etc/nginx/common/locations-php72.conf - - fi # Fix Redis-server security issue # http://redis.io/topics/security @@ -621,11 +619,13 @@ if [ -x /usr/local/bin/wo ]; then wo_install >> wo_install_log 2>&1 if [ -x "$(command -v nginx)" ]; then wo_lib_echo "Upgrading Nginx" | tee -ai $wo_install_log - wo_upgrade_nginx | tee -ai $wo_install_log + wo_upgrade_nginx | tee -ai $wo_install_log fi wo_update_latest | tee -ai $wo_install_log - wo_lib_echo "Installing acme.sh" | tee -ai $wo_install_log - wo_install_acme_sh | tee -ai $wo_install_log + if [ ! -d /opt/acme.sh ]; then + wo_lib_echo "Installing acme.sh" | tee -ai $wo_install_log + wo_install_acme_sh | tee -ai $wo_install_log + fi wo_lib_echo "Running post-install steps " | tee -ai $wo_install_log wo_git_init | tee -ai $wo_install_log wo_update_wp_cli | tee -ai $wo_install_log @@ -651,11 +651,13 @@ else wo_install >> wo_install_log 2>&1 if [ -x "$(command -v nginx)" ]; then wo_lib_echo "Upgrading Nginx" | tee -ai $wo_install_log - wo_upgrade_nginx | tee -ai $wo_install_log + wo_upgrade_nginx | tee -ai $wo_install_log fi wo_update_latest | tee -ai $wo_install_log - wo_lib_echo "Installing acme.sh" | tee -ai $wo_install_log - wo_install_acme_sh | tee -ai $wo_install_log + if [ ! -d /opt/acme.sh ]; then + wo_lib_echo "Installing acme.sh" | tee -ai $wo_install_log + wo_install_acme_sh | tee -ai $wo_install_log + fi wo_lib_echo "Running post-install steps " | tee -ai $wo_install_log wo_git_init | tee -ai $wo_install_log wo_update_wp_cli | tee -ai $wo_install_log diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index fa56c92..a9e9cb9 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -369,6 +369,10 @@ class WOStackController(CementBaseController): self.app.render((data), 'locations.mustache', out=wo_nginx) wo_nginx.close() + if not os.path.isfile("/etc/nginx/common/release"): + with open("/etc/nginx/common/release", + "a") as release_file: + release_file.write("v3.9.5") # Nginx-Plus does not have nginx # package structure like this @@ -1029,6 +1033,17 @@ class WOStackController(CementBaseController): WOVariables.wo_php_user, WOVariables.wo_php_user, recursive=True) + + if os.path.isfile("/tmp/composer-install"): + WOShellExec.cmd_exec(self, "php -q /tmp/composer-install" + "--install-dir=/tmp/") + shutil.move('/tmp/composer.phar', + '/usr/local/bin/composer') + WOFileUtils.chmod(self, "/usr/local/bin/composer", 0o775) + WOShellExec.cmd_exec(self, "sudo -u www-data -H composer " + "update --no-dev -d " + "/var/www/22222/htdocs/db/pma/") + if any('/tmp/memcached.tar.gz' == x[1] for x in packages): Log.debug(self, "Extracting memcached.tar.gz to location" @@ -1286,13 +1301,15 @@ class WOStackController(CementBaseController): # PHPMYADMIN if self.app.pargs.phpmyadmin: - Log.debug(self, "Setting packages varible for phpMyAdmin ") + Log.debug(self, "Setting packages variable for phpMyAdmin ") packages = packages + [["https://github.com/phpmyadmin/" "phpmyadmin/archive/STABLE.tar.gz", - "/tmp/pma.tar.gz", "phpMyAdmin"]] + "/tmp/pma.tar.gz", "phpMyAdmin"], + ["https://getcomposer.org/installer", + "/tmp/composer-install", "composer"]] # PHPREDISADMIN if self.app.pargs.phpredisadmin: - Log.debug(self, "Setting packages varible for phpRedisAdmin") + Log.debug(self, "Setting packages variable for phpRedisAdmin") packages = packages + [["https://github.com/ErikDubbelboer/" "phpRedisAdmin/archive/master.tar.gz", "/tmp/pra.tar.gz", "phpRedisAdmin"], From e1ee9def602eb1a72221202529ae9fd2e61e3b65 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sun, 31 Mar 2019 17:20:40 +0200 Subject: [PATCH 02/24] fix composer install --- wo/cli/plugins/stack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index a9e9cb9..a8943b6 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -1035,7 +1035,7 @@ class WOStackController(CementBaseController): recursive=True) if os.path.isfile("/tmp/composer-install"): - WOShellExec.cmd_exec(self, "php -q /tmp/composer-install" + WOShellExec.cmd_exec(self, "php -q /tmp/composer-install " "--install-dir=/tmp/") shutil.move('/tmp/composer.phar', '/usr/local/bin/composer') From 412c7d7e6d1d2adc8720902ae91d9330f811ea65 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sun, 31 Mar 2019 19:04:51 +0200 Subject: [PATCH 03/24] force phpmyadmin update --- CHANGELOG.md | 1 + wo/cli/plugins/stack.py | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59c3e98..ed661d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - WordOps backup directory creation before upgrade - EasyEngine database sync during migration - command "wo info" +- phpmyadmin install with composer ### v3.9.4 - 2019-03-15 diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index a8943b6..759ec74 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -1034,10 +1034,11 @@ class WOStackController(CementBaseController): WOVariables.wo_php_user, recursive=True) - if os.path.isfile("/tmp/composer-install"): - WOShellExec.cmd_exec(self, "php -q /tmp/composer-install " - "--install-dir=/tmp/") - shutil.move('/tmp/composer.phar', + if any('/tmp/composer-install' == x[1] + for x in packages): + WOShellExec.cmd_exec(self, "php -q /tmp/composer-install " + "--install-dir=/tmp/") + shutil.move('/tmp/composer.phar', '/usr/local/bin/composer') WOFileUtils.chmod(self, "/usr/local/bin/composer", 0o775) WOShellExec.cmd_exec(self, "sudo -u www-data -H composer " @@ -1306,7 +1307,7 @@ class WOStackController(CementBaseController): "phpmyadmin/archive/STABLE.tar.gz", "/tmp/pma.tar.gz", "phpMyAdmin"], ["https://getcomposer.org/installer", - "/tmp/composer-install", "composer"]] + "/tmp/composer-install", "Composer"]] # PHPREDISADMIN if self.app.pargs.phpredisadmin: Log.debug(self, "Setting packages variable for phpRedisAdmin") From 4109a1622e93a1ab16806dc3d58ae2aae4b9199f Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sun, 31 Mar 2019 19:11:19 +0200 Subject: [PATCH 04/24] fix clean memcached --- wo/cli/plugins/clean.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wo/cli/plugins/clean.py b/wo/cli/plugins/clean.py index 6400c13..58b1246 100644 --- a/wo/cli/plugins/clean.py +++ b/wo/cli/plugins/clean.py @@ -65,7 +65,7 @@ class WOCleanController(CementBaseController): Log.info(self, "Redis is not installed") @expose(hide=True) - def clean_memcache(self): + def clean_memcached(self): try: if(WOAptGet.is_installed(self, "memcached")): WOService.restart_service(self, "memcached") From c2cc4a839a092c663ef8d212ff90182825a258b3 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sun, 31 Mar 2019 19:17:27 +0200 Subject: [PATCH 05/24] fix composer --- wo/cli/plugins/stack.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 759ec74..4a8576a 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -999,9 +999,9 @@ class WOStackController(CementBaseController): .format(WOVariables.wo_webroot)) os.makedirs('{0}22222/htdocs/db' .format(WOVariables.wo_webroot)) - shutil.move('/tmp/phpmyadmin-STABLE/', - '{0}22222/htdocs/db/pma/' - .format(WOVariables.wo_webroot)) + shutil.move('/tmp/phpmyadmin-STABLE/', + '{0}22222/htdocs/db/pma/' + .format(WOVariables.wo_webroot)) shutil.copyfile('{0}22222/htdocs/db/pma/config.sample.inc.php' .format(WOVariables.wo_webroot), '{0}22222/htdocs/db/pma/config.inc.php' @@ -1038,12 +1038,12 @@ class WOStackController(CementBaseController): for x in packages): WOShellExec.cmd_exec(self, "php -q /tmp/composer-install " "--install-dir=/tmp/") - shutil.move('/tmp/composer.phar', + shutil.copyfile('tmp/composer.phar', '/usr/local/bin/composer') - WOFileUtils.chmod(self, "/usr/local/bin/composer", 0o775) - WOShellExec.cmd_exec(self, "sudo -u www-data -H composer " - "update --no-dev -d " - "/var/www/22222/htdocs/db/pma/") + WOFileUtils.chmod(self, "/usr/local/bin/composer", 0o775) + WOShellExec.cmd_exec(self, "sudo -u www-data -H composer " + "update --no-dev -d " + "/var/www/22222/htdocs/db/pma/") if any('/tmp/memcached.tar.gz' == x[1] for x in packages): From 9fefcb695b9dae35010b025804bd2b56a0fa93eb Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sun, 31 Mar 2019 19:41:08 +0200 Subject: [PATCH 06/24] fix composer install --- wo/cli/plugins/stack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 4a8576a..be9af15 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -1038,7 +1038,7 @@ class WOStackController(CementBaseController): for x in packages): WOShellExec.cmd_exec(self, "php -q /tmp/composer-install " "--install-dir=/tmp/") - shutil.copyfile('tmp/composer.phar', + shutil.copyfile('/tmp/composer.phar', '/usr/local/bin/composer') WOFileUtils.chmod(self, "/usr/local/bin/composer", 0o775) WOShellExec.cmd_exec(self, "sudo -u www-data -H composer " From 77222f4944f0bdb77d2bedc29f710aa488a15987 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Mon, 1 Apr 2019 01:43:59 +0200 Subject: [PATCH 07/24] fix fpm status on 22222 --- install | 4 ++-- wo/cli/plugins/stack.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/install b/install index 43425a9..d27f44e 100644 --- a/install +++ b/install @@ -618,7 +618,7 @@ if [ -x /usr/local/bin/wo ]; then wo_lib_echo "Installing WordOps " | tee -ai $wo_install_log wo_install >> wo_install_log 2>&1 if [ -x "$(command -v nginx)" ]; then - wo_lib_echo "Upgrading Nginx" | tee -ai $wo_install_log + wo_lib_echo "Upgrading Nginx" | tee -ai $wo_install_log wo_upgrade_nginx | tee -ai $wo_install_log fi wo_update_latest | tee -ai $wo_install_log @@ -650,7 +650,7 @@ else wo_lib_echo "Installing WordOps " | tee -ai $wo_install_log wo_install >> wo_install_log 2>&1 if [ -x "$(command -v nginx)" ]; then - wo_lib_echo "Upgrading Nginx" | tee -ai $wo_install_log + wo_lib_echo "Upgrading Nginx" | tee -ai $wo_install_log wo_upgrade_nginx | tee -ai $wo_install_log fi wo_update_latest | tee -ai $wo_install_log diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index be9af15..e241795 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -774,10 +774,16 @@ class WOStackController(CementBaseController): .format(WOVariables.wo_webroot)) os.makedirs('{0}22222/htdocs/fpm/status/' .format(WOVariables.wo_webroot)) - open('{0}22222/htdocs/fpm/status/debug' + open('{0}22222/htdocs/fpm/status/debug72' .format(WOVariables.wo_webroot), encoding='utf-8', mode='a').close() - open('{0}22222/htdocs/fpm/status/php' + open('{0}22222/htdocs/fpm/status/debug73' + .format(WOVariables.wo_webroot), + encoding='utf-8', mode='a').close() + open('{0}22222/htdocs/fpm/status/php72' + .format(WOVariables.wo_webroot), + encoding='utf-8', mode='a').close() + open('{0}22222/htdocs/fpm/status/php73' .format(WOVariables.wo_webroot), encoding='utf-8', mode='a').close() From 12899faf618c56f8cee62fd66621766e2cbf36bb Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Mon, 1 Apr 2019 01:53:00 +0200 Subject: [PATCH 08/24] do not overwrite acl.conf anymore --- install | 1 + 1 file changed, 1 insertion(+) diff --git a/install b/install index d27f44e..518e345 100644 --- a/install +++ b/install @@ -466,6 +466,7 @@ wo_upgrade_nginx() { rm -f /etc/php/7.3/fpm/pool.d/{www.conf,www-two.conf,debug.conf} /usr/local/bin/wo stack install --php73 fi + rm -f /etc/nginx/common/acl.conf /etc/nginx/conf.d/{map-wp-cache.conf,map-wp.conf} fi # restore sites and configuration From 23af2faa3e3331ce33e9df29120d5422a8506e32 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Mon, 1 Apr 2019 20:59:53 +0200 Subject: [PATCH 09/24] adding composer and netdata --- wo/cli/plugins/site_functions.py | 9 +++++--- wo/cli/plugins/stack.py | 36 +++++++++++++++++++------------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/wo/cli/plugins/site_functions.py b/wo/cli/plugins/site_functions.py index 67481fe..fb779aa 100644 --- a/wo/cli/plugins/site_functions.py +++ b/wo/cli/plugins/site_functions.py @@ -725,7 +725,8 @@ def site_package_check(self, stype): Log.debug(self, "Setting apt_packages variable for PHP 7.2") if not WOAptGet.is_installed(self, 'php7.2-fpm'): if not WOAptGet.is_installed(self, 'php7.3-fpm'): - apt_packages = apt_packages + WOVariables.wo_php + WOVariables.wo_php_extra + apt_packages = apt_packages + WOVariables.wo_php + \ + WOVariables.wo_php_extra else: apt_packages = apt_packages + WOVariables.wo_php @@ -733,7 +734,8 @@ def site_package_check(self, stype): Log.debug(self, "Setting apt_packages variable for PHP 7.3") if not WOAptGet.is_installed(self, 'php7.3-fpm'): if not WOAptGet.is_installed(self, 'php7.2-fpm'): - apt_packages = apt_packages + WOVariables.wo_php73 + WOVariables.wo_php_extra + apt_packages = apt_packages + WOVariables.wo_php + \ + WOVariables.wo_php73 + WOVariables.wo_php_extra else: apt_packages = apt_packages + WOVariables.wo_php73 @@ -796,7 +798,8 @@ def site_package_check(self, stype): Log.debug(self, "Setting apt_packages variable for PHP 7.3") if not WOAptGet.is_installed(self, 'php7.3-fpm'): if not WOAptGet.is_installed(self, 'php7.2-fpm'): - apt_packages = apt_packages + WOVariables.wo_php73 + WOVariables.wo_php_extra + apt_packages = apt_packages + WOVariables.wo_php + \ + WOVariables.wo_php73 + WOVariables.wo_php_extra else: apt_packages = apt_packages + WOVariables.wo_php73 diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index e241795..70599de 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -63,6 +63,10 @@ class WOStackController(CementBaseController): dict(help='Install WPCLI stack', action='store_true')), (['--phpmyadmin'], dict(help='Install PHPMyAdmin stack', action='store_true')), + (['--composer'], + dict(help='Install Composer stack', action='store_true')), + (['--netdata'], + dict(help='Install Netdata monitoring suite', action='store_true')), (['--adminer'], dict(help='Install Adminer stack', action='store_true')), (['--utils'], @@ -373,6 +377,7 @@ class WOStackController(CementBaseController): with open("/etc/nginx/common/release", "a") as release_file: release_file.write("v3.9.5") + release_file.close() # Nginx-Plus does not have nginx # package structure like this @@ -777,15 +782,9 @@ class WOStackController(CementBaseController): open('{0}22222/htdocs/fpm/status/debug72' .format(WOVariables.wo_webroot), encoding='utf-8', mode='a').close() - open('{0}22222/htdocs/fpm/status/debug73' - .format(WOVariables.wo_webroot), - encoding='utf-8', mode='a').close() open('{0}22222/htdocs/fpm/status/php72' .format(WOVariables.wo_webroot), encoding='utf-8', mode='a').close() - open('{0}22222/htdocs/fpm/status/php73' - .format(WOVariables.wo_webroot), - encoding='utf-8', mode='a').close() # Write info.php if not os.path.exists('{0}22222/htdocs/php/' @@ -934,10 +933,10 @@ class WOStackController(CementBaseController): .format(WOVariables.wo_webroot)) os.makedirs('{0}22222/htdocs/fpm/status/' .format(WOVariables.wo_webroot)) - open('{0}22222/htdocs/fpm/status/debug' + open('{0}22222/htdocs/fpm/status/debug73' .format(WOVariables.wo_webroot), encoding='utf-8', mode='a').close() - open('{0}22222/htdocs/fpm/status/php' + open('{0}22222/htdocs/fpm/status/php73' .format(WOVariables.wo_webroot), encoding='utf-8', mode='a').close() @@ -1200,6 +1199,7 @@ class WOStackController(CementBaseController): (not self.app.pargs.nginx) and (not self.app.pargs.php) and (not self.app.pargs.mysql) and (not self.app.pargs.wpcli) and (not self.app.pargs.phpmyadmin) and + (not self.app.pargs.composer) and (not self.app.pargs.netdata) (not self.app.pargs.adminer) and (not self.app.pargs.utils) and (not self.app.pargs.redis) and (not self.app.pargs.phpredisadmin) and @@ -1257,7 +1257,8 @@ class WOStackController(CementBaseController): Log.debug(self, "Setting apt_packages variable for PHP 7.2") if not (WOAptGet.is_installed(self, 'php7.2-fpm')): if not (WOAptGet.is_installed(self, 'php7.3-fpm')): - apt_packages = apt_packages + WOVariables.wo_php + WOVariables.wo_php_extra + apt_packages = apt_packages + WOVariables.wo_php + \ + WOVariables.wo_php_extra else: apt_packages = apt_packages + WOVariables.wo_php else: @@ -1269,7 +1270,8 @@ class WOStackController(CementBaseController): Log.debug(self, "Setting apt_packages variable for PHP 7.3") if not WOAptGet.is_installed(self, 'php7.3-fpm'): if not (WOAptGet.is_installed(self, 'php7.2-fpm')): - apt_packages = apt_packages + WOVariables.wo_php73 + WOVariables.wo_php_extra + apt_packages = apt_packages + WOVariables.wo_php + \ + WOVariables.wo_php73 + WOVariables.wo_php_extra else: apt_packages = apt_packages + WOVariables.wo_php73 else: @@ -1311,8 +1313,11 @@ class WOStackController(CementBaseController): Log.debug(self, "Setting packages variable for phpMyAdmin ") packages = packages + [["https://github.com/phpmyadmin/" "phpmyadmin/archive/STABLE.tar.gz", - "/tmp/pma.tar.gz", "phpMyAdmin"], - ["https://getcomposer.org/installer", + "/tmp/pma.tar.gz", "phpMyAdmin"]] + # Composer + if self.app.pargs.composer: + Log.debug(self, "Setting packages variable for Composer ") + packages = packages + [["https://getcomposer.org/installer", "/tmp/composer-install", "Composer"]] # PHPREDISADMIN if self.app.pargs.phpredisadmin: @@ -1465,6 +1470,7 @@ class WOStackController(CementBaseController): if self.app.pargs.admin: self.app.pargs.adminer = True self.app.pargs.phpmyadmin = True + self.app.pargs.composer = True self.app.pargs.utils = True # NGINX if self.app.pargs.nginx: @@ -1478,7 +1484,8 @@ class WOStackController(CementBaseController): Log.debug(self, "Removing apt_packages variable of PHP") if WOAptGet.is_installed(self, 'php7.2-fpm'): if not WOAptGet.is_installed(self, 'php7.3-fpm'): - apt_packages = apt_packages + WOVariables.wo_php + WOVariables.wo_php_extra + apt_packages = apt_packages + WOVariables.wo_php + \ + WOVariables.wo_php_extra else: apt_packages = apt_packages + WOVariables.wo_php else: @@ -1489,7 +1496,8 @@ class WOStackController(CementBaseController): Log.debug(self, "Removing apt_packages variable of PHP 7.3") if WOAptGet.is_installed(self, 'php7.3-fpm'): if not (WOAptGet.is_installed(self, 'php7.2-fpm')): - apt_packages = apt_packages + WOVariables.wo_php73 + WOVariables.wo_php_extra + apt_packages = apt_packages + WOVariables.wo_php73 + \ + WOVariables.wo_php_extra else: apt_packages = apt_packages + WOVariables.wo_php73 else: From fb3869680676431c106d33b9a0f68d9d32ec7b21 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Mon, 1 Apr 2019 21:15:54 +0200 Subject: [PATCH 10/24] update travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e1898ba..8821465 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,3 +64,4 @@ script: - sudo bash -c 'tar -I pigz -cf wordops.tar.gz /var/log/wo' - sudo curl --progress-bar --upload-file "wordops.tar.gz" https://transfer.vtbox.net/$(basename wordops.tar.gz) && echo "" || sudo echo "transfer.sh is down" - sudo tree -L 2 /etc/nginx + - sudo tree -L 2 /var/www/22222 From 6630fda4f91fa68eb6c409d1a0b9d30d674278f3 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Mon, 1 Apr 2019 22:19:44 +0200 Subject: [PATCH 11/24] fix pma --- wo/cli/plugins/stack.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 70599de..8b02d52 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -1004,9 +1004,9 @@ class WOStackController(CementBaseController): .format(WOVariables.wo_webroot)) os.makedirs('{0}22222/htdocs/db' .format(WOVariables.wo_webroot)) - shutil.move('/tmp/phpmyadmin-STABLE/', - '{0}22222/htdocs/db/pma/' - .format(WOVariables.wo_webroot)) + shutil.move('/tmp/phpmyadmin-STABLE/', + '{0}22222/htdocs/db/pma/' + .format(WOVariables.wo_webroot)) shutil.copyfile('{0}22222/htdocs/db/pma/config.sample.inc.php' .format(WOVariables.wo_webroot), '{0}22222/htdocs/db/pma/config.inc.php' @@ -1223,7 +1223,9 @@ class WOStackController(CementBaseController): self.app.pargs.mysql = True self.app.pargs.adminer = True self.app.pargs.phpmyadmin = True + self.app.pargs.composer = True self.app.pargs.utils = True + self.app.pargs.netdata = True if self.app.pargs.redis: if not WOAptGet.is_installed(self, 'redis-server'): @@ -1258,7 +1260,7 @@ class WOStackController(CementBaseController): if not (WOAptGet.is_installed(self, 'php7.2-fpm')): if not (WOAptGet.is_installed(self, 'php7.3-fpm')): apt_packages = apt_packages + WOVariables.wo_php + \ - WOVariables.wo_php_extra + WOVariables.wo_php_extra else: apt_packages = apt_packages + WOVariables.wo_php else: @@ -1497,7 +1499,7 @@ class WOStackController(CementBaseController): if WOAptGet.is_installed(self, 'php7.3-fpm'): if not (WOAptGet.is_installed(self, 'php7.2-fpm')): apt_packages = apt_packages + WOVariables.wo_php73 + \ - WOVariables.wo_php_extra + WOVariables.wo_php_extra else: apt_packages = apt_packages + WOVariables.wo_php73 else: From 3e928cd43e7ee649c7d9b2826233f18c5072196a Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Tue, 2 Apr 2019 01:59:40 +0200 Subject: [PATCH 12/24] add netdata --- .travis.yml | 2 +- CHANGELOG.md | 2 ++ wo/cli/plugins/stack.py | 31 ++++++++++++++++++++++++++++--- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8821465..dc63fb7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,4 +64,4 @@ script: - sudo bash -c 'tar -I pigz -cf wordops.tar.gz /var/log/wo' - sudo curl --progress-bar --upload-file "wordops.tar.gz" https://transfer.vtbox.net/$(basename wordops.tar.gz) && echo "" || sudo echo "transfer.sh is down" - sudo tree -L 2 /etc/nginx - - sudo tree -L 2 /var/www/22222 + - sudo tree -L 4 /var/www/22222 diff --git a/CHANGELOG.md b/CHANGELOG.md index ed661d9..07c70dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Previous acme.sh certs migration - "wo maintenance" command to perform server package update & cleanup - Support for Netdata on backend : https://server.hostname:22222/netdata/ +- Stack : composer and netdata #### Changed @@ -51,6 +52,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - EasyEngine database sync during migration - command "wo info" - phpmyadmin install with composer +- command "wo clean --memcached" ### v3.9.4 - 2019-03-15 diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 8b02d52..59377b7 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -66,7 +66,8 @@ class WOStackController(CementBaseController): (['--composer'], dict(help='Install Composer stack', action='store_true')), (['--netdata'], - dict(help='Install Netdata monitoring suite', action='store_true')), + dict(help='Install Netdata monitoring suite', + action='store_true')), (['--adminer'], dict(help='Install Adminer stack', action='store_true')), (['--utils'], @@ -1067,6 +1068,17 @@ class WOStackController(CementBaseController): WOVariables.wo_php_user, recursive=True) + if any('/tmp/netdata.tar.gz' == x[1] + for x in packages): + if not os.path.exists('/etc/netdata'): + Log.debug(self, "Extracting netdata.tar.gz to location" + "/usr/src/netdata.git/") + WOExtract.extract(self, '/tmp/netdata.tar.gz', '/tmp/') + WOShellExec.cmd_exec(self, "/tmp/netdata-v1.13.0/" + "netdata-installer.sh " + "--stable-channel " + "--dont-wait") + if any('/tmp/webgrind.tar.gz' == x[1] for x in packages): Log.debug(self, "Extracting file webgrind.tar.gz to " @@ -1333,13 +1345,24 @@ class WOStackController(CementBaseController): # ADMINER if self.app.pargs.adminer: Log.debug(self, "Setting packages variable for Adminer ") - packages = packages + [["https://www.adminer.org/static/download/" - "{0}/adminer-{0}.php" + packages = packages + [["https://www.adminer.org/static/" + "download/{0}/adminer-{0}.php" "".format(WOVariables.wo_adminer), "{0}22222/" "htdocs/db/adminer/index.php" .format(WOVariables.wo_webroot), "Adminer"]] + # Netdata + if self.app.pargs.netdata: + Log.debug(self, "Setting packages variable for Netdata") + if not os.path.exists('/etc/netdata'): + packages = packages + [['https://github.com/' + 'netdata/netdata/releases/' + 'download/v1.13.0/' + 'netdata-v1.13.0.tar.gz', + '/tmp/netdata.tar.gz', + 'netdata']] + # UTILS if self.app.pargs.utils: Log.debug(self, "Setting packages variable for utils") @@ -1453,6 +1476,7 @@ class WOStackController(CementBaseController): (not self.app.pargs.php73) and (not self.app.pargs.mysql) and (not self.app.pargs.wpcli) and (not self.app.pargs.phpmyadmin) and (not self.app.pargs.adminer) and (not self.app.pargs.utils) and + (not self.app.pargs.composer) and (not self.app.pargs.netdata) (not self.app.pargs.all) and (not self.app.pargs.redis) and (not self.app.pargs.phpredisadmin)): self.app.pargs.web = True @@ -1589,6 +1613,7 @@ class WOStackController(CementBaseController): (not self.app.pargs.php73) and (not self.app.pargs.mysql) and (not self.app.pargs.wpcli) and (not self.app.pargs.phpmyadmin) and (not self.app.pargs.adminer) and (not self.app.pargs.utils) and + (not self.app.pargs.composer) and (not self.app.pargs.netdata) (not self.app.pargs.all) and (not self.app.pargs.redis) and (not self.app.pargs.phpredisadmin)): self.app.pargs.web = True From 802c5a5d04e32c664a9835c08ecb6bed911ccaa7 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Wed, 3 Apr 2019 06:59:13 +0200 Subject: [PATCH 13/24] fix wo stack --- wo/cli/plugins/stack.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 59377b7..623e1d1 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -1073,8 +1073,10 @@ class WOStackController(CementBaseController): if not os.path.exists('/etc/netdata'): Log.debug(self, "Extracting netdata.tar.gz to location" "/usr/src/netdata.git/") - WOExtract.extract(self, '/tmp/netdata.tar.gz', '/tmp/') - WOShellExec.cmd_exec(self, "/tmp/netdata-v1.13.0/" + WOExtract.extract(self, '/tmp/netdata.tar.gz', + '/usr/src/netdata.git/') + WOShellExec.cmd_exec(self, "bash /usr/src/netdata.git/" + "netdata-v1.13.0/" "netdata-installer.sh " "--stable-channel " "--dont-wait") @@ -1142,8 +1144,9 @@ class WOStackController(CementBaseController): WOMysql.execute(self, 'grant select on *.* to \'anemometer\'' '@\'{0}\' IDENTIFIED' - ' BY \'{1}\''.format(self.app.config.get('mysql', - 'grant-host'), chars)) + ' BY \'{1}\''.format(self.app.config.get + ('mysql', 'grant-host'), + chars)) Log.debug(self, "grant all on slow-query-log.*" " to anemometer@root_user IDENTIFIED BY password ") WOMysql.execute(self, 'grant all on slow_query_log.* to' @@ -1211,7 +1214,7 @@ class WOStackController(CementBaseController): (not self.app.pargs.nginx) and (not self.app.pargs.php) and (not self.app.pargs.mysql) and (not self.app.pargs.wpcli) and (not self.app.pargs.phpmyadmin) and - (not self.app.pargs.composer) and (not self.app.pargs.netdata) + (not self.app.pargs.composer) and (not self.app.pargs.netdata) and (not self.app.pargs.adminer) and (not self.app.pargs.utils) and (not self.app.pargs.redis) and (not self.app.pargs.phpredisadmin) and @@ -1237,7 +1240,6 @@ class WOStackController(CementBaseController): self.app.pargs.phpmyadmin = True self.app.pargs.composer = True self.app.pargs.utils = True - self.app.pargs.netdata = True if self.app.pargs.redis: if not WOAptGet.is_installed(self, 'redis-server'): @@ -1476,7 +1478,7 @@ class WOStackController(CementBaseController): (not self.app.pargs.php73) and (not self.app.pargs.mysql) and (not self.app.pargs.wpcli) and (not self.app.pargs.phpmyadmin) and (not self.app.pargs.adminer) and (not self.app.pargs.utils) and - (not self.app.pargs.composer) and (not self.app.pargs.netdata) + (not self.app.pargs.composer) and (not self.app.pargs.netdata) and (not self.app.pargs.all) and (not self.app.pargs.redis) and (not self.app.pargs.phpredisadmin)): self.app.pargs.web = True @@ -1613,7 +1615,7 @@ class WOStackController(CementBaseController): (not self.app.pargs.php73) and (not self.app.pargs.mysql) and (not self.app.pargs.wpcli) and (not self.app.pargs.phpmyadmin) and (not self.app.pargs.adminer) and (not self.app.pargs.utils) and - (not self.app.pargs.composer) and (not self.app.pargs.netdata) + (not self.app.pargs.composer) and (not self.app.pargs.netdata) and (not self.app.pargs.all) and (not self.app.pargs.redis) and (not self.app.pargs.phpredisadmin)): self.app.pargs.web = True From af5ce4b69d71fb230b7be5259a2a292858cc2e75 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Wed, 3 Apr 2019 07:07:21 +0200 Subject: [PATCH 14/24] add required package for netdata --- wo/cli/plugins/stack.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 623e1d1..0b45d53 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -1075,6 +1075,11 @@ class WOStackController(CementBaseController): "/usr/src/netdata.git/") WOExtract.extract(self, '/tmp/netdata.tar.gz', '/usr/src/netdata.git/') + WOShellExec.cmd_exec(self, "apt-get install zlib1g-dev " + "uuid-dev libmnl-dev gcc make " + "git autoconf autoconf-archive " + "autogen automake pkg-config " + "curl -y") WOShellExec.cmd_exec(self, "bash /usr/src/netdata.git/" "netdata-v1.13.0/" "netdata-installer.sh " From 8e9a7fabff3a6b5a16a6a9994b5530316d13576e Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Wed, 3 Apr 2019 07:10:46 +0200 Subject: [PATCH 15/24] fix pma --- wo/cli/plugins/stack.py | 53 ++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 0b45d53..9f1f363 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -1005,32 +1005,35 @@ class WOStackController(CementBaseController): .format(WOVariables.wo_webroot)) os.makedirs('{0}22222/htdocs/db' .format(WOVariables.wo_webroot)) - shutil.move('/tmp/phpmyadmin-STABLE/', - '{0}22222/htdocs/db/pma/' - .format(WOVariables.wo_webroot)) - shutil.copyfile('{0}22222/htdocs/db/pma/config.sample.inc.php' - .format(WOVariables.wo_webroot), - '{0}22222/htdocs/db/pma/config.inc.php' + if not os.path.exists('{0}22222/htdocs/db/' + 'pma/phpmyadmin-STABLE' + .format(WOVariables.wo_webroot)): + shutil.move('/tmp/phpmyadmin-STABLE/', + '{0}22222/htdocs/db/pma/' .format(WOVariables.wo_webroot)) - Log.debug(self, 'Setting Blowfish Secret Key FOR COOKIE AUTH to ' - '{0}22222/htdocs/db/pma/config.inc.php file ' - .format(WOVariables.wo_webroot)) - blowfish_key = ''.join([random.choice - (string.ascii_letters + string.digits) - for n in range(25)]) - WOFileUtils.searchreplace(self, - '{0}22222/htdocs/db/pma/config.inc.php' - .format(WOVariables.wo_webroot), - "$cfg[\'blowfish_secret\'] = \'\';", "$cfg[\'blowfish_secret\'] = \'{0}\';" - .format(blowfish_key)) - Log.debug(self, 'Setting HOST Server For Mysql to ' - '{0}22222/htdocs/db/pma/config.inc.php file ' - .format(WOVariables.wo_webroot)) - WOFileUtils.searchreplace(self, - '{0}22222/htdocs/db/pma/config.inc.php' - .format(WOVariables.wo_webroot), - "$cfg[\'Servers\'][$i][\'host\'] = \'localhost\';", "$cfg[\'Servers\'][$i][\'host\'] = \'{0}\';" - .format(WOVariables.wo_mysql_host)) + shutil.copyfile('{0}22222/htdocs/db/pma/config.sample.inc.php' + .format(WOVariables.wo_webroot), + '{0}22222/htdocs/db/pma/config.inc.php' + .format(WOVariables.wo_webroot)) + Log.debug(self, 'Setting Blowfish Secret Key FOR COOKIE AUTH to ' + '{0}22222/htdocs/db/pma/config.inc.php file ' + .format(WOVariables.wo_webroot)) + blowfish_key = ''.join([random.choice + (string.ascii_letters + string.digits) + for n in range(25)]) + WOFileUtils.searchreplace(self, + '{0}22222/htdocs/db/pma/config.inc.php' + .format(WOVariables.wo_webroot), + "$cfg[\'blowfish_secret\'] = \'\';", "$cfg[\'blowfish_secret\'] = \'{0}\';" + .format(blowfish_key)) + Log.debug(self, 'Setting HOST Server For Mysql to ' + '{0}22222/htdocs/db/pma/config.inc.php file ' + .format(WOVariables.wo_webroot)) + WOFileUtils.searchreplace(self, + '{0}22222/htdocs/db/pma/config.inc.php' + .format(WOVariables.wo_webroot), + "$cfg[\'Servers\'][$i][\'host\'] = \'localhost\';", "$cfg[\'Servers\'][$i][\'host\'] = \'{0}\';" + .format(WOVariables.wo_mysql_host)) Log.debug(self, 'Setting Privileges of webroot permission to ' '{0}22222/htdocs/db/pma file ' .format(WOVariables.wo_webroot)) From 71b7ada96e8a2ea07b0b948c0bb10e4fa9693d09 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Wed, 3 Apr 2019 07:15:17 +0200 Subject: [PATCH 16/24] fix other stack shmove --- wo/cli/plugins/stack.py | 52 ++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 9f1f363..02b7ba6 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -1101,9 +1101,11 @@ class WOStackController(CementBaseController): .format(WOVariables.wo_webroot)) os.makedirs('{0}22222/htdocs/php' .format(WOVariables.wo_webroot)) - shutil.move('/tmp/webgrind-master/', - '{0}22222/htdocs/php/webgrind' - .format(WOVariables.wo_webroot)) + if not os.path.exists('{0}22222/htdocs/php/webgrind' + .format(WOVariables.wo_webroot)): + shutil.move('/tmp/webgrind-master/', + '{0}22222/htdocs/php/webgrind' + .format(WOVariables.wo_webroot)) WOFileUtils.searchreplace(self, "{0}22222/htdocs/php/webgrind/" "config.php" @@ -1139,16 +1141,18 @@ class WOStackController(CementBaseController): Log.debug(self, "Creating directory") os.makedirs('{0}22222/htdocs/db/' .format(WOVariables.wo_webroot)) - shutil.move('/tmp/Anemometer-master', - '{0}22222/htdocs/db/anemometer' - .format(WOVariables.wo_webroot)) - chars = ''.join(random.sample(string.ascii_letters, 8)) - try: - WOShellExec.cmd_exec(self, 'mysql < {0}22222/htdocs/db' - '/anemometer/install.sql' - .format(WOVariables.wo_webroot)) - except CommandExecutionError as e: - raise SiteError("Unable to import Anemometer database") + if not os.path.exists('{0}22222/htdocs/db/anemometer' + .format(WOVariables.wo_webroot)): + shutil.move('/tmp/Anemometer-master', + '{0}22222/htdocs/db/anemometer' + .format(WOVariables.wo_webroot)) + chars = ''.join(random.sample(string.ascii_letters, 8)) + try: + WOShellExec.cmd_exec(self, 'mysql < {0}22222/htdocs/db' + '/anemometer/install.sql' + .format(WOVariables.wo_webroot)) + except CommandExecutionError as e: + raise SiteError("Unable to import Anemometer database") WOMysql.execute(self, 'grant select on *.* to \'anemometer\'' '@\'{0}\' IDENTIFIED' @@ -1192,16 +1196,20 @@ class WOStackController(CementBaseController): .format(WOVariables.wo_webroot)) os.makedirs('{0}22222/htdocs/cache/redis' .format(WOVariables.wo_webroot)) - shutil.move('/tmp/phpRedisAdmin-master/', - '{0}22222/htdocs/cache/redis/phpRedisAdmin' - .format(WOVariables.wo_webroot)) + if not os.path.exists('{0}22222/htdocs/cache/' + 'redis/phpRedisAdmin' + .format(WOVariables.wo_webroot)): + shutil.move('/tmp/phpRedisAdmin-master/', + '{0}22222/htdocs/cache/redis/phpRedisAdmin' + .format(WOVariables.wo_webroot)) - Log.debug(self, 'Extracting file /tmp/predis.tar.gz to ' - 'loaction /tmp/') - WOExtract.extract(self, '/tmp/predis.tar.gz', '/tmp/') - shutil.move('/tmp/predis-1.0.1/', - '{0}22222/htdocs/cache/redis/phpRedisAdmin/vendor' - .format(WOVariables.wo_webroot)) + Log.debug(self, 'Extracting file /tmp/predis.tar.gz to ' + 'loaction /tmp/') + WOExtract.extract(self, '/tmp/predis.tar.gz', '/tmp/') + shutil.move('/tmp/predis-1.0.1/', + '{0}22222/htdocs/cache/redis/' + 'phpRedisAdmin/vendor' + .format(WOVariables.wo_webroot)) Log.debug(self, 'Setting Privileges of webroot permission to ' '{0}22222/htdocs/cache/ file ' From 2c8b03ac5c05180fe6c4f73bc567b3ba52aad1ce Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Wed, 3 Apr 2019 07:19:26 +0200 Subject: [PATCH 17/24] fix chars variable --- wo/cli/plugins/stack.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 02b7ba6..cb50bd9 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -1154,19 +1154,21 @@ class WOStackController(CementBaseController): except CommandExecutionError as e: raise SiteError("Unable to import Anemometer database") - WOMysql.execute(self, 'grant select on *.* to \'anemometer\'' - '@\'{0}\' IDENTIFIED' - ' BY \'{1}\''.format(self.app.config.get - ('mysql', 'grant-host'), - chars)) - Log.debug(self, "grant all on slow-query-log.*" - " to anemometer@root_user IDENTIFIED BY password ") - WOMysql.execute(self, 'grant all on slow_query_log.* to' - '\'anemometer\'@\'{0}\' IDENTIFIED' - ' BY \'{1}\''.format(self.app.config.get( - 'mysql', 'grant-host'), - chars), - errormsg="cannot grant priviledges", log=False) + WOMysql.execute(self, 'grant select on' + ' *.* to \'anemometer\'' + '@\'{0}\' IDENTIFIED' + ' BY \'{1}\''.format(self.app.config.get + ('mysql', 'grant-host'), + chars)) + Log.debug(self, "grant all on slow-query-log.*" + " to anemometer@root_user" + " IDENTIFIED BY password ") + WOMysql.execute(self, 'grant all on slow_query_log.* to' + '\'anemometer\'@\'{0}\' IDENTIFIED' + ' BY \'{1}\''.format(self.app.config.get( + 'mysql', 'grant-host'), + chars), + errormsg="cannot grant priviledges", log=False) # Custom Anemometer configuration Log.debug(self, "configration Anemometer") From 5e27ada4abeec9e62493f2347f6a4092a316ca67 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Wed, 3 Apr 2019 07:22:59 +0200 Subject: [PATCH 18/24] fix chars --- wo/cli/plugins/stack.py | 44 ++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index cb50bd9..4654159 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -1146,29 +1146,29 @@ class WOStackController(CementBaseController): shutil.move('/tmp/Anemometer-master', '{0}22222/htdocs/db/anemometer' .format(WOVariables.wo_webroot)) - chars = ''.join(random.sample(string.ascii_letters, 8)) - try: - WOShellExec.cmd_exec(self, 'mysql < {0}22222/htdocs/db' - '/anemometer/install.sql' - .format(WOVariables.wo_webroot)) - except CommandExecutionError as e: - raise SiteError("Unable to import Anemometer database") + chars = ''.join(random.sample(string.ascii_letters, 8)) + try: + WOShellExec.cmd_exec(self, 'mysql < {0}22222/htdocs/db' + '/anemometer/install.sql' + .format(WOVariables.wo_webroot)) + except CommandExecutionError as e: + raise SiteError("Unable to import Anemometer database") - WOMysql.execute(self, 'grant select on' - ' *.* to \'anemometer\'' - '@\'{0}\' IDENTIFIED' - ' BY \'{1}\''.format(self.app.config.get - ('mysql', 'grant-host'), - chars)) - Log.debug(self, "grant all on slow-query-log.*" - " to anemometer@root_user" - " IDENTIFIED BY password ") - WOMysql.execute(self, 'grant all on slow_query_log.* to' - '\'anemometer\'@\'{0}\' IDENTIFIED' - ' BY \'{1}\''.format(self.app.config.get( - 'mysql', 'grant-host'), - chars), - errormsg="cannot grant priviledges", log=False) + WOMysql.execute(self, 'grant select on' + ' *.* to \'anemometer\'' + '@\'{0}\' IDENTIFIED' + ' BY \'{1}\''.format(self.app.config.get + ('mysql', 'grant-host'), + chars)) + Log.debug(self, "grant all on slow-query-log.*" + " to anemometer@root_user" + " IDENTIFIED BY password ") + WOMysql.execute(self, 'grant all on slow_query_log.* to' + '\'anemometer\'@\'{0}\' IDENTIFIED' + ' BY \'{1}\''.format(self.app.config.get( + 'mysql', 'grant-host'), + chars), + errormsg="cannot grant priviledges", log=False) # Custom Anemometer configuration Log.debug(self, "configration Anemometer") From 4f6df9862bc0ae8f831d6165133f28eefd678e9e Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Wed, 3 Apr 2019 07:27:11 +0200 Subject: [PATCH 19/24] another fix for anemometer --- wo/cli/plugins/stack.py | 66 ++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 4654159..5148547 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -1146,41 +1146,41 @@ class WOStackController(CementBaseController): shutil.move('/tmp/Anemometer-master', '{0}22222/htdocs/db/anemometer' .format(WOVariables.wo_webroot)) - chars = ''.join(random.sample(string.ascii_letters, 8)) - try: - WOShellExec.cmd_exec(self, 'mysql < {0}22222/htdocs/db' - '/anemometer/install.sql' - .format(WOVariables.wo_webroot)) - except CommandExecutionError as e: - raise SiteError("Unable to import Anemometer database") + chars = ''.join(random.sample(string.ascii_letters, 8)) + try: + WOShellExec.cmd_exec(self, 'mysql < {0}22222/htdocs/db' + '/anemometer/install.sql' + .format(WOVariables.wo_webroot)) + except CommandExecutionError as e: + raise SiteError("Unable to import Anemometer database") - WOMysql.execute(self, 'grant select on' - ' *.* to \'anemometer\'' - '@\'{0}\' IDENTIFIED' - ' BY \'{1}\''.format(self.app.config.get - ('mysql', 'grant-host'), - chars)) - Log.debug(self, "grant all on slow-query-log.*" - " to anemometer@root_user" - " IDENTIFIED BY password ") - WOMysql.execute(self, 'grant all on slow_query_log.* to' - '\'anemometer\'@\'{0}\' IDENTIFIED' - ' BY \'{1}\''.format(self.app.config.get( - 'mysql', 'grant-host'), - chars), - errormsg="cannot grant priviledges", log=False) + WOMysql.execute(self, 'grant select on' + ' *.* to \'anemometer\'' + '@\'{0}\' IDENTIFIED' + ' BY \'{1}\''.format(self.app.config.get + ('mysql', 'grant-host'), + chars)) + Log.debug(self, "grant all on slow-query-log.*" + " to anemometer@root_user" + " IDENTIFIED BY password ") + WOMysql.execute(self, 'grant all on slow_query_log.* to' + '\'anemometer\'@\'{0}\' IDENTIFIED' + ' BY \'{1}\''.format(self.app.config.get( + 'mysql', 'grant-host'), + chars), + errormsg="cannot grant priviledges", log=False) - # Custom Anemometer configuration - Log.debug(self, "configration Anemometer") - data = dict(host=WOVariables.wo_mysql_host, port='3306', - user='anemometer', password=chars) - wo_anemometer = open('{0}22222/htdocs/db/anemometer' - '/conf/config.inc.php' - .format(WOVariables.wo_webroot), - encoding='utf-8', mode='w') - self.app.render((data), 'anemometer.mustache', - out=wo_anemometer) - wo_anemometer.close() + # Custom Anemometer configuration + Log.debug(self, "configration Anemometer") + data = dict(host=WOVariables.wo_mysql_host, port='3306', + user='anemometer', password=chars) + wo_anemometer = open('{0}22222/htdocs/db/anemometer' + '/conf/config.inc.php' + .format(WOVariables.wo_webroot), + encoding='utf-8', mode='w') + self.app.render((data), 'anemometer.mustache', + out=wo_anemometer) + wo_anemometer.close() if any('/usr/bin/pt-query-advisor' == x[1] for x in packages): From 4b69122aafebb63356fa76224bf0073e54314e62 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Wed, 3 Apr 2019 07:41:29 +0200 Subject: [PATCH 20/24] add netdata to admin stack --- wo/cli/plugins/stack.py | 1 + 1 file changed, 1 insertion(+) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 5148547..efa6630 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -1258,6 +1258,7 @@ class WOStackController(CementBaseController): self.app.pargs.phpmyadmin = True self.app.pargs.composer = True self.app.pargs.utils = True + self.app.pargs.netdata = True if self.app.pargs.redis: if not WOAptGet.is_installed(self, 'redis-server'): From c8cd2e95fc385f8f44c7a8f43a594802eabc19c8 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Wed, 3 Apr 2019 07:53:25 +0200 Subject: [PATCH 21/24] change netdata install method --- wo/cli/plugins/stack.py | 43 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index efa6630..03766ff 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -1070,25 +1070,6 @@ class WOStackController(CementBaseController): WOVariables.wo_php_user, WOVariables.wo_php_user, recursive=True) - - if any('/tmp/netdata.tar.gz' == x[1] - for x in packages): - if not os.path.exists('/etc/netdata'): - Log.debug(self, "Extracting netdata.tar.gz to location" - "/usr/src/netdata.git/") - WOExtract.extract(self, '/tmp/netdata.tar.gz', - '/usr/src/netdata.git/') - WOShellExec.cmd_exec(self, "apt-get install zlib1g-dev " - "uuid-dev libmnl-dev gcc make " - "git autoconf autoconf-archive " - "autogen automake pkg-config " - "curl -y") - WOShellExec.cmd_exec(self, "bash /usr/src/netdata.git/" - "netdata-v1.13.0/" - "netdata-installer.sh " - "--stable-channel " - "--dont-wait") - if any('/tmp/webgrind.tar.gz' == x[1] for x in packages): Log.debug(self, "Extracting file webgrind.tar.gz to " @@ -1232,7 +1213,8 @@ class WOStackController(CementBaseController): (not self.app.pargs.nginx) and (not self.app.pargs.php) and (not self.app.pargs.mysql) and (not self.app.pargs.wpcli) and (not self.app.pargs.phpmyadmin) and - (not self.app.pargs.composer) and (not self.app.pargs.netdata) and + (not self.app.pargs.composer) and + (not self.app.pargs.netdata) and (not self.app.pargs.adminer) and (not self.app.pargs.utils) and (not self.app.pargs.redis) and (not self.app.pargs.phpredisadmin) and @@ -1280,8 +1262,10 @@ class WOStackController(CementBaseController): apt = ["nginx-plus"] + WOVariables.wo_nginx self.post_pref(apt, packages) elif WOAptGet.is_installed(self, 'nginx'): - Log.info(self, "WordOps detected an already installed nginx package." - "It may or may not have required modules.\n") + Log.info(self, "WordOps detected an already " + "installed nginx package." + "It may or may not have " + "required modules.\n") apt = ["nginx"] + WOVariables.wo_nginx self.post_pref(apt, packages) else: @@ -1376,13 +1360,14 @@ class WOStackController(CementBaseController): # Netdata if self.app.pargs.netdata: Log.debug(self, "Setting packages variable for Netdata") - if not os.path.exists('/etc/netdata'): - packages = packages + [['https://github.com/' - 'netdata/netdata/releases/' - 'download/v1.13.0/' - 'netdata-v1.13.0.tar.gz', - '/tmp/netdata.tar.gz', - 'netdata']] + if not os.path.exists('/opt/netdata'): + packages = packages + [['https://my-netdata.io/' + 'kickstart.sh', + '/tmp/kickstart.sh', + 'Netdata']] + WOShellExec.cmd_exec( + self, "bash /tmp/kickstart.sh " + "--dont-wait --no-updates") # UTILS if self.app.pargs.utils: From a2973ee96ae75c87949376801792efa0e4905d61 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Wed, 3 Apr 2019 07:57:36 +0200 Subject: [PATCH 22/24] fix netdata --- wo/cli/plugins/stack.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 03766ff..75703c8 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -1042,7 +1042,7 @@ class WOStackController(CementBaseController): WOVariables.wo_php_user, WOVariables.wo_php_user, recursive=True) - + # composer install and phpmyadmin update if any('/tmp/composer-install' == x[1] for x in packages): WOShellExec.cmd_exec(self, "php -q /tmp/composer-install " @@ -1053,6 +1053,12 @@ class WOStackController(CementBaseController): WOShellExec.cmd_exec(self, "sudo -u www-data -H composer " "update --no-dev -d " "/var/www/22222/htdocs/db/pma/") + # netdata install + if any('/tmp/kickstart.sh' == x[1] + for x in packages): + if not os.path.exists('/etc/netdata'): + WOShellExec.cmd_exec(self, "bash /tmp/kickstart.sh " + "--dont-wait --no-updates") if any('/tmp/memcached.tar.gz' == x[1] for x in packages): @@ -1365,9 +1371,6 @@ class WOStackController(CementBaseController): 'kickstart.sh', '/tmp/kickstart.sh', 'Netdata']] - WOShellExec.cmd_exec( - self, "bash /tmp/kickstart.sh " - "--dont-wait --no-updates") # UTILS if self.app.pargs.utils: From 95a64fa1232f7f9297fbfa3a910f125b020ef3af Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Wed, 3 Apr 2019 08:05:01 +0200 Subject: [PATCH 23/24] disable netdata mail notification --- wo/cli/plugins/stack.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 75703c8..2699c52 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -1059,6 +1059,11 @@ class WOStackController(CementBaseController): if not os.path.exists('/etc/netdata'): WOShellExec.cmd_exec(self, "bash /tmp/kickstart.sh " "--dont-wait --no-updates") + WOFileUtils.searchreplace(self, "/usr/lib/netdata/conf.d/" + "health_alarm_notify.conf", + 'SEND_EMAIL="YES"', + 'SEND_EMAIL="NO"') + WOService.restart_service(self, 'netdata') if any('/tmp/memcached.tar.gz' == x[1] for x in packages): From d988d8b6af01f68afc60a36f8955b1e6f2bc952e Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Wed, 3 Apr 2019 11:32:35 +0200 Subject: [PATCH 24/24] fix wo info --- .travis.yml | 1 - CHANGELOG.md | 4 ++-- install | 4 ++-- wo/cli/plugins/info.py | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index dc63fb7..e1898ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,4 +64,3 @@ script: - sudo bash -c 'tar -I pigz -cf wordops.tar.gz /var/log/wo' - sudo curl --progress-bar --upload-file "wordops.tar.gz" https://transfer.vtbox.net/$(basename wordops.tar.gz) && echo "" || sudo echo "transfer.sh is down" - sudo tree -L 2 /etc/nginx - - sudo tree -L 4 /var/www/22222 diff --git a/CHANGELOG.md b/CHANGELOG.md index 07c70dc..6ed4b35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Previous acme.sh certs migration - "wo maintenance" command to perform server package update & cleanup - Support for Netdata on backend : https://server.hostname:22222/netdata/ -- Stack : composer and netdata +- New Stacks : composer and netdata #### Changed @@ -50,7 +50,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - PHP 7.2 & PHP 7.3 pool configuration during upgrade - WordOps backup directory creation before upgrade - EasyEngine database sync during migration -- command "wo info" +- fix command "wo info" - phpmyadmin install with composer - command "wo clean --memcached" diff --git a/install b/install index 518e345..213832c 100644 --- a/install +++ b/install @@ -145,10 +145,10 @@ wo_install_dep() { { if [ "$wo_linux_distro" == "Ubuntu" ]; then - DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confmiss" -o Dpkg::Options::="--force-confold" -y install build-essential curl gzip python3 python3-apt python3-setuptools python3-dev sqlite3 git tar software-properties-common pigz gnupg2 fail2ban cron ccze rsync tree > /dev/null 2>&1 + DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confmiss" -o Dpkg::Options::="--force-confold" -y install build-essential curl gzip python3 python3-apt python3-setuptools python3-dev sqlite3 git tar software-properties-common pigz gnupg2 fail2ban cron ccze rsync tree haveged ufw > /dev/null 2>&1 else wget -qO /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg - DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confmiss" -o Dpkg::Options::="--force-confold" -y install build-essential curl gzip dirmngr sudo python3 python3-apt python3-setuptools python3-dev ca-certificates sqlite3 git tar software-properties-common pigz apt-transport-https gnupg2 fail2ban cron ccze rsync tree > /dev/null 2>&1 + DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confmiss" -o Dpkg::Options::="--force-confold" -y install build-essential curl gzip dirmngr sudo python3 python3-apt python3-setuptools python3-dev ca-certificates sqlite3 git tar software-properties-common pigz apt-transport-https gnupg2 fail2ban cron ccze rsync tree haveged ufw > /dev/null 2>&1 fi locale-gen en diff --git a/wo/cli/plugins/info.py b/wo/cli/plugins/info.py index 4f0025f..d20d5a6 100644 --- a/wo/cli/plugins/info.py +++ b/wo/cli/plugins/info.py @@ -252,7 +252,7 @@ class WOInfoController(CementBaseController): if self.app.pargs.nginx: if (WOAptGet.is_installed(self, 'nginx-custom') or - WOAptGet.is_installed(self, 'nginx-common')): + WOAptGet.is_installed(self, 'nginx-wo')): self.info_nginx() else: Log.error(self, "Nginx is not installed")