diff --git a/.travis.yml b/.travis.yml index 3356f34..5cb4b30 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ script: - sudo echo "Travis Banch = $TRAVIS_BRANCH" - sudo apt-get install -y --force-yes git python3-setuptools python3-dev python3-apt ccze tree - sudo bash install -b $TRAVIS_BRANCH --travis - - sudo wo --help && sudo wo stack install + - sudo wo --help && sudo wo stack install && sudo stack install --proftpd - sudo wo stack upgrade --netdata --no-prompt - sudo wo site create html.net --html && sudo wo site create php.com --php && sudo wo site create mysql.com --mysql && sudo wo site create proxy.com --proxy=127.0.0.1:3000 - sudo wo site create wp1.com --wp && sudo wo site create wpsc1.net --wpsc && sudo wo site create wpfc1.com --wpfc @@ -48,5 +48,7 @@ script: - sudo wp --allow-root --info - sudo wo info - sudo tree -L 2 /etc/nginx + - sudo cat /var/www/wp1.com/wp-config.php - sudo wo update --travis + - sudo wo stack remove --netdata --proftpd -- - sudo wo stack status \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index cbdbc6d..cb3e92c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,8 +18,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Support for Debian 10 buster (testing - not ready for production) - Fail2ban with custom jails to secure WordPress & SSH - Variable `keylength` in /etc/wo/wo.conf to define letsencrypt certificate keylenght -- ProFTPd stack with UFW & Fail2ban configuration +- ProFTPd stack with UFW & Fail2ban configurationz - Beta branch and command `wo update --beta` for beta releases +- Extra directives in wp-config.php (limit posts revisions, set max_memory, enable auto-update for minor-releases) #### Fixed diff --git a/wo/cli/plugins/site_functions.py b/wo/cli/plugins/site_functions.py index 94ca80f..995b648 100644 --- a/wo/cli/plugins/site_functions.py +++ b/wo/cli/plugins/site_functions.py @@ -327,11 +327,44 @@ def setupwordpress(self, data): raise SiteError("generate wp-config failed for wp single site") except CommandExecutionError as e: raise SiteError("generate wp-config failed for wp single site") + try: - WOShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root " - .format(WOVariables.wo_wpcli_path) + - "config set WP_CACHE_KEY_SALT " - "\'{0}:\'\"".format(wo_domain_name)) + WOShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root " + .format(WOVariables.wo_wpcli_path) + + "config set WP_CACHE_KEY_SALT " + "\'{0}:\'\"".format(wo_domain_name)) + + WOShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root " + .format(WOVariables.wo_wpcli_path) + + "config set WP_MEMORY_LIMIT " + "\'128M\'\"") + WOShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root " + .format(WOVariables.wo_wpcli_path) + + "config set WP_MAX_MEMORY_LIMIT " + "\'256M\'\"") + WOShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root " + .format(WOVariables.wo_wpcli_path) + + "config set CONCATENATE_SCRIPTS " + "false\"") + WOShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root " + .format(WOVariables.wo_wpcli_path) + + "config set WP_POST_REVISIONS " + "\'10\'\"") + WOShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root " + .format(WOVariables.wo_wpcli_path) + + "config set MEDIA_TRASH " + "true\"") + WOShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root " + .format(WOVariables.wo_wpcli_path) + + "config set EMPTY_TRASH_DAYS " + "\'15\'\"") + WOShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root " + .format(WOVariables.wo_wpcli_path) + + "config set WP_AUTO_UPDATE_CORE " + "minor\"") + + except CommandExecutionError as e: + Log.error(self, "Unable to define extra variable in wp-config.php") else: Log.debug(self, "Generating wp-config for WordPress multisite") @@ -373,10 +406,44 @@ def setupwordpress(self, data): except CommandExecutionError as e: raise SiteError("generate wp-config failed for wp multi site") - WOShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root " - .format(WOVariables.wo_wpcli_path) + - "config set WP_CACHE_KEY_SALT " - "\'{0}:\'\"".format(wo_domain_name)) + try: + + WOShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root " + .format(WOVariables.wo_wpcli_path) + + "config set WP_CACHE_KEY_SALT " + "\'{0}:\'\"".format(wo_domain_name)) + + WOShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root " + .format(WOVariables.wo_wpcli_path) + + "config set WP_MEMORY_LIMIT " + "\'128M\'\"") + WOShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root " + .format(WOVariables.wo_wpcli_path) + + "config set WP_MAX_MEMORY_LIMIT " + "\'256M\'\"") + WOShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root " + .format(WOVariables.wo_wpcli_path) + + "config set CONCATENATE_SCRIPTS " + "false\"") + WOShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root " + .format(WOVariables.wo_wpcli_path) + + "config set WP_POST_REVISIONS " + "\'10\'\"") + WOShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root " + .format(WOVariables.wo_wpcli_path) + + "config set MEDIA_TRASH " + "true\"") + WOShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root " + .format(WOVariables.wo_wpcli_path) + + "config set EMPTY_TRASH_DAYS " + "\'15\'\"") + WOShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root " + .format(WOVariables.wo_wpcli_path) + + "config set WP_AUTO_UPDATE_CORE " + "minor\"") + + except CommandExecutionError as e: + Log.error(self, "Unable to define extra variable in wp-config.php") # WOFileUtils.mvfile(self, os.getcwd()+'/wp-config.php', # os.path.abspath(os.path.join(os.getcwd(), os.pardir))) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index ec1db13..f318bee 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -1613,12 +1613,22 @@ class WOStackController(CementBaseController): "phpmyadmin/archive/STABLE.tar.gz", "/var/lib/wo/tmp/pma.tar.gz", "phpMyAdmin"]] + else: + Log.debug(self, "phpMyAdmin already installed") + Log.info(self, "phpMyAdmin already installed") + # Composer if self.app.pargs.composer: - Log.debug(self, "Setting packages variable for Composer ") - packages = packages + [["https://getcomposer.org/installer", - "/var/lib/wo/tmp/composer-install", - "Composer"]] + if not os.path.isfile('/usr/local/bin/composer'): + Log.debug(self, "Setting packages variable for Composer ") + packages = packages + [["https://getcomposer.org/" + "installer", + "/var/lib/wo/tmp/composer-install", + "Composer"]] + else: + Log.debug(self, "Composer already installed") + Log.info(self, "Composer already installed") + # PHPREDISADMIN if self.app.pargs.phpredisadmin: if not os.path.isdir('/var/www/22222/htdocs/cache/redis'): @@ -1631,11 +1641,17 @@ class WOStackController(CementBaseController): "/v1.11.3.tar.gz", "/var/lib/wo/tmp/pra.tar.gz", "phpRedisAdmin"]] + else: + Log.debug(self, "phpRedisAdmin already installed") + Log.info(self, "phpRedisAdmin already installed") + # ADMINER if self.app.pargs.adminer: - Log.debug(self, "Setting packages variable for Adminer ") - packages = packages + [["https://github.com/vrana/adminer/" - "releases/download/v{0}" + if not os.path.isdir('{0}22222/htdocs/db/adminer' + .format(WOVariables.wo_webroot)): + Log.debug(self, "Setting packages variable for Adminer ") + packages = packages + [["https://github.com/vrana/adminer/" + "releases/download/v{0}" "/adminer-{0}.php" .format(WOVariables.wo_adminer), "{0}22222/" @@ -1646,9 +1662,12 @@ class WOStackController(CementBaseController): "/vrana/adminer/master/designs/" "pepa-linha/adminer.css", "{0}22222/" - "htdocs/db/adminer/adminer.css" - .format(WOVariables.wo_webroot), - "Adminer theme"]] + "htdocs/db/adminer/adminer.css" + .format(WOVariables.wo_webroot), + "Adminer theme"]] + else: + Log.debug(self, "Adminer already installed") + Log.info(self, "Adminer already installed") # Netdata if self.app.pargs.netdata: @@ -1658,6 +1677,9 @@ class WOStackController(CementBaseController): 'kickstart-static64.sh', '/var/lib/wo/tmp/kickstart.sh', 'Netdata']] + else: + Log.debug(self, "Netdata already installed") + Log.info(self, "Netdata already installed") # WordOps Dashboard if self.app.pargs.dashboard: @@ -1674,6 +1696,9 @@ class WOStackController(CementBaseController): "extplorer/archive/v2.1.11.tar.gz", "/var/lib/wo/tmp/extplorer.tar.gz", "eXtplorer"]] + else: + Log.debug(self, "WordOps dashboard already installed") + Log.info(self, "WordOps dashboard already installed") # UTILS if self.app.pargs.utils: