Merge pull request #121 from WordOps/updating-configuration

Updating configuration
This commit is contained in:
VirtuBox
2019-08-20 07:31:09 +02:00
committed by GitHub
14 changed files with 551 additions and 509 deletions

View File

@@ -50,6 +50,7 @@ script:
- sudo wo info
- sudo cat /etc/nginx/nginx.conf
- sudo tree -L 2 /etc/nginx
- sudo tree -L 2 /var/www
- sudo cat /etc/mysql/my.cnf
- sudo wo stack upgrade --nginx --force
- sudo wo stack upgrade --php --force

View File

@@ -8,6 +8,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### v3.9.x - [Unreleased]
### v3.9.8.2 - 2019-08-20
#### Added
- Additional cache expection for Easy Digital Downloads [PR #120](https://github.com/WordOps/WordOps/pull/120)
- Additional settings to support mobile with WP-Rocket
- Add the ability to block nginx configuration overwriting by adding a file .custom. Example with /etc/nginx/conf.d/webp.conf -> `touch /etc/nginx/conf.d/webp.conf.custom`
- If there is a custom file, WordOps will write the configuration in a file named fileconf.conf.orig to let users implement possible changes
- UFW minimal configuration during install. Can be disabled with the flag `-w`, `--wufw` or `--without-ufw`. Example : `wget -qO wo wops.cc && sudo bash wo -w`
#### Fixed
- WordOps internal database creation on servers running with custom setup
### v3.9.8.1 - 2019-08-18
#### Added

View File

@@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2018-2019 WordOps (https://wordops.net)
Copyright (c) 2018-2019 WordOps (https://github.com/WordOps/WordOps/graphs/contributors)
Copyright (C) 2011-2017 EE Development Group (https://github.com/ee/ee/contributors)
Permission is hereby granted, free of charge, to any person obtaining a copy

131
install
View File

@@ -9,7 +9,7 @@
# -------------------------------------------------------------------------
# wget -qO wo wops.cc && sudo bash wo
# -------------------------------------------------------------------------
# Version 3.9.8.1 - 2019-08-18
# Version 3.9.8.2 - 2019-08-20
# -------------------------------------------------------------------------
# CONTENTS
@@ -77,6 +77,9 @@ while [ "$#" -gt 0 ]; do
--purge | --uninstall)
wo_purge="y"
;;
-w | --wufw | --without-ufw)
ufw="n"
;;
*) # positional args
;;
esac
@@ -148,7 +151,9 @@ if [ -x /usr/local/bin/ee ]; then
elif [ -x /usr/local/bin/wo ]; then
wo_upgrade=1
fi
if [ -z "$ufw" ]; then
ufw="y"
fi
###
# 1 - Checking linux distro
###
@@ -211,11 +216,15 @@ wo_install_dep() {
locale-gen en
# enable unattended upgades
cp /usr/share/unattended-upgrades/20auto-upgrades /etc/apt/apt.conf.d/20auto-upgrades
if [ ! -f /etc/apt/apt.conf.d/20auto-upgrades ]; then
cp /usr/share/unattended-upgrades/20auto-upgrades /etc/apt/apt.conf.d/20auto-upgrades
fi
# set default ntp pools
sed -e 's/^#NTP=/NTP=time.cloudflare.com 0.ubuntu.pool.ntp.org 1.ubuntu.pool.ntp.org 2.ubuntu.pool.ntp.org 3.ubuntu.pool.ntp.org/' -i /etc/systemd/timesyncd.conf
# enable ntp
timedatectl set-ntp 1
if ! grep -q "time.cloudflare.com" /etc/systemd/timesyncd.conf; then
sed -e 's/^#NTP=/NTP=time.cloudflare.com 0.ubuntu.pool.ntp.org 1.ubuntu.pool.ntp.org 2.ubuntu.pool.ntp.org 3.ubuntu.pool.ntp.org/' -i /etc/systemd/timesyncd.conf
# enable ntp
timedatectl set-ntp 1
fi
} >> "$wo_install_log" 2>&1
@@ -318,14 +327,14 @@ wo_sync_db() {
fi
fi
done
wo_webroot="/var/www/$site"
wo_webroot="/var/www/$site"
# Import the configuration into the WordOps SQLite database
echo "INSERT INTO sites (sitename, site_type, cache_type, site_path, is_enabled, is_ssl, storage_fs, storage_db)
# Import the configuration into the WordOps SQLite database
echo "INSERT INTO sites (sitename, site_type, cache_type, site_path, is_enabled, is_ssl, storage_fs, storage_db)
VALUES (\"$site\", \"$wo_site_current\", \"$wo_site_current_cache\", \"$wo_webroot\", \"$wo_site_status\", 0, 'ext4', 'mysql');" | sqlite3 /var/lib/wo/dbase.db
done
fi
# echo "UPDATE sites SET php_version = REPLACE(php_version, '5.6', '7.2');" | sqlite3 /var/lib/wo/dbase.db
@@ -401,9 +410,6 @@ wo_install_acme_sh() {
/etc/letsencrypt/renewal/
# remove previous acme.sh folder
rm -rf "$HOME/.acme.sh"
# create acme.sh.env file inlcuded in .bashrc to avoid error when logging in
mkdir -p "$HOME/.acme.sh"
echo '' > "$HOME/.acme.sh/acme.sh.env"
# removing previous cronjob
crontab -l | sed '/41 0 \* \* \* "\/root\/\.acme\.sh"\/acme.sh --cron --home "\/root\/\.acme\.sh" > \/dev\/null/d' | crontab -
@@ -509,6 +515,7 @@ wo_upgrade_nginx() {
[ -f /etc/nginx/htpasswd-ee ] && { mv /etc/nginx/htpasswd-ee /etc/nginx/htpasswd-wo; }
sed -i "s/locations.conf/locations-wo.conf/" /etc/nginx/sites-available/*
sed -i "s/locations-php7.conf/locations-wo.conf/" /etc/nginx/sites-available/*
sed -i "s/locations-php71.conf/locations-wo.conf/" /etc/nginx/sites-available/*
sed -i "s/locations-php72.conf/locations-wo.conf/" /etc/nginx/sites-available/*
sed -i "s/locations-php73.conf/locations-wo.conf/" /etc/nginx/sites-available/*
sed -i 's/ssl on;/#ssl on;/' /var/www/*/conf/nginx/ssl.conf
@@ -687,43 +694,73 @@ wo_uninstall() {
wo_ufw_setup() {
CURRENT_SSH_PORT=$(grep "Port" /etc/ssh/sshd_config | awk -F " " '{print $2}')
# get custom ssh port
if [ -f /etc/ssh/sshd_config ]; then
CURRENT_SSH_PORT=$(grep "Port" /etc/ssh/sshd_config | awk -F " " '{print $2}')
fi
# install ufw if needed
if [ ! -d /etc/ufw ]; then
apt-get install ufw -y
fi
# define firewall rules
ufw logging low
ufw default allow outgoing
ufw default deny incoming
# default ssh port
ufw allow 22
if ! grep -q "LOGLEVEL=low" /etc/ufw/ufw.conf; then
ufw logging low
fi
if ! grep -q 'DEFAULT_OUTPUT_POLICY="ACCEPT"' /etc/default/ufw; then
ufw default allow outgoing
fi
if ! grep -q 'DEFAULT_INPUT_POLICY="DROP"' /etc/default/ufw; then
ufw default deny incoming
fi
if ! grep -q "\-\-dport 22 -j" /etc/ufw/user.rules; then
# default ssh port
ufw limit 22
fi
# custom ssh port
if [ "$CURRENT_SSH_PORT" != "22" ]; then
ufw allow "$CURRENT_SSH_PORT"
if ! grep -q "\-\-dport $CURRENT_SSH_PORT -j" /etc/ufw/user.rules; then
ufw limit "$CURRENT_SSH_PORT"
fi
fi
# dns
ufw allow 53
# nginx
ufw allow http
ufw allow https
if ! grep -q "\-\-dport 80 -j" /etc/ufw/user.rules; then
# http
ufw allow http
fi
if ! grep -q "\-\-dport 443 -j" /etc/ufw/user.rules; then
# https
ufw allow https
fi
# ntp
ufw allow 123
# wordops backend
ufw allow 22222
if ! grep -q "\-\-dport 123 -j" /etc/ufw/user.rules; then
ufw allow 123
fi
if ! grep -q "\-\-dport 22222 -j" /etc/ufw/user.rules; then
# wordops backend
ufw limit 22222
fi
# enable ufw
echo "y" | ufw enable
if [ -n "$CURRENT_SSH_PORT" ]; then
if ! grep -q "ENABLED=yes" /etc/ufw/ufw.conf; then
ufw --force enable
else
ufw reload
fi
fi
} >> $wo_install_log
# remove ufw from syslog
if [ -f /etc/rsyslog.d/20-ufw.conf ]; then
sed -i 's/\#\& stop/\& stop/' /etc/rsyslog.d/20-ufw.conf
service rsyslog restart
fi
} \
>> $wo_install_log
###
# 4 - WO MAIN SETUP
@@ -739,7 +776,7 @@ else
# 1 - WO already installed
if [ -x /usr/local/bin/wo ]; then
if ! {
wo -v 2>&1 | grep -q "$wo_version_new"
wo -v 2>&1 | grep "$wo_version_new"
} || [ "$wo_force_install" = "y" ]; then
if [ -z "$wo_force_install" ]; then
echo -e "Update WordOps to $wo_version_new (y/n): " && read -r WO_ANSWER
@@ -754,10 +791,14 @@ else
secure_wo_db | tee -ai $wo_install_log
wo_lib_echo "Installing WordOps " | tee -ai $wo_install_log
wo_clean | tee -ai $wo_install_log
if [ -f "$HOME/.gitconfig" ]; then
wo_install >> $wo_install_log 2>&1
if [ "$wo_travis" = "y" ]; then
wo_install_travis | tee -ai $wo_install_log
else
wo_install | tee -ai $wo_install_log
if [ -f "$HOME/.gitconfig" ]; then
wo_install >> $wo_install_log 2>&1
else
wo_install | tee -ai $wo_install_log
fi
fi
if [ -z "$wo_preserve_config" ]; then
if [ -n "$(command -v nginx)" ]; then
@@ -772,6 +813,10 @@ else
wo_lib_echo "Updating acme.sh" | tee -ai $wo_install_log
wo_install_acme_sh | tee -ai $wo_install_log
fi
if [ "$ufw" = "y" ]; then
wo_lib_echo "Configuring UFW" | tee -ai $wo_install_log
wo_ufw_setup | tee -ai $wo_install_log
fi
wo_lib_echo "Applying Kernel tweaks" | tee -ai $wo_install_log
wo_tweak_kernel | tee -ai $wo_install_log
wo_lib_echo "Running post-install steps " | tee -ai $wo_install_log
@@ -813,6 +858,10 @@ else
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 [ "$ufw" = "y" ]; then
wo_lib_echo "Configuring UFW" | tee -ai $wo_install_log
wo_ufw_setup | tee -ai $wo_install_log
fi
wo_lib_echo "Applying Kernel tweaks" | tee -ai $wo_install_log
wo_tweak_kernel | tee -ai $wo_install_log
wo_lib_echo "Running post-install steps " | tee -ai $wo_install_log
@@ -833,6 +882,10 @@ else
else
wo_install | tee -ai $wo_install_log
fi
if [ "$ufw" = "y" ]; then
wo_lib_echo "Configuring UFW" | tee -ai $wo_install_log
wo_ufw_setup | tee -ai $wo_install_log
fi
wo_lib_echo "Applying Kernel tweaks" | tee -ai $wo_install_log
wo_tweak_kernel | tee -ai $wo_install_log
wo_lib_echo "Installing acme.sh" | 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')
setup(name='wo',
version='3.9.8.1',
version='3.9.8.2',
description=long_description,
long_description=long_description,
classifiers=[],
@@ -87,6 +87,7 @@ setup(name='wo',
'sh',
'SQLAlchemy',
'requests',
'distro',
],
data_files=[('/etc/wo', ['config/wo.conf']),
('/etc/wo/plugins.d', conf),

View File

@@ -1608,6 +1608,35 @@ class WOSiteUpdateController(CementBaseController):
" `tail /var/log/wo/wordops.log` "
"and please try again")
return 1
elif ((oldcachetype in ['wpsc', 'basic', 'wpfc', 'wprocket', 'wpredis'] and
(data['wpce'])) or (oldsitetype == 'wp' and
data['multisite'] and
data['wpce'])):
try:
plugin_data_object = {"expires": 24,
"new_post": 1,
"new_comment": 0,
"webp": 0,
"clear_on_upgrade": 1,
"compress": 0,
"excl_ids": "",
"excl_regexp": "",
"excl_cookies": "",
"incl_attributes": "",
"minify_html": 1}
plugin_data = json.dumps(plugin_data_object)
setupwp_plugin(
self, 'cache-enabler',
'cache-enabler', plugin_data, data)
except SiteError as e:
Log.debug(self, str(e))
Log.info(self, Log.FAIL + "Update cache-enabler "
"settings failed. "
"Check the log for details:"
" `tail /var/log/wo/wordops.log` "
"and please try again")
return 1
else:
try:
plugin_data_object = {"log_level": "INFO",

View File

@@ -587,7 +587,20 @@ def setupwordpress(self, data):
"""Install Cache-Enabler"""
if data['wpce']:
installwp_plugin(self, 'cache-enabler', data)
plugin_data_object = {"expires": 24,
"new_post": 1,
"new_comment": 0,
"webp": 0,
"clear_on_upgrade": 1,
"compress": 0,
"excl_ids": "",
"excl_regexp": "",
"excl_cookies": "",
"incl_attributes": "",
"minify_html": 1}
plugin_data = json.dumps(plugin_data_object)
setupwp_plugin(self, 'cache-enabler', 'cache-enabler',
plugin_data, data)
wp_creds = dict(wp_user=wo_wp_user, wp_pass=wo_wp_pass,
wp_email=wo_wp_email)
@@ -656,12 +669,12 @@ def uninstallwp_plugin(self, plugin_name, data):
Log.info(self, "Uninstalling plugin {0}, please wait..."
.format(plugin_name))
try:
WOShellExec.cmd_exec(self, "php {0} plugin "
WOShellExec.cmd_exec(self, "{0} plugin "
.format(WOVariables.wo_wpcli_path) +
"--allow-root deactivate "
"{0}".format(plugin_name))
WOShellExec.cmd_exec(self, "php {0} plugin "
WOShellExec.cmd_exec(self, "{0} plugin "
.format(WOVariables.wo_wpcli_path) +
"--allow-root uninstall "
"{0}".format(plugin_name))
@@ -678,7 +691,7 @@ def setupwp_plugin(self, plugin_name, plugin_option, plugin_data, data):
if not data['multisite']:
try:
WOShellExec.cmd_exec(self, "php {0} "
WOShellExec.cmd_exec(self, "{0} "
.format(WOVariables.wo_wpcli_path) +
"--allow-root option update "
"{0} \'{1}\' --format=json"
@@ -688,7 +701,7 @@ def setupwp_plugin(self, plugin_name, plugin_option, plugin_data, data):
raise SiteError("plugin setup failed")
else:
try:
WOShellExec.cmd_exec(self, "php {0} "
WOShellExec.cmd_exec(self, "{0} "
.format(WOVariables.wo_wpcli_path) +
"--allow-root network meta update 1 "
"{0} \'{1}\' --format=json"
@@ -1224,16 +1237,16 @@ def site_url_https(self, domain):
WOFileUtils.chdir(self, '{0}/htdocs/'.format(wo_site_webroot))
wo_siteurl = \
WOShellExec.cmd_exec_stdout(self,
"php {0} option get siteurl "
"{0} option get siteurl "
.format(WOVariables.wo_wpcli_path) +
"--allow-root --quiet")
test_url = re.split(":", wo_siteurl)
if not (test_url[0] == 'https'):
try:
WOShellExec.cmd_exec(self, "php {0} option update siteurl "
WOShellExec.cmd_exec(self, "{0} option update siteurl "
"\'https://{1}\' --allow-root".format(
WOVariables.wo_wpcli_path, domain))
WOShellExec.cmd_exec(self, "php {0} option update home "
WOShellExec.cmd_exec(self, "{0} option update home "
"\'https://{1}\' --allow-root".format(
WOVariables.wo_wpcli_path, domain))
except CommandExecutionError as e:

View File

@@ -15,6 +15,7 @@ from wo.core.cron import WOCron
from wo.core.extract import WOExtract
from wo.core.fileutils import WOFileUtils
from wo.core.git import WOGit
from wo.core.template import WOTemplate
from wo.core.logging import Log
from wo.core.mysql import WOMysql
from wo.core.services import WOService
@@ -146,46 +147,31 @@ def post_pref(self, apt_packages, packages):
# Nginx configuration
if set(WOVariables.wo_nginx).issubset(set(apt_packages)):
# Nginx main configuration
if os.path.isfile('/etc/nginx/nginx.conf'):
if (WOVariables.wo_distro == 'ubuntu' or
WOVariables.wo_platform_codename == 'buster'):
data = dict(tls13=True)
else:
data = dict(tls13=False)
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/nginx.conf')
wo_nginx = open('/etc/nginx/nginx.conf',
encoding='utf-8', mode='w')
self.app.render(
(data), 'nginx-core.mustache', out=wo_nginx)
wo_nginx.close()
ngxcnf = '/etc/nginx/conf.d'
ngxcom = '/etc/nginx/common'
ngxroot = '/var/www/'
if (WOVariables.wo_distro == 'ubuntu' or
WOVariables.wo_platform_codename == 'buster'):
data = dict(tls13=True)
else:
data = dict(tls13=False)
WOTemplate.tmpl_render(self,
'/etc/nginx/nginx.conf',
'nginx-core.mustache', data)
if not os.path.isfile('/etc/nginx/conf.d/gzip.conf.disabled'):
if not os.path.isfile('{0}/gzip.conf.disabled'.format(ngxcnf)):
data = dict()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/gzip.conf')
wo_nginx = open('/etc/nginx/conf.d/gzip.conf',
encoding='utf-8', mode='w')
self.app.render(
(data), 'gzip.mustache', out=wo_nginx)
wo_nginx.close()
WOTemplate.tmpl_render(self, '{0}/gzip.conf'.format(ngxcnf),
'gzip.mustache', data)
if not os.path.isfile('/etc/nginx/conf.d/brotli.conf'):
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/brotli.conf.disabled')
wo_nginx = open('/etc/nginx/conf.d/brotli.conf.disabled',
encoding='utf-8', mode='w')
self.app.render(
(data), 'brotli.mustache', out=wo_nginx)
wo_nginx.close()
if not os.path.isfile('{0}/brotli.conf'.format(ngxcnf)):
WOTemplate.tmpl_render(self,
'{0}/brotli.conf.disabled'
.format(ngxcnf),
'brotli.mustache', data)
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/tweaks.conf')
wo_nginx = open('/etc/nginx/conf.d/tweaks.conf',
encoding='utf-8', mode='w')
self.app.render(
(data), 'tweaks.mustache', out=wo_nginx)
wo_nginx.close()
WOTemplate.tmpl_render(self, '{0}/tweaks.conf'.format(ngxcnf),
'tweaks.mustache', data)
# Fix for white screen death with NGINX PLUS
if not WOFileUtils.grep(self, '/etc/nginx/fastcgi_params',
@@ -198,54 +184,32 @@ def post_pref(self, apt_packages, packages):
if os.path.isfile('/etc/nginx/nginx.conf'):
data = dict(php="9000", debug="9001",
php7="9070", debug7="9170")
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/upstream.conf')
wo_nginx = open('/etc/nginx/conf.d/upstream.conf',
encoding='utf-8', mode='w')
self.app.render(
(data), 'upstream.mustache', out=wo_nginx)
wo_nginx.close()
WOTemplate.tmpl_render(
self, '{0}/upstream.conf'.format(ngxcnf),
'upstream.mustache', data, overwrite=True)
data = dict(phpconf=True if
WOAptGet.is_installed(self, 'php7.2-fpm')
else False)
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/stub_status.conf')
wo_nginx = open('/etc/nginx/conf.d/stub_status.conf',
encoding='utf-8', mode='w')
self.app.render(
(data), 'stub_status.mustache', out=wo_nginx)
wo_nginx.close()
WOTemplate.tmpl_render(self,
'{0}/stub_status.conf'.format(ngxcnf),
'stub_status.mustache', data)
data = dict()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/webp.conf')
wo_nginx = open('/etc/nginx/conf.d/webp.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'webp.mustache',
out=wo_nginx)
wo_nginx.close()
WOTemplate.tmpl_render(self,
'{0}/webp.conf'.format(ngxcnf),
'webp.mustache', data)
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/cloudflare.conf')
wo_nginx = open('/etc/nginx/conf.d/cloudflare.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'cloudflare.mustache',
out=wo_nginx)
wo_nginx.close()
WOTemplate.tmpl_render(self,
'{0}/cloudflare.conf'.format(ngxcnf),
'cloudflare.mustache', data)
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/'
'map-wp-fastcgi-cache.conf')
wo_nginx = open('/etc/nginx/conf.d/'
'map-wp-fastcgi-cache.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'map-wp.mustache',
out=wo_nginx)
wo_nginx.close()
WOTemplate.tmpl_render(self,
'{0}/map-wp-fastcgi-cache.conf'.format(
ngxcnf),
'map-wp.mustache', data)
# Setup Nginx common directory
if not os.path.exists('/etc/nginx/common'):
if not os.path.exists('{0}'.format(ngxcom)):
Log.debug(self, 'Creating directory'
'/etc/nginx/common')
os.makedirs('/etc/nginx/common')
@@ -254,138 +218,88 @@ def post_pref(self, apt_packages, packages):
data = dict()
# Common Configuration
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/locations-wo.conf')
wo_nginx = open('/etc/nginx/common/locations-wo.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'locations.mustache',
out=wo_nginx)
wo_nginx.close()
WOTemplate.tmpl_render(self,
'{0}/locations-wo.conf'
.format(ngxcom),
'locations.mustache', data)
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpsubdir.conf')
wo_nginx = open('/etc/nginx/common/wpsubdir.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpsubdir.mustache',
out=wo_nginx)
wo_nginx.close()
WOTemplate.tmpl_render(self,
'{0}/wpsubdir.conf'
.format(ngxcom),
'wpsubdir.mustache', data)
data = dict(upstream="php72")
# PHP 7.2 conf
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/php72.conf')
wo_nginx = open('/etc/nginx/common/php72.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'php.mustache',
out=wo_nginx)
wo_nginx.close()
WOTemplate.tmpl_render(self,
'{0}/php72.conf'
.format(ngxcom),
'php.mustache', data)
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/redis-php72.conf')
wo_nginx = open('/etc/nginx/common/redis-php72.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'redis.mustache',
out=wo_nginx)
wo_nginx.close()
WOTemplate.tmpl_render(self,
'{0}/redis-php72.conf'
.format(ngxcom),
'redis.mustache', data)
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpcommon-php72.conf')
wo_nginx = open('/etc/nginx/common/wpcommon-php72.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpcommon.mustache',
out=wo_nginx)
wo_nginx.close()
WOTemplate.tmpl_render(self,
'{0}/wpcommon-php72.conf'
.format(ngxcom),
'wpcommon.mustache', data)
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpfc-php72.conf')
wo_nginx = open('/etc/nginx/common/wpfc-php72.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpfc.mustache',
out=wo_nginx)
wo_nginx.close()
WOTemplate.tmpl_render(self,
'{0}/wpfc-php72.conf'
.format(ngxcom),
'wpfc.mustache', data)
WOTemplate.tmpl_render(self,
'{0}/wpsc-php72.conf'
.format(ngxcom),
'wpsc.mustache', data)
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpsc-php72.conf')
wo_nginx = open('/etc/nginx/common/wpsc-php72.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpsc.mustache',
out=wo_nginx)
wo_nginx.close()
WOTemplate.tmpl_render(self,
'{0}/wprocket-php72.conf'
.format(ngxcom),
'wprocket.mustache', data)
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wprocket-php72.conf')
wo_nginx = open('/etc/nginx/common/wprocket-php72.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wprocket.mustache',
out=wo_nginx)
wo_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpce-php72.conf')
wo_nginx = open('/etc/nginx/common/wpce-php72.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpce.mustache',
out=wo_nginx)
wo_nginx.close()
WOTemplate.tmpl_render(self,
'{0}/wpce-php72.conf'
.format(ngxcom),
'wpce.mustache', data)
# PHP 7.3 conf
if os.path.isdir("/etc/nginx/common"):
data = dict(upstream="php73")
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/php73.conf')
wo_nginx = open('/etc/nginx/common/php73.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'php.mustache',
out=wo_nginx)
wo_nginx.close()
WOTemplate.tmpl_render(self,
'{0}/php73.conf'
.format(ngxcom),
'php.mustache', data)
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpcommon-php73.conf')
wo_nginx = open('/etc/nginx/common/wpcommon-php73.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpcommon.mustache',
out=wo_nginx)
wo_nginx.close()
WOTemplate.tmpl_render(self,
'{0}/redis-php73.conf'
.format(ngxcom),
'redis.mustache', data)
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpfc-php73.conf')
wo_nginx = open('/etc/nginx/common/wpfc-php73.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpfc.mustache',
out=wo_nginx)
wo_nginx.close()
WOTemplate.tmpl_render(self,
'{0}/wpcommon-php73.conf'
.format(ngxcom),
'wpcommon.mustache', data)
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpsc-php73.conf')
wo_nginx = open('/etc/nginx/common/wpsc-php73.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpsc.mustache',
out=wo_nginx)
wo_nginx.close()
WOTemplate.tmpl_render(self,
'{0}/wpfc-php73.conf'
.format(ngxcom),
'wpfc.mustache', data)
WOTemplate.tmpl_render(self,
'{0}/wpsc-php73.conf'
.format(ngxcom),
'wpsc.mustache', data)
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wprocket-php73.conf')
wo_nginx = open('/etc/nginx/common/wprocket-php73.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wprocket.mustache',
out=wo_nginx)
wo_nginx.close()
WOTemplate.tmpl_render(self,
'{0}/wprocket-php73.conf'
.format(ngxcom),
'wprocket.mustache', data)
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpce-php73.conf')
wo_nginx = open('/etc/nginx/common/wpce-php73.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpce.mustache',
out=wo_nginx)
wo_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/redis-php73.conf')
wo_nginx = open('/etc/nginx/common/redis-php73.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'redis.mustache',
out=wo_nginx)
wo_nginx.close()
WOTemplate.tmpl_render(self,
'{0}/wpce-php73.conf'
.format(ngxcom),
'wpce.mustache', data)
with open("/etc/nginx/common/release",
"w") as release_file:
@@ -395,32 +309,19 @@ def post_pref(self, apt_packages, packages):
# Following files should not be overwrited
if not os.path.isfile('/etc/nginx/common/acl.conf'):
data = dict(webroot=WOVariables.wo_webroot)
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/acl.conf')
wo_nginx = open('/etc/nginx/common/acl.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'acl.mustache',
out=wo_nginx)
wo_nginx.close()
if not os.path.isfile('/etc/nginx/conf.d/blockips.conf'):
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/blockips.conf')
wo_nginx = open('/etc/nginx/conf.d/blockips.conf',
encoding='utf-8', mode='w')
self.app.render(
(data), 'blockips.mustache', out=wo_nginx)
wo_nginx.close()
if not os.path.isfile('/etc/nginx/conf.d/fastcgi.conf'):
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/fastcgi.conf')
wo_nginx = open('/etc/nginx/conf.d/fastcgi.conf',
encoding='utf-8', mode='w')
self.app.render(
(data), 'fastcgi.mustache', out=wo_nginx)
wo_nginx.close()
data = dict(webroot=ngxroot)
WOTemplate.tmpl_render(self,
'{0}/acl.conf'
.format(ngxcom),
'acl.mustache', data, overwrite=False)
WOTemplate.tmpl_render(self,
'{0}/blockips.conf'
.format(ngxcnf),
'blockips.mustache', data, overwrite=False)
WOTemplate.tmpl_render(self,
'{0}/fastcgi.conf'
.format(ngxcnf),
'fastcgi.mustache', data, overwrite=False)
# add redis cache format if not already done
if (os.path.isfile("/etc/nginx/nginx.conf") and
@@ -486,72 +387,74 @@ def post_pref(self, apt_packages, packages):
'22222'])
# Create log and cert folder and softlinks
if not os.path.exists('{0}22222/logs'
.format(WOVariables.wo_webroot)):
.format(ngxroot)):
Log.debug(self, "Creating directory "
"{0}22222/logs "
.format(WOVariables.wo_webroot))
.format(ngxroot))
os.makedirs('{0}22222/logs'
.format(WOVariables.wo_webroot))
.format(ngxroot))
if not os.path.exists('{0}22222/cert'
.format(WOVariables.wo_webroot)):
.format(ngxroot)):
Log.debug(self, "Creating directory "
"{0}22222/cert"
.format(WOVariables.wo_webroot))
.format(ngxroot))
os.makedirs('{0}22222/cert'
.format(WOVariables.wo_webroot))
.format(ngxroot))
if not os.path.exists('{0}22222/conf/nginx'
.format(WOVariables.wo_webroot)):
if not os.path.isdir('{0}22222/conf/nginx'
.format(ngxroot)):
Log.debug(self, "Creating directory "
"{0}22222/conf/nginx"
.format(WOVariables.wo_webroot))
.format(ngxroot))
os.makedirs('{0}22222/conf/nginx'
.format(WOVariables.wo_webroot))
.format(ngxroot))
WOFileUtils.create_symlink(self, ['/var/log/nginx/'
'22222.access.log',
'{0}22222/'
'logs/access.log'
.format(WOVariables.wo_webroot)]
WOFileUtils.create_symlink(self,
['/var/log/nginx/'
'22222.access.log',
'{0}22222/'
'logs/access.log'
.format(ngxroot)]
)
WOFileUtils.create_symlink(self, ['/var/log/nginx/'
'22222.error.log',
'{0}22222/'
'logs/error.log'
.format(WOVariables.wo_webroot)]
WOFileUtils.create_symlink(self,
['/var/log/nginx/'
'22222.error.log',
'{0}22222/'
'logs/error.log'
.format(ngxroot)]
)
try:
WOShellExec.cmd_exec(self, "openssl genrsa -out "
"{0}22222/cert/22222.key 2048"
.format(WOVariables.wo_webroot))
.format(ngxroot))
WOShellExec.cmd_exec(self, "openssl req -new -batch "
"-subj /commonName=localhost/ "
"-key {0}22222/cert/22222.key "
"-out {0}22222/cert/"
"22222.csr"
.format(WOVariables.wo_webroot))
.format(ngxroot))
WOFileUtils.mvfile(self, "{0}22222/cert/22222.key"
.format(WOVariables.wo_webroot),
.format(ngxroot),
"{0}22222/cert/"
"22222.key.org"
.format(WOVariables.wo_webroot))
.format(ngxroot))
WOShellExec.cmd_exec(self, "openssl rsa -in "
"{0}22222/cert/"
"22222.key.org -out "
"{0}22222/cert/22222.key"
.format(WOVariables.wo_webroot))
.format(ngxroot))
WOShellExec.cmd_exec(self, "openssl x509 -req -days "
"3652 -in {0}22222/cert/"
"22222.csr -signkey {0}"
"22222/cert/22222.key -out "
"{0}22222/cert/22222.crt"
.format(WOVariables.wo_webroot))
.format(ngxroot))
except CommandExecutionError as e:
Log.debug(self, "{0}".format(e))
@@ -560,7 +463,7 @@ def post_pref(self, apt_packages, packages):
"certificate for 22222")
if not os.path.isfile('{0}22222/conf/nginx/ssl.conf'
.format(WOVariables.wo_webroot)):
.format(ngxroot)):
with open("/var/www/22222/conf/nginx/"
"ssl.conf", "a") as php_file:
@@ -646,16 +549,21 @@ def post_pref(self, apt_packages, packages):
"\"$http_user_agent\"';\n")
if set(WOVariables.wo_php).issubset(set(apt_packages)):
ngxroot = '/var/www/'
# Create log directories
if not os.path.exists('/var/log/php/7.2/'):
Log.debug(self, 'Creating directory /var/log/php/7.2/')
os.makedirs('/var/log/php/7.2/')
# Parse etc/php/7.2/fpm/php.ini
if not os.path.isfile('/etc/php/7.2/fpm/php.ini.orig'):
WOFileUtils.copyfile(self, '/etc/php/7.2/fpm/php.ini',
'/etc/php/7.2/fpm/php.ini.orig')
# Parse etc/php/7.2/fpm/php.ini
config = configparser.ConfigParser()
Log.debug(self, "configuring php file "
"/etc/php/7.2/fpm/php.ini")
config.read('/etc/php/7.2/fpm/php.ini')
config.read('/etc/php/7.2/fpm/php.ini.orig')
config['PHP']['expose_php'] = 'Off'
config['PHP']['post_max_size'] = '100M'
config['PHP']['upload_max_filesize'] = '100M'
@@ -688,10 +596,13 @@ def post_pref(self, apt_packages, packages):
self.app.render((data), 'php-fpm.mustache', out=wo_php_fpm)
wo_php_fpm.close()
if not os.path.isfile('/etc/php/7.2/fpm/pool.d/www.conf.orig'):
WOFileUtils.copyfile(self, '/etc/php/7.2/fpm/pool.d/www.conf',
'/etc/php/7.2/fpm/pool.d/www.conf.orig')
# Parse /etc/php/7.2/fpm/pool.d/www.conf
config = configparser.ConfigParser()
config.read_file(codecs.open('/etc/php/7.2/fpm/'
'pool.d/www.conf',
'pool.d/www.conf.orig',
"r", "utf8"))
config['www']['ping.path'] = '/ping'
config['www']['pm.status_path'] = '/status'
@@ -773,35 +684,35 @@ def post_pref(self, apt_packages, packages):
# PHP and Debug pull configuration
if not os.path.exists('{0}22222/htdocs/fpm/status/'
.format(WOVariables.wo_webroot)):
.format(ngxroot)):
Log.debug(self, 'Creating directory '
'{0}22222/htdocs/fpm/status/ '
.format(WOVariables.wo_webroot))
.format(ngxroot))
os.makedirs('{0}22222/htdocs/fpm/status/'
.format(WOVariables.wo_webroot))
.format(ngxroot))
open('{0}22222/htdocs/fpm/status/debug72'
.format(WOVariables.wo_webroot),
.format(ngxroot),
encoding='utf-8', mode='a').close()
open('{0}22222/htdocs/fpm/status/php72'
.format(WOVariables.wo_webroot),
.format(ngxroot),
encoding='utf-8', mode='a').close()
# Write info.php
if not os.path.exists('{0}22222/htdocs/php/'
.format(WOVariables.wo_webroot)):
.format(ngxroot)):
Log.debug(self, 'Creating directory '
'{0}22222/htdocs/php/ '
.format(WOVariables.wo_webroot))
.format(ngxroot))
os.makedirs('{0}22222/htdocs/php'
.format(WOVariables.wo_webroot))
.format(ngxroot))
with open("{0}22222/htdocs/php/info.php"
.format(WOVariables.wo_webroot),
.format(ngxroot),
encoding='utf-8', mode='w') as myfile:
myfile.write("<?php\nphpinfo();\n?>")
WOFileUtils.chown(self, "{0}22222/htdocs"
.format(WOVariables.wo_webroot),
.format(ngxroot),
WOVariables.wo_php_user,
WOVariables.wo_php_user, recursive=True)
@@ -810,16 +721,21 @@ def post_pref(self, apt_packages, packages):
# PHP7.3 configuration
if set(WOVariables.wo_php73).issubset(set(apt_packages)):
ngxroot = '/var/www/'
# Create log directories
if not os.path.exists('/var/log/php/7.3/'):
Log.debug(self, 'Creating directory /var/log/php/7.3/')
os.makedirs('/var/log/php/7.3/')
if not os.path.isfile('/etc/php/7.3/fpm/php.ini.orig'):
WOFileUtils.copyfile(self, '/etc/php/7.3/fpm/php.ini',
'/etc/php/7.3/fpm/php.ini.orig')
# Parse etc/php/7.3/fpm/php.ini
config = configparser.ConfigParser()
Log.debug(self, "configuring php file /etc/php/7.3/"
"fpm/php.ini")
config.read('/etc/php/7.3/fpm/php.ini')
config.read('/etc/php/7.3/fpm/php.ini.orig')
config['PHP']['expose_php'] = 'Off'
config['PHP']['post_max_size'] = '100M'
config['PHP']['upload_max_filesize'] = '100M'
@@ -853,9 +769,12 @@ def post_pref(self, apt_packages, packages):
wo_php_fpm.close()
# Parse /etc/php/7.3/fpm/pool.d/www.conf
if not os.path.isfile('/etc/php/7.3/fpm/pool.d/www.conf.orig'):
WOFileUtils.copyfile(self, '/etc/php/7.3/fpm/pool.d/www.conf',
'/etc/php/7.3/fpm/pool.d/www.conf.orig')
config = configparser.ConfigParser()
config.read_file(codecs.open('/etc/php/7.3/fpm/'
'pool.d/www.conf',
'pool.d/www.conf.orig',
"r", "utf8"))
config['www']['ping.path'] = '/ping'
config['www']['pm.status_path'] = '/status'
@@ -937,35 +856,35 @@ def post_pref(self, apt_packages, packages):
# PHP and Debug pull configuration
if not os.path.exists('{0}22222/htdocs/fpm/status/'
.format(WOVariables.wo_webroot)):
.format(ngxroot)):
Log.debug(self, 'Creating directory '
'{0}22222/htdocs/fpm/status/ '
.format(WOVariables.wo_webroot))
.format(ngxroot))
os.makedirs('{0}22222/htdocs/fpm/status/'
.format(WOVariables.wo_webroot))
.format(ngxroot))
open('{0}22222/htdocs/fpm/status/debug73'
.format(WOVariables.wo_webroot),
.format(ngxroot),
encoding='utf-8', mode='a').close()
open('{0}22222/htdocs/fpm/status/php73'
.format(WOVariables.wo_webroot),
.format(ngxroot),
encoding='utf-8', mode='a').close()
# Write info.php
if not os.path.exists('{0}22222/htdocs/php/'
.format(WOVariables.wo_webroot)):
.format(ngxroot)):
Log.debug(self, 'Creating directory '
'{0}22222/htdocs/php/ '
.format(WOVariables.wo_webroot))
.format(ngxroot))
os.makedirs('{0}22222/htdocs/php'
.format(WOVariables.wo_webroot))
.format(ngxroot))
with open("{0}22222/htdocs/php/info.php"
.format(WOVariables.wo_webroot),
.format(ngxroot),
encoding='utf-8', mode='w') as myfile:
myfile.write("<?php\nphpinfo();\n?>")
WOFileUtils.chown(self, "{0}22222/htdocs"
.format(WOVariables.wo_webroot),
.format(ngxroot),
WOVariables.wo_php_user,
WOVariables.wo_php_user, recursive=True)
@@ -1195,7 +1114,7 @@ def post_pref(self, apt_packages, packages):
WOService.reload_service(self, 'proftpd')
# Redis configuration
if set(["redis-server"]).issubset(set(apt_packages)):
if set(WOVariables.wo_redis).issubset(set(apt_packages)):
# set redis.conf parameter
# set maxmemory 10% for ram below 512MB and 20% for others
# set maxmemory-policy allkeys-lru

