Merge pull request #242 from WordOps/updating-configuration

v3.11.3
This commit is contained in:
VirtuBox
2020-01-16 21:54:08 +01:00
committed by GitHub
20 changed files with 205 additions and 172 deletions

View File

@@ -8,6 +8,28 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### v3.9.x - [Unreleased] ### v3.9.x - [Unreleased]
### v3.11.3 - 2020-01-16
#### Added
- Backported Nano editor package for Debian/Ubuntu/Raspbian (which support syntax highlighting with `--nanorc`)
- Protect Easy Digital Download files from being accessed directly (PR [#222](https://github.com/WordOps/WordOps/pull/222))
#### Changed
- Improved WordOps performance by removing useless imports in `wo site` code
- Improved opcache cleaning with `wo clean --opcache`
- Force php imagick extension to be enabled after php-fpm install
- Netdata upgrade is now performed with fresh install script downloaded from github
- Update phpmyadmin to v5.0.1
#### Fixed
- Domain IP validation when using CNAME before issuing SSL certificate
- Netdata stack purge/remove not working properly
- Do not backup all databases when purging `--mysql` stack with remote MySQL server
- Netdata upgrade failure due to missing arguments
### v3.11.2 - 2019-12-07 ### v3.11.2 - 2019-12-07
#### Changed #### Changed

35
install
View File

@@ -4,12 +4,12 @@
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# Website: https://wordops.net # Website: https://wordops.net
# GitHub: https://github.com/WordOps/WordOps # GitHub: https://github.com/WordOps/WordOps
# Copyright (c) 2019 - WordOps # Copyright (c) 2019-2020 - WordOps
# This script is licensed under M.I.T # This script is licensed under M.I.T
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# wget -qO wo wops.cc && sudo bash wo # wget -qO wo wops.cc && sudo bash wo
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# Version 3.11.2 - 2019-12-07 # Version 3.11.3 - 2020-01-16
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# CONTENTS # CONTENTS
@@ -427,7 +427,10 @@ wo_install_acme_sh() {
# WordOps install # WordOps install
wo_install() { wo_install() {
cd /usr/local/lib/python3.*/dist-packages || exit 1 local python_ver
python_ver=$(python3 -c "import sys; print(sys.version_info[1])")
cd /usr/local/lib/python3."$python_ver"/dist-packages || exit 1
rm -f /usr/local/bin/wo
if [ "$wo_branch" = "master" ]; then if [ "$wo_branch" = "master" ]; then
python3 -m pip uninstall wo -y python3 -m pip uninstall wo -y
python3 -m pip install --upgrade wordops python3 -m pip install --upgrade wordops
@@ -435,14 +438,14 @@ wo_install() {
python3 -m pip uninstall wo -y python3 -m pip uninstall wo -y
python3 -m pip install -U "git+git://github.com/WordOps/WordOps.git@$wo_branch#egg=wordops" python3 -m pip install -U "git+git://github.com/WordOps/WordOps.git@$wo_branch#egg=wordops"
fi fi
cp -rf /usr/local/lib/python3.*/dist-packages/usr/* /usr/ cp -rf /usr/local/lib/python3."$python_ver"/dist-packages/usr/* /usr/
cp -rn /usr/local/lib/python3.*/dist-packages/etc/* /etc/ cp -rn /usr/local/lib/python3."$python_ver"/dist-packages/etc/* /etc/
cp -f /usr/local/lib/python3.*/dist-packages/etc/bash_completion.d/wo_auto.rc /etc/bash_completion.d/wo_auto.rc cp -f /usr/local/lib/python3."$python_ver"/dist-packages/etc/bash_completion.d/wo_auto.rc /etc/bash_completion.d/wo_auto.rc
} }
# Clone Github repository if it doesn't exist # Clone Github repository if it doesn't exist
wo_travis_install() { wo_travis_install() {
python_ver=$(python3 -c "import sys; print(sys.version_info[1])")
if [ -d ./dist ]; then if [ -d ./dist ]; then
rm -rf dist rm -rf dist
fi fi
@@ -452,9 +455,9 @@ wo_travis_install() {
else else
python3 -m pip install -U "git+git://github.com/WordOps/WordOps.git@$wo_branch#egg=wordops" python3 -m pip install -U "git+git://github.com/WordOps/WordOps.git@$wo_branch#egg=wordops"
fi fi
cp -rf /usr/local/lib/python3.*/dist-packages/usr/* /usr/ cp -rf /usr/local/lib/python3."$python_ver"/dist-packages/usr/* /usr/
cp -rn /usr/local/lib/python3.*/dist-packages/etc/* /etc/ cp -rn /usr/local/lib/python3."$python_ver"/dist-packages/etc/* /etc/
cp -f /usr/local/lib/python3.*/dist-packages/etc/bash_completion.d/wo_auto.rc /etc/bash_completion.d/wo_auto.rc cp -f /usr/local/lib/python3."$python_ver"/dist-packages/etc/bash_completion.d/wo_auto.rc /etc/bash_completion.d/wo_auto.rc
} }
@@ -584,7 +587,9 @@ wo_backup_wo() {
} }
wo_clean_ee() { wo_clean_ee() {
rm -rf /usr/local/bin/ee /etc/bash_completion.d/ee_auto.rc /usr/lib/ee/templates /usr/local/lib/python3.*/dist-packages/ee-*.egg /etc/ee /var/lib/ee local python_ver
python_ver=$(python3 -c "import sys; print(sys.version_info[1])")
rm -rf /usr/local/bin/ee /etc/bash_completion.d/ee_auto.rc /usr/lib/ee/templates /usr/local/lib/python3."$python_ver"/dist-packages/ee-*.egg /etc/ee /var/lib/ee
return 0 return 0
} }
@@ -599,14 +604,18 @@ wo_domain_suffix() {
} }
wo_clean() { wo_clean() {
rm -rf /usr/local/lib/python3.*/dist-packages/{wo-*.egg,cement-*.egg,wordops-*.egg} local python_ver
python_ver=$(python3 -c "import sys; print(sys.version_info[1])")
rm -rf /usr/local/lib/python3."$python_ver"/dist-packages/{wo-*.egg,cement-*.egg,wordops-*.egg}
} }
wo_uninstall() { wo_uninstall() {
local python_ver
python_ver=$(python3 -c "import sys; print(sys.version_info[1])")
if { python3 -m pip list | grep -q "wordops" >/dev/null 2>&1; }; then if { python3 -m pip list | grep -q "wordops" >/dev/null 2>&1; }; then
python3 -m pip uninstall wordops -y python3 -m pip uninstall wordops -y
fi fi
rm -rf /usr/local/lib/python3.*/dist-packages/{pystache-*,cement-2.*,wo-*,wordops-*} /usr/local/bin/wo /etc/bash_completion.d/wo_auto.rc /var/lib/wo /etc/wo /usr/lib/wo/templates rm -rf /usr/local/lib/python3."$python_ver"/dist-packages/{pystache-*,cement-2.*,wo-*,wordops-*} /usr/local/bin/wo /etc/bash_completion.d/wo_auto.rc /var/lib/wo /etc/wo /usr/lib/wo/templates
} }
wo_clean_repo() { wo_clean_repo() {

View File

@@ -2,10 +2,10 @@ cement==2.10.12
pystache>=0.5.4 pystache>=0.5.4
pynginxconfig>=0.3.4 pynginxconfig>=0.3.4
PyMySQL>=0.9.3 PyMySQL>=0.9.3
psutil>=5.6.3 psutil>=5.6.7
sh>=1.12.14 sh>=1.12.14
SQLAlchemy>=1.3.8 SQLAlchemy>=1.3.11
requests>=2.22.0 requests>=2.22.0
distro>=1.4.0 distro>=1.4.0
argcomplete>=1.10.0 argcomplete>=1.10.3
colorlog>=4.0.2 colorlog>=4.0.2

View File

@@ -27,7 +27,7 @@ if os.geteuid() == 0:
os.makedirs('/var/lib/wo/tmp/') os.makedirs('/var/lib/wo/tmp/')
setup(name='wordops', setup(name='wordops',
version='3.11.2', version='3.11.3',
description='An essential toolset that eases server administration', description='An essential toolset that eases server administration',
long_description=LONG, long_description=LONG,
long_description_content_type='text/markdown', long_description_content_type='text/markdown',
@@ -65,12 +65,12 @@ setup(name='wordops',
'pystache >= 0.5.4', 'pystache >= 0.5.4',
'pynginxconfig >= 0.3.4', 'pynginxconfig >= 0.3.4',
'PyMySQL >= 0.9.3', 'PyMySQL >= 0.9.3',
'psutil >= 5.6.3', 'psutil >= 5.6.7',
'sh >= 1.12.14', 'sh >= 1.12.14',
'SQLAlchemy >= 1.3.8', 'SQLAlchemy >= 1.3.11',
'requests >= 2.22.0', 'requests >= 2.22.0',
'distro >= 1.4.0', 'distro >= 1.4.0',
'argcomplete >= 1.10.0', 'argcomplete >= 1.10.3',
'colorlog >= 4.0.2', 'colorlog >= 4.0.2',
], ],
extras_require={ # Optional extras_require={ # Optional

View File

@@ -72,16 +72,22 @@ class WOCleanController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def clean_opcache(self): def clean_opcache(self):
opcache_dir = '/var/www/22222/htdocs/cache/opcache/'
if (os.path.exists('/usr/sbin/nginx') and if (os.path.exists('/usr/sbin/nginx') and
os.path.exists( os.path.exists(
'/var/www/22222/htdocs/cache/opcache/php72.php')): '/var/www/22222/htdocs/cache/opcache')):
try: try:
Log.info(self, "Cleaning opcache") Log.info(self, "Cleaning opcache")
opgui = requests.get( if os.path.exists('{0}php72.php'.format(opcache_dir)):
"http://127.0.0.1/cache/opcache/php72.php") requests.get(
if opgui.status_code != '200' or opgui.status_code != '302': "http://127.0.0.1/cache/opcache/php72.php")
Log.warn(self, 'Cleaning opcache failed') if os.path.exists('{0}php73.php'.format(opcache_dir)):
except Exception as e: requests.get(
"http://127.0.0.1/cache/opcache/php73.php")
if os.path.exists('{0}php74.php'.format(opcache_dir)):
requests.get(
"http://127.0.0.1/cache/opcache/php74.php")
except requests.HTTPError as e:
Log.debug(self, "{0}".format(e)) Log.debug(self, "{0}".format(e))
Log.debug(self, "Unable hit url, " Log.debug(self, "Unable hit url, "
" http://127.0.0.1/cache/opcache/" " http://127.0.0.1/cache/opcache/"

View File

@@ -117,10 +117,10 @@ class WOSecureController(CementBaseController):
Log.info(self, "Please Enter valid port number :") Log.info(self, "Please Enter valid port number :")
port = input("WordOps admin port [22222]:") port = input("WordOps admin port [22222]:")
pargs.user_input = port pargs.user_input = port
WOShellExec.cmd_exec(self, "sed -i \"s/listen.*/listen " data = dict(release=WOVar.wo_version, port=port)
"{port} default_server ssl http2;/\" " WOTemplate.deploy(
"/etc/nginx/sites-available/22222" self, '/etc/nginx/sites-available/22222',
.format(port=pargs.user_input)) '22222.mustache', data)
WOGit.add(self, ["/etc/nginx"], WOGit.add(self, ["/etc/nginx"],
msg="Adding changed secure port into Git") msg="Adding changed secure port into Git")
if not WOService.reload_service(self, 'nginx'): if not WOService.reload_service(self, 'nginx'):
@@ -145,8 +145,8 @@ class WOSecureController(CementBaseController):
Log.debug(self, "{0}".format(e)) Log.debug(self, "{0}".format(e))
user_ip = ['127.0.0.1'] user_ip = ['127.0.0.1']
for ip_addr in user_ip: for ip_addr in user_ip:
if not ("exist_ip_address "+ip_addr in open('/etc/nginx/common/' if not ("exist_ip_address " + ip_addr in open('/etc/nginx/common/'
'acl.conf').read()): 'acl.conf').read()):
WOShellExec.cmd_exec(self, "sed -i " WOShellExec.cmd_exec(self, "sed -i "
"\"/deny/i allow {whitelist_address}\;\"" "\"/deny/i allow {whitelist_address}\;\""
" /etc/nginx/common/acl.conf" " /etc/nginx/common/acl.conf"

View File

@@ -3,8 +3,9 @@ import os
import subprocess import subprocess
from cement.core.controller import CementBaseController, expose from cement.core.controller import CementBaseController, expose
from wo.cli.plugins.site_functions import * from wo.cli.plugins.site_functions import (
from wo.cli.plugins.sitedb import (addNewSite, deleteSiteInfo, getAllsites, check_domain_exists, deleteDB, deleteWebRoot, removeNginxConf, logwatch)
from wo.cli.plugins.sitedb import (deleteSiteInfo, getAllsites,
getSiteInfo, updateSiteInfo) getSiteInfo, updateSiteInfo)
from wo.cli.plugins.site_create import WOSiteCreateController from wo.cli.plugins.site_create import WOSiteCreateController
from wo.cli.plugins.site_update import WOSiteUpdateController from wo.cli.plugins.site_update import WOSiteUpdateController
@@ -132,7 +133,6 @@ class WOSiteController(CementBaseController):
Log.error(self, 'could not input site name') Log.error(self, 'could not input site name')
pargs.site_name = pargs.site_name.strip() pargs.site_name = pargs.site_name.strip()
wo_domain = WODomain.validate(self, pargs.site_name) wo_domain = WODomain.validate(self, pargs.site_name)
wo_www_domain = "www.{0}".format(wo_domain)
(wo_domain_type, wo_root_domain) = WODomain.getlevel( (wo_domain_type, wo_root_domain) = WODomain.getlevel(
self, wo_domain) self, wo_domain)
wo_db_name = '' wo_db_name = ''
@@ -152,7 +152,6 @@ class WOSiteController(CementBaseController):
wo_db_name = siteinfo.db_name wo_db_name = siteinfo.db_name
wo_db_user = siteinfo.db_user wo_db_user = siteinfo.db_user
wo_db_pass = siteinfo.db_password wo_db_pass = siteinfo.db_password
wo_db_host = siteinfo.db_host
php_version = siteinfo.php_version php_version = siteinfo.php_version
@@ -163,7 +162,8 @@ class WOSiteController(CementBaseController):
else: else:
sslprovider = '' sslprovider = ''
sslexpiry = '' sslexpiry = ''
data = dict(domain=wo_domain, webroot=wo_site_webroot, data = dict(domain=wo_domain, domain_type=wo_domain_type,
webroot=wo_site_webroot,
accesslog=access_log, errorlog=error_log, accesslog=access_log, errorlog=error_log,
dbname=wo_db_name, dbuser=wo_db_user, dbname=wo_db_name, dbuser=wo_db_user,
php_version=php_version, php_version=php_version,
@@ -203,7 +203,6 @@ class WOSiteController(CementBaseController):
# TODO Write code for wo site edit command here # TODO Write code for wo site edit command here
pargs.site_name = pargs.site_name.strip() pargs.site_name = pargs.site_name.strip()
wo_domain = WODomain.validate(self, pargs.site_name) wo_domain = WODomain.validate(self, pargs.site_name)
wo_www_domain = "www.{0}".format(wo_domain)
if not check_domain_exists(self, wo_domain): if not check_domain_exists(self, wo_domain):
Log.error(self, "site {0} does not exist".format(wo_domain)) Log.error(self, "site {0} does not exist".format(wo_domain))
@@ -276,12 +275,9 @@ class WOSiteEditController(CementBaseController):
pargs.site_name = pargs.site_name.strip() pargs.site_name = pargs.site_name.strip()
wo_domain = WODomain.validate(self, pargs.site_name) wo_domain = WODomain.validate(self, pargs.site_name)
wo_www_domain = "www.{0}".format(wo_domain)
if not check_domain_exists(self, wo_domain): if not check_domain_exists(self, wo_domain):
Log.error(self, "site {0} does not exist".format(wo_domain)) Log.error(self, "site {0} does not exist".format(wo_domain))
wo_site_webroot = WOVar.wo_webroot + wo_domain
if os.path.isfile('/etc/nginx/sites-available/{0}' if os.path.isfile('/etc/nginx/sites-available/{0}'
.format(wo_domain)): .format(wo_domain)):
try: try:
@@ -341,7 +337,6 @@ class WOSiteDeleteController(CementBaseController):
pargs.site_name = pargs.site_name.strip() pargs.site_name = pargs.site_name.strip()
wo_domain = WODomain.validate(self, pargs.site_name) wo_domain = WODomain.validate(self, pargs.site_name)
wo_www_domain = "www.{0}".format(wo_domain)
wo_db_name = '' wo_db_name = ''
wo_prompt = '' wo_prompt = ''
wo_nginx_prompt = '' wo_nginx_prompt = ''

View File

@@ -1,7 +1,11 @@
import os import os
from cement.core.controller import CementBaseController, expose from cement.core.controller import CementBaseController, expose
from wo.cli.plugins.site_functions import * from wo.cli.plugins.site_functions import (
detSitePar, check_domain_exists, site_package_check,
pre_run_checks, setupdomain, SiteError,
doCleanupAction, setupdatabase, setupwordpress, setwebrootpermissions,
display_cache_settings, copyWildcardCert)
from wo.cli.plugins.sitedb import (addNewSite, deleteSiteInfo, from wo.cli.plugins.sitedb import (addNewSite, deleteSiteInfo,
updateSiteInfo) updateSiteInfo)
from wo.core.acme import WOAcme from wo.core.acme import WOAcme

View File

@@ -891,28 +891,19 @@ def site_package_check(self, stype):
'wpsubdomain']): 'wpsubdomain']):
Log.debug(self, "Setting apt_packages variable for PHP 7.2") 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.2-fpm')):
apt_packages = apt_packages + WOVar.wo_php72 apt_packages = apt_packages + WOVar.wo_php72 + WOVar.wo_php_extra
if not (WOAptGet.is_installed(self, 'php7.3-fpm') or
WOAptGet.is_installed(self, 'php7.4-fpm')):
apt_packages = apt_packages + WOVar.wo_php_extra
if pargs.php73 and stype in ['php73', 'mysql', 'wp', if pargs.php73 and stype in ['php73', 'mysql', 'wp',
'wpsubdir', 'wpsubdomain']: 'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for PHP 7.3") 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.3-fpm'):
apt_packages = apt_packages + WOVar.wo_php73 apt_packages = apt_packages + WOVar.wo_php73 + WOVar.wo_php_extra
if not (WOAptGet.is_installed(self, 'php7.2-fpm') or
WOAptGet.is_installed(self, 'php7.4-fpm')):
apt_packages = apt_packages + WOVar.wo_php_extra
if pargs.php74 and stype in ['php74', 'mysql', 'wp', if pargs.php74 and stype in ['php74', 'mysql', 'wp',
'wpsubdir', 'wpsubdomain']: 'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for PHP 7.4") Log.debug(self, "Setting apt_packages variable for PHP 7.4")
if not WOAptGet.is_installed(self, 'php7.4-fpm'): if not WOAptGet.is_installed(self, 'php7.4-fpm'):
apt_packages = apt_packages + WOVar.wo_php74 apt_packages = apt_packages + WOVar.wo_php74 + WOVar.wo_php_extra
if not (WOAptGet.is_installed(self, 'php7.3-fpm') or
WOAptGet.is_installed(self, 'php7.2-fpm')):
apt_packages = apt_packages + WOVar.wo_php_extra
if stype in ['mysql', 'wp', 'wpsubdir', 'wpsubdomain']: if stype in ['mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for MySQL") Log.debug(self, "Setting apt_packages variable for MySQL")

View File

@@ -4,7 +4,13 @@ import os
from cement.core.controller import CementBaseController, expose from cement.core.controller import CementBaseController, expose
from wo.cli.plugins.site_functions import * from wo.cli.plugins.site_functions import (
detSitePar, site_package_check,
pre_run_checks, setupdomain, SiteError,
setupdatabase, setupwordpress, setwebrootpermissions,
display_cache_settings, copyWildcardCert,
updatewpuserpassword, setupngxblocker, setupwp_plugin,
setupwordpressnetwork, installwp_plugin, sitebackup, uninstallwp_plugin)
from wo.cli.plugins.sitedb import (getAllsites, from wo.cli.plugins.sitedb import (getAllsites,
getSiteInfo, updateSiteInfo) getSiteInfo, updateSiteInfo)
from wo.core.acme import WOAcme from wo.core.acme import WOAcme

View File

@@ -166,7 +166,6 @@ class WOStackController(CementBaseController):
# Nginx # Nginx
if pargs.nginx: if pargs.nginx:
pargs.ngxblocker = True
Log.debug(self, "Setting apt_packages variable for Nginx") Log.debug(self, "Setting apt_packages variable for Nginx")
if not WOAptGet.is_exec(self, 'nginx'): if not WOAptGet.is_exec(self, 'nginx'):
apt_packages = apt_packages + WOVar.wo_nginx apt_packages = apt_packages + WOVar.wo_nginx
@@ -767,9 +766,9 @@ class WOStackController(CementBaseController):
# netdata # netdata
if pargs.netdata: if pargs.netdata:
Log.debug(self, "Removing Netdata") if (os.path.exists('/opt/netdata') or
if os.path.isfile('/opt/netdata/usr/' os.path.exists('/etc/netdata')):
'libexec/netdata/netdata-uninstaller.sh'): Log.debug(self, "Removing Netdata")
packages = packages + ['/var/lib/wo/tmp/kickstart.sh'] packages = packages + ['/var/lib/wo/tmp/kickstart.sh']
# wordops dashboard # wordops dashboard
@@ -814,20 +813,28 @@ class WOStackController(CementBaseController):
WOService.stop_service(self, 'mysql') WOService.stop_service(self, 'mysql')
# Netdata uninstaller # Netdata uninstaller
if (set(['/var/lib/wo/tmp/' if '/var/lib/wo/tmp/kickstart.sh' in packages:
'kickstart.sh']).issubset(set(packages))): if os.path.exists(
if WOVar.wo_distro == 'Raspbian': '/usr/libexec/netdata/netdata-uninstaller.sh'):
Log.debug(self, "Uninstalling Netdata from /etc/netdata")
WOShellExec.cmd_exec( WOShellExec.cmd_exec(
self, "bash /usr/" self, "bash /usr/libexec/netdata/netdata-"
"libexec/netdata/" "uninstaller.sh -y -f",
"netdata-uninstaller.sh -y -f",
errormsg='', log=False) errormsg='', log=False)
packages = packages + ["/etc/netdata"]
elif os.path.exists(
'/opt/netdata/usr/libexec/'
'netdata/netdata-uninstaller.sh'):
Log.debug(self, "Uninstalling Netdata from /opt/netdata")
WOShellExec.cmd_exec(
self, "bash /opt/netdata/usr/libexec/netdata/netdata-"
"uninstaller.sh -y -f")
packages = packages + ["/opt/netdata"]
else: else:
WOShellExec.cmd_exec( Log.debug(self, "Netdata uninstaller not found")
self, "bash /opt/netdata/usr/" if WOShellExec.cmd_exec(self, 'mysqladmin ping'):
"libexec/netdata/" WOMysql.execute(
"netdata-uninstaller.sh -y -f", self, "DELETE FROM mysql.user WHERE User = 'netdata';")
errormsg='', log=False)
if (packages): if (packages):
Log.wait(self, "Removing packages ") Log.wait(self, "Removing packages ")
@@ -1079,11 +1086,11 @@ class WOStackController(CementBaseController):
'{0}22222/htdocs/db/anemometer' '{0}22222/htdocs/db/anemometer'
.format(WOVar.wo_webroot) .format(WOVar.wo_webroot)
] ]
# netdata
if pargs.netdata: if pargs.netdata:
Log.debug(self, "Removing Netdata") if (os.path.exists('/opt/netdata') or
if os.path.isfile('/opt/netdata/usr/' os.path.exists('/etc/netdata')):
'libexec/netdata/netdata-uninstaller.sh'): Log.debug(self, "Removing Netdata")
packages = packages + ['/var/lib/wo/tmp/kickstart.sh'] packages = packages + ['/var/lib/wo/tmp/kickstart.sh']
# wordops dashboard # wordops dashboard
@@ -1123,23 +1130,35 @@ class WOStackController(CementBaseController):
WOService.stop_service(self, 'fail2ban') WOService.stop_service(self, 'fail2ban')
if (set(["mariadb-server"]).issubset(set(apt_packages))): if (set(["mariadb-server"]).issubset(set(apt_packages))):
if (os.path.isfile('/usr/bin/mysql') and if self.app.config.has_section('stack'):
os.path.isdir('/var/lib/mysql')): database_host = self.app.config.get(
'stack', 'ip-address')
else:
database_host = 'na'
if database_host == '127.0.0.1':
WOMysql.backupAll(self) WOMysql.backupAll(self)
WOService.stop_service(self, 'mysql') WOService.stop_service(self, 'mysql')
# Netdata uninstaller # Netdata uninstaller
if (set(['/var/lib/wo/tmp/' if '/var/lib/wo/tmp/kickstart.sh' in packages:
'kickstart.sh']).issubset(set(packages))): if os.path.exists(
if WOVar.wo_distro == 'Raspbian': '/usr/libexec/netdata/netdata-uninstaller.sh'):
WOShellExec.cmd_exec(self, "bash /usr/" Log.debug(self, "Uninstalling Netdata from /etc/netdata")
"libexec/netdata/netdata-" WOShellExec.cmd_exec(
"uninstaller.sh -y -f", self, "bash /usr/libexec/netdata/netdata-"
errormsg='', log=False) "uninstaller.sh -y -f",
errormsg='', log=False)
packages = packages + ["/etc/netdata"]
elif os.path.exists(
'/opt/netdata/usr/libexec/'
'netdata/netdata-uninstaller.sh'):
Log.debug(self, "Uninstalling Netdata from /opt/netdata")
WOShellExec.cmd_exec(
self, "bash /opt/netdata/usr/libexec/netdata/netdata-"
"uninstaller.sh -y -f")
packages = packages + ["/opt/netdata"]
else: else:
WOShellExec.cmd_exec(self, "bash /opt/netdata/usr/" Log.debug(self, "Netdata uninstaller not found")
"libexec/netdata/netdata-"
"uninstaller.sh -y -f")
if WOShellExec.cmd_exec(self, 'mysqladmin ping'): if WOShellExec.cmd_exec(self, 'mysqladmin ping'):
WOMysql.execute( WOMysql.execute(
self, "DELETE FROM mysql.user WHERE User = 'netdata';") self, "DELETE FROM mysql.user WHERE User = 'netdata';")

View File

@@ -156,6 +156,14 @@ def pre_pref(self, apt_packages):
WOVar.wo_platform_codename == 'xenial'): WOVar.wo_platform_codename == 'xenial'):
Log.debug(self, 'Adding ppa for nano') Log.debug(self, 'Adding ppa for nano')
WORepo.add(self, ppa=WOVar.wo_ubuntu_backports) WORepo.add(self, ppa=WOVar.wo_ubuntu_backports)
else:
if not WOFileUtils.grepcheck(
self, '/etc/apt/sources.list/wo-repo.list',
'WordOps'):
Log.info(self, "Adding repository for Nano, please wait...")
Log.debug(self, 'Adding repository for Nano')
WORepo.add_key(self, WOVar.wo_nginx_key)
WORepo.add(self, repo_url=WOVar.wo_nginx_repo)
def post_pref(self, apt_packages, packages, upgrade=False): def post_pref(self, apt_packages, packages, upgrade=False):
@@ -249,34 +257,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
for wo_php in wo_php_version: for wo_php in wo_php_version:
data = dict(upstream="{0}".format(wo_php), data = dict(upstream="{0}".format(wo_php),
release=WOVar.wo_version) release=WOVar.wo_version)
WOTemplate.deploy(self, WOConf.nginxcommon(self)
'{0}/{1}.conf'
.format(ngxcom, wo_php),
'php.mustache', data)
WOTemplate.deploy(
self, '{0}/redis-{1}.conf'.format(ngxcom, wo_php),
'redis.mustache', data)
WOTemplate.deploy(
self, '{0}/wpcommon-{1}.conf'.format(ngxcom, wo_php),
'wpcommon.mustache', data)
WOTemplate.deploy(
self, '{0}/wpfc-{1}.conf'.format(ngxcom, wo_php),
'wpfc.mustache', data)
WOTemplate.deploy(
self, '{0}/wpsc-{1}.conf'.format(ngxcom, wo_php),
'wpsc.mustache', data)
WOTemplate.deploy(
self, '{0}/wprocket-{1}.conf'.format(ngxcom, wo_php),
'wprocket.mustache', data)
WOTemplate.deploy(
self, '{0}/wpce-{1}.conf'.format(ngxcom, wo_php),
'wpce.mustache', data)
except CommandExecutionError as e: except CommandExecutionError as e:
Log.debug(self, "{0}".format(e)) Log.debug(self, "{0}".format(e))
@@ -341,11 +322,14 @@ def post_pref(self, apt_packages, packages, upgrade=False):
os.makedirs('/etc/nginx/sites-enabled') os.makedirs('/etc/nginx/sites-enabled')
# 22222 port settings # 22222 port settings
data = dict(webroot=ngxroot, release=WOVar.wo_version) data = dict(webroot=ngxroot,
WOTemplate.deploy( release=WOVar.wo_version, port='22222')
self, if not WOFileUtils.grepcheck(
'/etc/nginx/sites-available/22222', self, 'WordOps', '/etc/nginx/sites-available/22222'):
'22222.mustache', data, overwrite=True) WOTemplate.deploy(
self,
'/etc/nginx/sites-available/22222',
'22222.mustache', data, overwrite=True)
passwd = ''.join([random.choice passwd = ''.join([random.choice
(string.ascii_letters + string.digits) (string.ascii_letters + string.digits)
for n in range(24)]) for n in range(24)])
@@ -486,7 +470,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
WOShellExec.cmd_exec(self, 'systemctl daemon-reload') WOShellExec.cmd_exec(self, 'systemctl daemon-reload')
WOService.restart_service(self, 'nginx') WOService.restart_service(self, 'nginx')
if set(WOVar.wo_php72).issubset(set(apt_packages)): if 'php7.2-fpm' in apt_packages:
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git") WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
Log.info(self, "Configuring php7.2-fpm") Log.info(self, "Configuring php7.2-fpm")
ngxroot = '/var/www/' ngxroot = '/var/www/'
@@ -627,6 +611,9 @@ def post_pref(self, apt_packages, packages, upgrade=False):
'www-data', 'www-data',
'www-data', recursive=True) 'www-data', recursive=True)
# enable imagick php extension
WOShellExec.cmd_exec(self, 'phpenmod -v ALL imagick')
# check service restart or rollback configuration # check service restart or rollback configuration
if not WOService.restart_service(self, 'php7.2-fpm'): if not WOService.restart_service(self, 'php7.2-fpm'):
WOGit.rollback(self, ["/etc/php"], msg="Rollback PHP") WOGit.rollback(self, ["/etc/php"], msg="Rollback PHP")
@@ -773,6 +760,10 @@ def post_pref(self, apt_packages, packages, upgrade=False):
.format(ngxroot), .format(ngxroot),
'www-data', 'www-data',
'www-data', recursive=True) 'www-data', recursive=True)
# enable imagick php extension
WOShellExec.cmd_exec(self, 'phpenmod -v ALL imagick')
# check service restart or rollback configuration # check service restart or rollback configuration
if not WOService.restart_service(self, 'php7.3-fpm'): if not WOService.restart_service(self, 'php7.3-fpm'):
WOGit.rollback(self, ["/etc/php"], msg="Rollback PHP") WOGit.rollback(self, ["/etc/php"], msg="Rollback PHP")
@@ -919,6 +910,10 @@ def post_pref(self, apt_packages, packages, upgrade=False):
.format(ngxroot), .format(ngxroot),
'www-data', 'www-data',
'www-data', recursive=True) 'www-data', recursive=True)
# enable imagick php extension
WOShellExec.cmd_exec(self, 'phpenmod -v ALL imagick')
# check service restart or rollback configuration # check service restart or rollback configuration
if not WOService.restart_service(self, 'php7.4-fpm'): if not WOService.restart_service(self, 'php7.4-fpm'):
WOGit.rollback(self, ["/etc/php"], msg="Rollback PHP") WOGit.rollback(self, ["/etc/php"], msg="Rollback PHP")
@@ -1386,7 +1381,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
Log.wait(self, "Installing Netdata") Log.wait(self, "Installing Netdata")
WOShellExec.cmd_exec( WOShellExec.cmd_exec(
self, "bash /var/lib/wo/tmp/kickstart.sh " self, "bash /var/lib/wo/tmp/kickstart.sh "
"--dont-wait", errormsg='', log=False) "--dont-wait --no-updates", errormsg='', log=False)
Log.valide(self, "Installing Netdata") Log.valide(self, "Installing Netdata")
if os.path.isdir('/etc/netdata'): if os.path.isdir('/etc/netdata'):
wo_netdata = "/" wo_netdata = "/"

View File

@@ -11,6 +11,7 @@ from wo.core.fileutils import WOFileUtils
from wo.core.logging import Log from wo.core.logging import Log
from wo.core.shellexec import WOShellExec from wo.core.shellexec import WOShellExec
from wo.core.variables import WOVar from wo.core.variables import WOVar
from wo.core.services import WOService
class WOStackUpgradeController(CementBaseController): class WOStackUpgradeController(CementBaseController):
@@ -360,29 +361,14 @@ class WOStackUpgradeController(CementBaseController):
# Netdata # Netdata
if WOAptGet.is_selected(self, 'Netdata', packages): if WOAptGet.is_selected(self, 'Netdata', packages):
WOService.stop_service(self, 'netdata')
Log.wait(self, "Upgrading Netdata") Log.wait(self, "Upgrading Netdata")
# detect static binaries install # detect static binaries install
if os.path.isdir('/opt/netdata'): WOShellExec.cmd_exec(
if os.path.exists( self,
'/opt/netdata/usr/libexec/' "bash /var/lib/wo/tmp/kickstart.sh "
'netdata/netdata-updater.sh'): "--dont-wait --no-updates",
WOShellExec.cmd_exec( errormsg='', log=False)
self, "bash /opt/netdata/usr/"
"libexec/netdata/netdata-"
"updater.sh")
else:
WOShellExec.cmd_exec(
self, "bash /var/lib/wo/tmp/kickstart.sh")
# detect install from source
elif os.path.isdir('/etc/netdata'):
if os.path.exists(
'/usr/libexec/netdata/netdata-updater.sh'):
WOShellExec.cmd_exec(
self,
'bash /usr/libexec/netdata/netdata-updater.sh')
else:
WOShellExec.cmd_exec(
self, "bash /var/lib/wo/tmp/kickstart.sh")
Log.valide(self, "Upgrading Netdata") Log.valide(self, "Upgrading Netdata")
if WOAptGet.is_selected(self, 'WordOps Dashboard', packages): if WOAptGet.is_selected(self, 'WordOps Dashboard', packages):

View File

@@ -2,13 +2,13 @@
server { server {
listen 22222 default_server ssl http2; listen {{port}} default_server ssl http2;
access_log /var/log/nginx/22222.access.log rt_cache; access_log /var/log/nginx/22222.access.log rt_cache;
error_log /var/log/nginx/22222.error.log; error_log /var/log/nginx/22222.error.log;
# Force HTTP to HTTPS # Force HTTP to HTTPS
error_page 497 =200 https://$host:22222$request_uri; error_page 497 =200 https://$host:{{port}}$request_uri;
root {{webroot}}22222/htdocs; root {{webroot}}22222/htdocs;
index index.php index.htm index.html; index index.php index.htm index.html;

View File

@@ -1,4 +1,5 @@
Information about {{domain}}: Information about {{domain}} ({{domain_type}}):
Nginx configuration {{type}} {{enable}} Nginx configuration {{type}} {{enable}}
{{#php_version}}PHP Version {{php_version}}{{/php_version}} {{#php_version}}PHP Version {{php_version}}{{/php_version}}

View File

@@ -4,6 +4,12 @@
upstream phpstatus { upstream phpstatus {
server unix:/run/php/php72-fpm.sock; server unix:/run/php/php72-fpm.sock;
} }
upstream php73opcache {
server unix:/run/php/php73-fpm.sock;
}
upstream php74opcache {
server unix:/run/php/php74-fpm.sock;
}
{{/phpconf}} {{/phpconf}}
server { server {
listen 127.0.0.1:80; listen 127.0.0.1:80;
@@ -33,21 +39,21 @@ server {
location /cache/opcache/php72.php { location /cache/opcache/php72.php {
try_files $uri =404; try_files $uri =404;
include fastcgi_params; include fastcgi_params;
fastcgi_pass php72; fastcgi_pass phpstatus;
access_log off; access_log off;
log_not_found off; log_not_found off;
} }
location /cache/opcache/php73.php { location /cache/opcache/php73.php {
try_files $uri =404; try_files $uri =404;
include fastcgi_params; include fastcgi_params;
fastcgi_pass php73; fastcgi_pass php73opcache;
access_log off; access_log off;
log_not_found off; log_not_found off;
} }
location /cache/opcache/php74.php { location /cache/opcache/php74.php {
try_files $uri =404; try_files $uri =404;
include fastcgi_params; include fastcgi_params;
fastcgi_pass php74; fastcgi_pass php74opcache;
access_log off; access_log off;
log_not_found off; log_not_found off;
} }

View File

@@ -48,7 +48,7 @@ location /wp-content/uploads {
try_files $uri$webp_suffix $uri =404; try_files $uri$webp_suffix $uri =404;
} }
location ~* \.(php|gz|log|zip|tar|rar|xz)$ { location ~* \.(php|gz|log|zip|tar|rar|xz)$ {
#Prevent Direct Access Of PHP Files & BackupsFrom Web Browsers #Prevent Direct Access Of PHP Files & Backups from Web Browsers
deny all; deny all;
} }
} }

View File

@@ -188,20 +188,8 @@ class WOAcme:
"""Check if a list of domains point to the server IP""" """Check if a list of domains point to the server IP"""
server_ip = requests.get('https://v4.wordops.eu/').text server_ip = requests.get('https://v4.wordops.eu/').text
for domain in acme_domains: for domain in acme_domains:
url = ( domain_ip = requests.get('http://v4.wordops.eu/dns/{0}/'
"https://cloudflare-dns.com/dns-query?name={0}&type=A" .format(domain)).text
.format(domain))
headers = {
'accept': 'application/dns-json'
}
try:
response = requests.get(url, headers=headers).json()
domain_ip = response["Answer"][0]['data']
except requests.RequestException:
Log.error(
self, 'Resolving domain IP failed.\n'
'The domain {0} do not exist or a DNS record is missing'
.format(domain))
if(not domain_ip == server_ip): if(not domain_ip == server_ip):
Log.warn( Log.warn(
self, "{0}".format(domain) + self, "{0}".format(domain) +
@@ -228,8 +216,13 @@ class WOAcme:
if wo_domain_name == row[0]: if wo_domain_name == row[0]:
# check if cert expiration exist # check if cert expiration exist
if not row[3] == '': if not row[3] == '':
return True acme_cert = True
certfile.close() certfile.close()
if acme_cert is True:
if os.path.exists(
'/etc/letsencrypt/live/{0}/fullchain.pem'
.format(wo_domain_name)):
return True
return False return False
def removeconf(self, domain): def removeconf(self, domain):

View File

@@ -14,9 +14,9 @@ class WOConf():
"""nginx common configuration deployment""" """nginx common configuration deployment"""
wo_php_version = ["php72", "php73", "php74"] wo_php_version = ["php72", "php73", "php74"]
ngxcom = '/etc/nginx/common' ngxcom = '/etc/nginx/common'
if not os.path.exists(ngxcom):
os.mkdir(ngxcom)
for wo_php in wo_php_version: for wo_php in wo_php_version:
if not os.path.exists(ngxcom):
os.mkdir(ngxcom)
Log.debug(self, 'deploying templates for {0}'.format(wo_php)) Log.debug(self, 'deploying templates for {0}'.format(wo_php))
data = dict(upstream="{0}".format(wo_php), data = dict(upstream="{0}".format(wo_php),
release=WOVar.wo_version) release=WOVar.wo_version)

View File

@@ -14,11 +14,11 @@ class WOVar():
"""Intialization of core variables""" """Intialization of core variables"""
# WordOps version # WordOps version
wo_version = "3.11.2" wo_version = "3.11.3"
# WordOps packages versions # WordOps packages versions
wo_wp_cli = "2.4.0" wo_wp_cli = "2.4.0"
wo_adminer = "4.7.5" wo_adminer = "4.7.5"
wo_phpmyadmin = "4.9.2" wo_phpmyadmin = "5.0.1"
wo_extplorer = "2.1.13" wo_extplorer = "2.1.13"
wo_dashboard = "1.2" wo_dashboard = "1.2"