Merge pull request #86 from WordOps/updating-configuration

Updating configuration
This commit is contained in:
VirtuBox
2019-06-17 00:59:10 +02:00
committed by GitHub
10 changed files with 104 additions and 84 deletions

View File

@@ -55,3 +55,5 @@ script:
- sudo wo info || sudo tail -n50 /var/log/wo/wordops.log - sudo wo info || sudo tail -n50 /var/log/wo/wordops.log
- sudo tree -L 2 /etc/nginx - sudo tree -L 2 /etc/nginx
- sudo cat /var/www/wpredis.net/wp-config.php - 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

View File

@@ -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.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 #### 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 ### v3.9.5.1 - 2019-05-10

46
install
View File

@@ -7,10 +7,10 @@
# Copyright (c) 2019 - WordOps # Copyright (c) 2019 - WordOps
# This script is licensed under M.I.T # 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_old="2.2.3"
readonly wo_version_new="3.9.5.1" readonly wo_version_new="3.9.5.2"
# CONTENTS # CONTENTS
# --- # ---
# 1. VARIABLES AND DECLARATIONS # 1. VARIABLES AND DECLARATIONS
@@ -70,6 +70,9 @@ while [ "$#" -gt 0 ]; do
--travis) --travis)
wo_travis="y" wo_travis="y"
;; ;;
-s | --silent)
wo_silent="y"
;;
*) # positional args *) # positional args
;; ;;
esac esac
@@ -193,21 +196,7 @@ wo_install_dep() {
locale-gen en locale-gen en
} >> "$wo_install_log" 2>&1 } >> "$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 \ --config-home /etc/letsencrypt/config \
--cert-home /etc/letsencrypt/renewal --cert-home /etc/letsencrypt/renewal
# enable auto-upgrade # 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 } >> "$wo_install_log" 2>&1
fi fi
@@ -427,6 +416,9 @@ wo_install() {
fi fi
cd /tmp/WordOps || exit 1 cd /tmp/WordOps || exit 1
} >> "$wo_install_log" 2>&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 python3 setup.py install
} }
@@ -435,7 +427,7 @@ wo_upgrade_nginx() {
{ {
if [ -d /var/lib/wo-backup/nginx ]; then 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 rm -rf /var/lib/wo-backup/nginx
fi fi
# backup nginx conf # backup nginx conf
@@ -464,7 +456,7 @@ wo_upgrade_nginx() {
# import the respository key for updates # import the respository key for updates
apt-key add - < /tmp/nginx-wo.key apt-key add - < /tmp/nginx-wo.key
rm -f /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 if [ -f /etc/nginx/common/release ]; then
CHECK_NGINX_UPSTREAM_VERSION=$(grep "$wo_version_new" /etc/nginx/common/release) CHECK_NGINX_UPSTREAM_VERSION=$(grep "$wo_version_new" /etc/nginx/common/release)
@@ -508,7 +500,7 @@ wo_upgrade_nginx() {
else else
WO WO_STACK_INSTALL_ARGS="" WO WO_STACK_INSTALL_ARGS=""
fi 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 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} rm -f /etc/nginx/common/acl.conf /etc/nginx/conf.d/{map-wp-cache.conf,map-wp.conf}
fi fi
@@ -681,8 +673,12 @@ wo_tweak_kernel() {
if [ -x /usr/local/bin/wo ]; then if [ -x /usr/local/bin/wo ]; then
if ! { if ! {
wo -v 2>&1 | grep $wo_version_new wo -v 2>&1 | grep $wo_version_new
}; then } || [ "$wo_force_install" = "y" ]; then
echo -e "Update WordOps to $wo_version_new (y/n): " && read -r WO_ANSWER 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 if [ "$WO_ANSWER" = "y" ] || [ "$WO_ANSWER" = "Y" ]; then
wo_lib_echo "Installing wo dependencies " | tee -ai $wo_install_log wo_lib_echo "Installing wo dependencies " | tee -ai $wo_install_log
wo_install_dep | 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 else
# 2 - Migration from EEv3 # 2 - Migration from EEv3
if [ -x /usr/local/bin/ee ]; then 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 if [ "$WO_ANSWER" = "y" ] || [ "$WO_ANSWER" = "Y" ]; then
wo_lib_echo "Installing wo dependencies " | tee -ai $wo_install_log wo_lib_echo "Installing wo dependencies " | tee -ai $wo_install_log
wo_install_dep | tee -ai $wo_install_log wo_install_dep | tee -ai $wo_install_log

View File

@@ -57,7 +57,7 @@ if not os.path.isfile('/root/.gitconfig'):
shutil.copy2(os.path.expanduser("~")+'/.gitconfig', '/root/.gitconfig') shutil.copy2(os.path.expanduser("~")+'/.gitconfig', '/root/.gitconfig')
setup(name='wo', setup(name='wo',
version='3.9.5', version='3.9.5.2',
description=long_description, description=long_description,
long_description=long_description, long_description=long_description,
classifiers=[], classifiers=[],

View File

@@ -4,6 +4,7 @@ from cement.core import handler, hook
from wo.core.cron import WOCron from wo.core.cron import WOCron
from wo.core.sslutils import SSL from wo.core.sslutils import SSL
from wo.core.variables import WOVariables from wo.core.variables import WOVariables
from wo.core.shellexec import WOShellExec
from wo.core.domainvalidate import ValidateDomain from wo.core.domainvalidate import ValidateDomain
from wo.core.fileutils import WOFileUtils from wo.core.fileutils import WOFileUtils
from wo.cli.plugins.site_functions import * from wo.cli.plugins.site_functions import *
@@ -1610,42 +1611,25 @@ class WOSiteUpdateController(CementBaseController):
if oldcachetype != 'wpredis' and data['wpredis']: if oldcachetype != 'wpredis' and data['wpredis']:
try: try:
if installwp_plugin(self, 'redis-cache', data): if installwp_plugin(self, 'redis-cache', data):
# search for wp-config.php # add WP_CACHE_KEY_SALT if not already set
if WOFileUtils.isexist(self, "{0}/wp-config.php" try:
.format(wo_site_webroot)): Log.debug(self, "Updating wp-config.php.")
config_path = '{0}/wp-config.php'.format( WOShellExec.cmd_exec(self,
wo_site_webroot) "bash -c \"php {0} --allow-root "
elif WOFileUtils.isexist(self, "{0}/htdocs/wp-config.php" .format(WOVariables.wo_wpcli_path) +
.format(wo_site_webroot)): "config set --add "
config_path = '{0}/htdocs/wp-config.php'.format( "WP_CACHE_KEY_SALT "
wo_site_webroot) "\'{0}:\' --path={1}\""
else: .format(wo_domain,
Log.debug( wo_site_webroot))
self, "Updating wp-config.php failed. " except IOError as e:
"File could not be located.") Log.debug(self, str(e))
Log.error( Log.debug(self, "Updating wp-config.php failed.")
self, "wp-config.php could not be located !!") Log.warn(self, "Updating wp-config.php failed. "
raise SiteError "Could not append:"
"\ndefine( \'WP_CACHE_KEY_SALT\', "
if WOShellExec.cmd_exec(self, "grep -q " "\'{0}:\' );".format(wo_domain) +
"\"WP_CACHE_KEY_SALT\" {0}" "\nPlease add manually")
.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")
except SiteError as e: except SiteError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.info(self, Log.FAIL + "Update site failed." Log.info(self, Log.FAIL + "Update site failed."

View File

@@ -16,10 +16,13 @@ class WOUpdateController(CementBaseController):
label = 'wo_update' label = 'wo_update'
stacked_on = 'base' stacked_on = 'base'
aliases = ['update'] aliases = ['update']
aliases_only = True
stacked_type = 'nested' stacked_type = 'nested'
description = ('update WordOps to latest version') 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) @expose(hide=True)
def default(self): def default(self):
@@ -28,15 +31,20 @@ class WOUpdateController(CementBaseController):
"WordOps/WordOps/master/install", "WordOps/WordOps/master/install",
"/tmp/{0}".format(filename), "/tmp/{0}".format(filename),
"update script"]]) "update script"]])
try: if self.app.pargs.force:
Log.info(self, "updating WordOps, please wait...") try:
os.system("bash /tmp/{0}".format(filename)) Log.info(self, "updating WordOps, please wait...")
except OSError as e: os.system("bash /tmp/{0} --force".format(filename))
Log.debug(self, str(e)) except OSError as e:
Log.error(self, "WordOps update failed !") Log.debug(self, str(e))
except Exception as e: Log.error(self, "WordOps update failed !")
Log.debug(self, str(e)) else:
Log.error(self, "WordOps update failed !") 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): def load(app):

View File

@@ -6,17 +6,6 @@ location = /favicon.ico {
log_not_found off; log_not_found off;
expires max; 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 # 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)$ { 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" "*"; add_header "Access-Control-Allow-Origin" "*";

View File

@@ -12,6 +12,17 @@ location = /wp-config.txt {
access_log off; access_log off;
log_not_found 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 # webp rewrite rules for jpg and png images
# try to load alternative image.png.webp before image.png # try to load alternative image.png.webp before image.png
location /wp-content/uploads { location /wp-content/uploads {

View File

@@ -12,6 +12,17 @@ location = /wp-config.txt {
access_log off; access_log off;
log_not_found 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 # webp rewrite rules for jpg and png images
# try to load alternative image.png.webp before image.png # try to load alternative image.png.webp before image.png
location /wp-content/uploads { location /wp-content/uploads {

View File

@@ -11,7 +11,7 @@ class WOVariables():
"""Intialization of core variables""" """Intialization of core variables"""
# WordOps version # WordOps version
wo_version = "3.9.5" wo_version = "3.9.5.2"
# WordOps packages versions # WordOps packages versions
wo_wp_cli = "2.2.0" wo_wp_cli = "2.2.0"
wo_adminer = "4.7.1" wo_adminer = "4.7.1"