View File

@@ -149,12 +149,7 @@ class WOStackUpgradeController(CementBaseController):
"releases/download/v{0}/wordops-dashboard.tar.gz"
.format(WOVariables.wo_dashboard),
"/var/lib/wo/tmp/wo-dashboard.tar.gz",
"WordOps Dashboard"],
["https://github.com/soerennb/"
"extplorer/archive/v{0}.tar.gz"
.format(WOVariables.wo_extplorer),
"/var/lib/wo/tmp/extplorer.tar.gz",
"eXtplorer"]]
"WordOps Dashboard"]]
if pargs.phpmyadmin:
if os.path.isdir('/var/www/22222/htdocs/db/pma'):
@@ -177,95 +172,94 @@ class WOStackUpgradeController(CementBaseController):
else:
Log.error(self, "Composer isn't installed")
if len(packages) or len(apt_packages):
if len(apt_packages):
Log.info(self, "Your site may be down for few seconds if "
"you are upgrading Nginx, PHP-FPM, MariaDB or Redis")
# Check prompt
if ((not pargs.no_prompt) and (not pargs.force)):
start_upgrade = input("Do you want to continue:[y/N]")
if start_upgrade != "Y" and start_upgrade != "y":
Log.error(self, "Not starting package update")
Log.info(self, "Updating APT packages, please wait...")
# apt-get update
WOAptGet.update(self)
if set(WOVariables.wo_php).issubset(set(apt_packages)):
WOAptGet.remove(self, ['php7.2-fpm'],
auto=False, purge=True)
if set(WOVariables.wo_php73).issubset(set(apt_packages)):
WOAptGet.remove(self, ['php7.3-fpm'],
auto=False, purge=True)
# Update packages
WOAptGet.install(self, apt_packages)
post_pref(self, apt_packages, empty_packages)
# Post Actions after package updates
if len(apt_packages):
Log.info(self, "Your site may be down for few seconds if "
"you are upgrading Nginx, PHP-FPM, MariaDB or Redis")
# Check prompt
if ((not pargs.no_prompt) and (not pargs.force)):
start_upgrade = input("Do you want to continue:[y/N]")
if start_upgrade != "Y" and start_upgrade != "y":
Log.error(self, "Not starting package update")
Log.info(self, "Updating APT packages, please wait...")
# apt-get update
WOAptGet.update(self)
if set(WOVariables.wo_php).issubset(set(apt_packages)):
WOAptGet.remove(self, ['php7.2-fpm'],
auto=False, purge=True)
if set(WOVariables.wo_php73).issubset(set(apt_packages)):
WOAptGet.remove(self, ['php7.3-fpm'],
auto=False, purge=True)
# Update packages
WOAptGet.install(self, apt_packages)
post_pref(self, apt_packages, empty_packages)
# Post Actions after package updates
if len(packages):
if pargs.wpcli:
WOFileUtils.rm(self, '/usr/local/bin/wp')
if len(packages):
if pargs.wpcli:
WOFileUtils.rm(self, '/usr/local/bin/wp')
if pargs.netdata:
WOFileUtils.rm(self, '/var/lib/wo/tmp/kickstart.sh')
if pargs.netdata:
WOFileUtils.rm(self, '/var/lib/wo/tmp/kickstart.sh')
if pargs.dashboard:
WOFileUtils.rm(self, '/var/www/22222/htdocs/index.php')
if pargs.dashboard:
WOFileUtils.rm(self, '/var/www/22222/htdocs/index.php')
Log.debug(self, "Downloading following: {0}".format(packages))
WODownload.download(self, packages)
Log.debug(self, "Downloading following: {0}".format(packages))
WODownload.download(self, packages)
if pargs.wpcli:
WOFileUtils.chmod(self, "/usr/local/bin/wp", 0o775)
if pargs.wpcli:
WOFileUtils.chmod(self, "/usr/local/bin/wp", 0o775)
if pargs.netdata:
Log.info(self, "Upgrading Netdata, please wait...")
WOShellExec.cmd_exec(self, "/bin/bash /var/lib/wo/tmp/"
"kickstart.sh "
"--dont-wait")
if pargs.netdata:
Log.info(self, "Upgrading Netdata, please wait...")
WOShellExec.cmd_exec(self, "/bin/bash /var/lib/wo/tmp/"
"kickstart.sh "
"--dont-wait")
if pargs.dashboard:
Log.debug(self, "Extracting wo-dashboard.tar.gz "
"to location {0}22222/htdocs/"
.format(WOVariables.wo_webroot))
WOExtract.extract(self, '/var/lib/wo/tmp/'
'wo-dashboard.tar.gz',
'{0}22222/htdocs'
.format(WOVariables.wo_webroot))
WOFileUtils.chown(self, "{0}22222/htdocs"
.format(WOVariables.wo_webroot),
WOVariables.wo_php_user,
WOVariables.wo_php_user, recursive=True)
if pargs.dashboard:
Log.debug(self, "Extracting wo-dashboard.tar.gz "
"to location {0}22222/htdocs/"
.format(WOVariables.wo_webroot))
WOExtract.extract(self, '/var/lib/wo/tmp/'
'wo-dashboard.tar.gz',
'{0}22222/htdocs'
.format(WOVariables.wo_webroot))
WOFileUtils.chown(self, "{0}22222/htdocs"
.format(WOVariables.wo_webroot),
WOVariables.wo_php_user,
WOVariables.wo_php_user, recursive=True)
if pargs.composer:
Log.info(self, "Upgrading Composer, please wait...")
WOShellExec.cmd_exec(self, "php -q /var/lib/wo"
"/tmp/composer-install "
"--install-dir=/var/lib/wo/tmp/")
shutil.copyfile('/var/lib/wo/tmp/composer.phar',
'/usr/local/bin/composer')
WOFileUtils.chmod(self, "/usr/local/bin/composer", 0o775)
if pargs.composer:
Log.info(self, "Upgrading Composer, please wait...")
WOShellExec.cmd_exec(self, "php -q /var/lib/wo"
"/tmp/composer-install "
"--install-dir=/var/lib/wo/tmp/")
shutil.copyfile('/var/lib/wo/tmp/composer.phar',
'/usr/local/bin/composer')
WOFileUtils.chmod(self, "/usr/local/bin/composer", 0o775)
if pargs.phpmyadmin:
Log.info(self, "Upgrading phpMyAdmin, please wait...")
WOExtract.extract(self, '/var/lib/wo/tmp/pma.tar.gz',
'/var/lib/wo/tmp/')
shutil.copyfile(('{0}22222/htdocs/db/pma'
'/config.inc.php'
.format(WOVariables.wo_webroot)),
('/var/lib/wo/tmp/phpMyAdmin-{0}'
'-all-languages/config.inc.php'
.format(WOVariables.wo_phpmyadmin))
)
WOFileUtils.rm(self, '{0}22222/htdocs/db/pma'
.format(WOVariables.wo_webroot))
shutil.move('/var/lib/wo/tmp/phpMyAdmin-{0}'
'-all-languages/'
.format(WOVariables.wo_phpmyadmin),
'{0}22222/htdocs/db/pma/'
.format(WOVariables.wo_webroot))
WOFileUtils.chown(self, "{0}22222/htdocs"
.format(WOVariables.wo_webroot),
WOVariables.wo_php_user,
WOVariables.wo_php_user, recursive=True)
if pargs.phpmyadmin:
Log.info(self, "Upgrading phpMyAdmin, please wait...")
WOExtract.extract(self, '/var/lib/wo/tmp/pma.tar.gz',
'/var/lib/wo/tmp/')
shutil.copyfile(('{0}22222/htdocs/db/pma'
'/config.inc.php'
.format(WOVariables.wo_webroot)),
('/var/lib/wo/tmp/phpMyAdmin-{0}'
'-all-languages/config.inc.php'
.format(WOVariables.wo_phpmyadmin))
)
WOFileUtils.rm(self, '{0}22222/htdocs/db/pma'
.format(WOVariables.wo_webroot))
shutil.move('/var/lib/wo/tmp/phpMyAdmin-{0}'
'-all-languages/'
.format(WOVariables.wo_phpmyadmin),
'{0}22222/htdocs/db/pma/'
.format(WOVariables.wo_webroot))
WOFileUtils.chown(self, "{0}22222/htdocs"
.format(WOVariables.wo_webroot),
WOVariables.wo_php_user,
WOVariables.wo_php_user, recursive=True)
Log.info(self, "Successfully updated packages")
else:

