diff --git a/.travis.yml b/.travis.yml index 28ce07f..a0d2dbf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,3 +55,5 @@ script: - sudo wo info || sudo tail -n50 /var/log/wo/wordops.log - sudo tree -L 2 /etc/nginx - sudo cat /var/www/wpredis.net/wp-config.php + - echo "127.0.0.1 wpredis.net" | sudo tee -a /etc/hosts + - curl -sL http://wpredis.net/robots.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index e6d7734..3cda1f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,24 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### v3.9.6 - [Unreleased] +### v3.9.5.2 - 2019-06-17 + +#### Added + +- Non-interactive install/upgrade +- Argument `--force` with the command `wo update` +- Argument `-s|--silent` to perform non interactive installation + +#### Changed + +- robots.txt location block moved from locations-wo.conf to wpcommon(-php7).php + #### Fixed -- WP_CACHE_KEY_SALT set twice +- WP_CACHE_KEY_SALT set twice with wpredis +- WordOps version check when using `wo update` +- robots.txt file download if not created +- PHP-FPM socket path in stub_status.conf : PR [#82](https://github.com/WordOps/WordOps/pull/82) ### v3.9.5.1 - 2019-05-10 diff --git a/install b/install index a1eccd5..1c73fdc 100755 --- a/install +++ b/install @@ -7,10 +7,10 @@ # Copyright (c) 2019 - WordOps # This script is licensed under M.I.T # ------------------------------------------------------------------------- -# Version 3.9.5.1 - 2019-05-10 +# Version 3.9.5.2 - 2019-06-17 # ------------------------------------------------------------------------- readonly wo_version_old="2.2.3" -readonly wo_version_new="3.9.5.1" +readonly wo_version_new="3.9.5.2" # CONTENTS # --- # 1. VARIABLES AND DECLARATIONS @@ -70,6 +70,9 @@ while [ "$#" -gt 0 ]; do --travis) wo_travis="y" ;; + -s | --silent) + wo_silent="y" + ;; *) # positional args ;; esac @@ -193,21 +196,7 @@ wo_install_dep() { locale-gen en } >> "$wo_install_log" 2>&1 - # Support PFS - # if [ -f /etc/nginx/nginx.conf ]; then - # # Replace previous ciphers - # new_ciphers="EECDH+CHACHA20:EECDH+AESGCM:EECDH+AES" - # sed -i "s/ssl_ciphers\ \(\"\|.\|'\)\(.*\)\(\"\|.\|'\);/ssl_ciphers \"$new_ciphers\";/" /etc/nginx/nginx.conf - # # Change the TLS protocols - # sed -i "s/ssl_protocols\ \(.*\);/ssl_protocols TLSv1.2;/" /etc/nginx/nginx.conf - # fi - # # Let's Encrypt .well-known folder setup - # if [ ! -d /var/www/html/.well-known/acme-challenge ]; then - # mkdir -p /var/www/html/.well-known/acme-challenge - # chown -R www-data:www-data /var/www/html /var/www/html/.well-known - # chmod 750 /var/www/html /var/www/html/.well-known - # fi } ### @@ -380,7 +369,7 @@ wo_install_acme_sh() { --config-home /etc/letsencrypt/config \ --cert-home /etc/letsencrypt/renewal # enable auto-upgrade - /etc/letsencrypt/acme.sh --config-home /etc/letsencrypt/config --upgrade --auto-upgrade + /etc/letsencrypt/acme.sh --config-home '/etc/letsencrypt/config' --upgrade --auto-upgrade } >> "$wo_install_log" 2>&1 fi @@ -427,6 +416,9 @@ wo_install() { fi cd /tmp/WordOps || exit 1 } >> "$wo_install_log" 2>&1 + if [ "$wo_silent" = "y" ] || [ "$wo_force_install" = "y" ]; then + [ ! -f $HOME/.gitconfig ] && { bash -c 'echo -e "[user]\n\tname = $USER\n\temail = root@$HOSTNAME" > $HOME/.gitconfig'; } + fi python3 setup.py install } @@ -435,7 +427,7 @@ wo_upgrade_nginx() { { if [ -d /var/lib/wo-backup/nginx ]; then - tar -I pigz "$NGINX_BACKUP_FILE" /var/lib/wo-backup/nginx + /bin/tar -I pigz "$NGINX_BACKUP_FILE" /var/lib/wo-backup/nginx rm -rf /var/lib/wo-backup/nginx fi # backup nginx conf @@ -464,7 +456,7 @@ wo_upgrade_nginx() { # import the respository key for updates apt-key add - < /tmp/nginx-wo.key rm -f /tmp/nginx-wo.key - sudo apt-get update + sudo apt-get update -qq if [ -f /etc/nginx/common/release ]; then CHECK_NGINX_UPSTREAM_VERSION=$(grep "$wo_version_new" /etc/nginx/common/release) @@ -508,7 +500,7 @@ wo_upgrade_nginx() { else WO WO_STACK_INSTALL_ARGS="" fi - /usr/local/bin/wo stack install --nginx --php $WO_STACK_INSTALL_ARGS + /usr/local/bin/wo stack install --nginx --php "$WO_STACK_INSTALL_ARGS" echo "$wo_version_new" > /etc/nginx/common/release rm -f /etc/nginx/common/acl.conf /etc/nginx/conf.d/{map-wp-cache.conf,map-wp.conf} fi @@ -681,8 +673,12 @@ wo_tweak_kernel() { if [ -x /usr/local/bin/wo ]; then if ! { wo -v 2>&1 | grep $wo_version_new - }; then - echo -e "Update WordOps to $wo_version_new (y/n): " && read -r WO_ANSWER + } || [ "$wo_force_install" = "y" ]; then + if [ -z "$wo_silent" ] && [ -z "$wo_force_install" ]; then + echo -e "Update WordOps to $wo_version_new (y/n): " && read -r WO_ANSWER + else + WO_ANSWER="y" + fi if [ "$WO_ANSWER" = "y" ] || [ "$WO_ANSWER" = "Y" ]; then wo_lib_echo "Installing wo dependencies " | tee -ai $wo_install_log wo_install_dep | tee -ai $wo_install_log @@ -717,7 +713,11 @@ if [ -x /usr/local/bin/wo ]; then else # 2 - Migration from EEv3 if [ -x /usr/local/bin/ee ]; then - echo -e "Migrate from EasyEngine to WordOps (y/n): " && read -r WO_ANSWER + if [ -z "$wo_silent" ] && [ -z "$wo_force_install" ]; then + echo -e "Migrate from EasyEngine to WordOps (y/n): " && read -r WO_ANSWER + else + WO_ANSWER="y" + fi if [ "$WO_ANSWER" = "y" ] || [ "$WO_ANSWER" = "Y" ]; then wo_lib_echo "Installing wo dependencies " | tee -ai $wo_install_log wo_install_dep | tee -ai $wo_install_log diff --git a/setup.py b/setup.py index c302674..ed36b82 100644 --- a/setup.py +++ b/setup.py @@ -57,7 +57,7 @@ if not os.path.isfile('/root/.gitconfig'): shutil.copy2(os.path.expanduser("~")+'/.gitconfig', '/root/.gitconfig') setup(name='wo', - version='3.9.5', + version='3.9.5.2', description=long_description, long_description=long_description, classifiers=[], diff --git a/wo/cli/plugins/site.py b/wo/cli/plugins/site.py index 6c27262..73944c5 100644 --- a/wo/cli/plugins/site.py +++ b/wo/cli/plugins/site.py @@ -4,6 +4,7 @@ from cement.core import handler, hook from wo.core.cron import WOCron from wo.core.sslutils import SSL from wo.core.variables import WOVariables +from wo.core.shellexec import WOShellExec from wo.core.domainvalidate import ValidateDomain from wo.core.fileutils import WOFileUtils from wo.cli.plugins.site_functions import * @@ -1610,42 +1611,25 @@ class WOSiteUpdateController(CementBaseController): if oldcachetype != 'wpredis' and data['wpredis']: try: if installwp_plugin(self, 'redis-cache', data): - # search for wp-config.php - if WOFileUtils.isexist(self, "{0}/wp-config.php" - .format(wo_site_webroot)): - config_path = '{0}/wp-config.php'.format( - wo_site_webroot) - elif WOFileUtils.isexist(self, "{0}/htdocs/wp-config.php" - .format(wo_site_webroot)): - config_path = '{0}/htdocs/wp-config.php'.format( - wo_site_webroot) - else: - Log.debug( - self, "Updating wp-config.php failed. " - "File could not be located.") - Log.error( - self, "wp-config.php could not be located !!") - raise SiteError - - if WOShellExec.cmd_exec(self, "grep -q " - "\"WP_CACHE_KEY_SALT\" {0}" - .format(config_path)): - pass - else: - try: - wpconfig = open("{0}".format(config_path), - encoding='utf-8', mode='a') - wpconfig.write("\n\ndefine( \'WP_CACHE_KEY_SALT\'," - " \'{0}:\' );".format(wo_domain)) - wpconfig.close() - except IOError as e: - Log.debug(self, str(e)) - Log.debug(self, "Updating wp-config.php failed.") - Log.warn(self, "Updating wp-config.php failed. " - "Could not append:" - "\ndefine( \'WP_CACHE_KEY_SALT\', " - "\'{0}:\' );".format(wo_domain) + - "\nPlease add manually") + # add WP_CACHE_KEY_SALT if not already set + try: + Log.debug(self, "Updating wp-config.php.") + WOShellExec.cmd_exec(self, + "bash -c \"php {0} --allow-root " + .format(WOVariables.wo_wpcli_path) + + "config set --add " + "WP_CACHE_KEY_SALT " + "\'{0}:\' --path={1}\"" + .format(wo_domain, + wo_site_webroot)) + except IOError as e: + Log.debug(self, str(e)) + Log.debug(self, "Updating wp-config.php failed.") + Log.warn(self, "Updating wp-config.php failed. " + "Could not append:" + "\ndefine( \'WP_CACHE_KEY_SALT\', " + "\'{0}:\' );".format(wo_domain) + + "\nPlease add manually") except SiteError as e: Log.debug(self, str(e)) Log.info(self, Log.FAIL + "Update site failed." diff --git a/wo/cli/plugins/update.py b/wo/cli/plugins/update.py index fa955bc..07214e7 100644 --- a/wo/cli/plugins/update.py +++ b/wo/cli/plugins/update.py @@ -16,10 +16,13 @@ class WOUpdateController(CementBaseController): label = 'wo_update' stacked_on = 'base' aliases = ['update'] - aliases_only = True stacked_type = 'nested' description = ('update WordOps to latest version') - usage = "wo update" + arguments = [ + (['--force'], + dict(help='Force WordOps update', action='store_true')), + ] + usage = "wo update [options]" @expose(hide=True) def default(self): @@ -28,15 +31,20 @@ class WOUpdateController(CementBaseController): "WordOps/WordOps/master/install", "/tmp/{0}".format(filename), "update script"]]) - try: - Log.info(self, "updating WordOps, please wait...") - os.system("bash /tmp/{0}".format(filename)) - except OSError as e: - Log.debug(self, str(e)) - Log.error(self, "WordOps update failed !") - except Exception as e: - Log.debug(self, str(e)) - Log.error(self, "WordOps update failed !") + if self.app.pargs.force: + try: + Log.info(self, "updating WordOps, please wait...") + os.system("bash /tmp/{0} --force".format(filename)) + except OSError as e: + Log.debug(self, str(e)) + Log.error(self, "WordOps update failed !") + else: + try: + Log.info(self, "updating WordOps, please wait...") + os.system("bash /tmp/{0}".format(filename)) + except OSError as e: + Log.debug(self, str(e)) + Log.error(self, "WordOps update failed !") def load(app): diff --git a/wo/cli/templates/locations.mustache b/wo/cli/templates/locations.mustache index 267891c..ba1d66f 100644 --- a/wo/cli/templates/locations.mustache +++ b/wo/cli/templates/locations.mustache @@ -6,17 +6,6 @@ location = /favicon.ico { log_not_found off; expires max; } -location = /robots.txt { -# Some WordPress plugin gererate robots.txt file -# Refer #340 issue - try_files $uri $uri/ /index.php$is_args$args @robots; - access_log off; - log_not_found off; -} -# fallback for robots.txt with default wordpress rules -location @robots { - return 200 "User-agent: *\nDisallow: /wp-admin/\nAllow: /wp-admin/admin-ajax.php\n"; -} # Cache static files location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|woff2|ttf|m4a|mp4|ttf|rss|atom|jpe?g|gif|cur|heic|png|tiff|ico|webm|mp3|aac|tgz|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|swf|webp)$ { add_header "Access-Control-Allow-Origin" "*"; diff --git a/wo/cli/templates/wpcommon-php7.mustache b/wo/cli/templates/wpcommon-php7.mustache index 52054ad..d0ee50d 100644 --- a/wo/cli/templates/wpcommon-php7.mustache +++ b/wo/cli/templates/wpcommon-php7.mustache @@ -12,6 +12,17 @@ location = /wp-config.txt { access_log off; log_not_found off; } +location = /robots.txt { +# Some WordPress plugin gererate robots.txt file +# Refer #340 issue + try_files $uri $uri/ /index.php?$args @robots; + access_log off; + log_not_found off; +} +# fallback for robots.txt with default wordpress rules +location @robots { + return 200 "User-agent: *\nDisallow: /wp-admin/\nAllow: /wp-admin/admin-ajax.php\n"; +} # webp rewrite rules for jpg and png images # try to load alternative image.png.webp before image.png location /wp-content/uploads { diff --git a/wo/cli/templates/wpcommon.mustache b/wo/cli/templates/wpcommon.mustache index 8ddc377..581710c 100644 --- a/wo/cli/templates/wpcommon.mustache +++ b/wo/cli/templates/wpcommon.mustache @@ -12,6 +12,17 @@ location = /wp-config.txt { access_log off; log_not_found off; } +location = /robots.txt { +# Some WordPress plugin gererate robots.txt file +# Refer #340 issue + try_files $uri $uri/ /index.php?$args @robots; + access_log off; + log_not_found off; +} +# fallback for robots.txt with default wordpress rules +location @robots { + return 200 "User-agent: *\nDisallow: /wp-admin/\nAllow: /wp-admin/admin-ajax.php\n"; +} # webp rewrite rules for jpg and png images # try to load alternative image.png.webp before image.png location /wp-content/uploads { diff --git a/wo/core/variables.py b/wo/core/variables.py index d3af7bd..9997193 100644 --- a/wo/core/variables.py +++ b/wo/core/variables.py @@ -11,7 +11,7 @@ class WOVariables(): """Intialization of core variables""" # WordOps version - wo_version = "3.9.5" + wo_version = "3.9.5.2" # WordOps packages versions wo_wp_cli = "2.2.0" wo_adminer = "4.7.1"