View File

@@ -54,6 +54,12 @@ map $request_uri $uri_no_cache {
"~*/resetpass/" 1;
}
map $http_user_agent $mobile_prefix {
default "";
"~*iphone" -mobile;
"~*android" -mobile;
}
# do not cache requests with query strings
map $is_args $query_no_cache {
default 1;

View File

@@ -1,4 +1,4 @@
# WPCE NGINX CONFIGURATION - WO v3.9.7
# WPCE NGINX CONFIGURATION - WO v3.9.8
# DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE
# $cache_uri variable set in /etc/nginx/conf.d/map-wp.conf
# Use cached or actual file if they exists, Otherwise pass request to WordPress
@@ -10,7 +10,7 @@ location ~ \.php$ {
include fastcgi_params;
fastcgi_pass {{upstream}};
}
location ~* /cache/cache-enabler/\.html$ {
location ~ /wp-content/cache/cache-enabler/.*html$ {
etag on;
add_header Vary "Accept-Encoding, Cookie";
access_log off;

View File

@@ -1,16 +1,16 @@
# WPROCKET NGINX CONFIGURATION - WO v3.9.7
# WPROCKET NGINX CONFIGURATION - WO v3.9.8
# DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE
# $cache_uri variable set in /etc/nginx/conf.d/map-wp.conf
# Use cached or actual file if they exists, Otherwise pass request to WordPress
location / {
try_files /wp-content/cache/wp-rocket/$http_host/$cache_uri/index$https_prefix.html $uri $uri/ /index.php$is_args$args;
try_files /wp-content/cache/wp-rocket/$http_host/$cache_uri/index${mobile_prefix}${https_prefix}.html /wp-content/cache/wp-rocket/$http_host/$cache_uri/index${https_prefix}.html $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass {{upstream}};
fastcgi_pass {{upstream}};
}
location ~* /cache/wp-rocket/\.html$ {
location ~ /wp-content/cache/wp-rocket/.*html$ {
etag on;
add_header Vary "Accept-Encoding, Cookie";
access_log off;

View File

@@ -7,16 +7,9 @@ Render Templates
class WOTemplate():
def tmpl_render(self, fileconf, template, data, overwrite=False):
if overwrite:
Log.debug(self, 'Writting the configuration to '
'file {0}'.format(fileconf))
wo_template = open('{0}'.format(fileconf),
encoding='utf-8', mode='w')
self.app.render((data), '{0}'.format(template),
out=wo_template)
wo_template.close()
else:
def tmpl_render(self, fileconf, template, data, overwrite=True):
data = dict(data)
if (not overwrite):
if not os.path.isfile('{0}'.format(fileconf)):
Log.debug(self, 'Writting the configuration to '
'file {0}'.format(fileconf))
@@ -25,3 +18,21 @@ class WOTemplate():
self.app.render((data), '{0}'.format(template),
out=wo_template)
wo_template.close()
else:
if (not os.path.isfile('{0}.custom'
.format(fileconf))):
Log.debug(self, 'Writting the configuration to '
'file {0}'.format(fileconf))
wo_template = open('{0}'.format(fileconf),
encoding='utf-8', mode='w')
self.app.render((data), '{0}'.format(template),
out=wo_template)
wo_template.close()
else:
Log.debug(self, 'Writting the configuration to '
'file {0}.orig'.format(fileconf))
wo_template = open('{0}.orig'.format(fileconf),
encoding='utf-8', mode='w')
self.app.render((data), '{0}'.format(template),
out=wo_template)
wo_template.close()

View File

@@ -1,5 +1,5 @@
"""WordOps core variable module"""
import platform
import distro
import socket
import configparser
import os
@@ -10,7 +10,7 @@ class WOVariables():
"""Intialization of core variables"""
# WordOps version
wo_version = "3.9.8.1"
wo_version = "3.9.8.2"
# WordOps packages versions
wo_wp_cli = "2.2.0"
wo_adminer = "4.7.2"
@@ -25,11 +25,12 @@ class WOVariables():
wo_date = datetime.datetime.now().strftime('%d%b%Y%H%M%S')
# WordOps core variables
wo_distro = os.popen("/usr/bin/lsb_release -si "
"| tr -d \'\\n\'").read().lower()
wo_platform_version = platform.linux_distribution()[1]
wo_platform_codename = os.popen(
"/usr/bin/lsb_release -sc | tr -d \'\\n\'").read()
wo_distro = distro.linux_distribution(
full_distribution_name=False)[0].lower()
wo_platform_version = distro.linux_distribution(
full_distribution_name=False)[1].lower()
wo_platform_codename = distro.linux_distribution(
full_distribution_name=False)[2].lower()
# Get timezone of system
if os.path.isfile('/etc/timezone'):