Fix wo info and add tweaks to wo stack upgrade

This commit is contained in:
VirtuBox
2019-10-30 04:23:20 +01:00
parent 5cb8ab6268
commit f2d4bcb353
12 changed files with 98 additions and 69 deletions

View File

@@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### v3.9.x - [Unreleased] ### v3.9.x - [Unreleased]
### v3.10.0 - 2019-10-30
#### Added #### Added
- WordOps install is now installed with pip from PyPi (easier, cleaner and safer) inside a wheel - WordOps install is now installed with pip from PyPi (easier, cleaner and safer) inside a wheel
@@ -35,6 +37,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- force-ssl.conf not removed after removing a site - force-ssl.conf not removed after removing a site
- `wo clean --opcache` not working with invalid SSL certificate - `wo clean --opcache` not working with invalid SSL certificate
- `wo stack install --cheat` wasn't working properly previously - `wo stack install --cheat` wasn't working properly previously
- `wo info` failure depending on php-fpm pool name. ConfigParser will now detect the section name.
### v3.9.9.4 - 2019-10-18 ### v3.9.9.4 - 2019-10-18

View File

@@ -13,3 +13,16 @@ where=tests/
[metadata] [metadata]
license-file = LICENSE license-file = LICENSE
[flake8]
ignore = F405,W504,S322,S404,S603,s607,s602
exclude =
# No need to traverse our git directory
.git,
# There's no value in checking cache directories
__pycache__,
# This contains our built documentation
build,
# This contains builds of flake8 that we don't want to check
dist
max-complexity = 10

View File

@@ -225,6 +225,7 @@ echo -e ' various informations '
echo -e "${CGREEN}#############################################${CEND}" echo -e "${CGREEN}#############################################${CEND}"
wp --allow-root --info wp --allow-root --info
wo site info wp.net wo site info wp.net
wo info
echo -e "${CGREEN}#############################################${CEND}" echo -e "${CGREEN}#############################################${CEND}"
echo -e ' wo stack purge ' echo -e ' wo stack purge '
@@ -244,6 +245,3 @@ for stack in $stack_purge; do
fi fi
done done
if [ -n "$1" ]; then
cat /var/log/wo/test.log | ccze -A -p syslog
fi

View File

@@ -79,19 +79,21 @@ class WOInfoController(CementBaseController):
max_execution_time = config['PHP']['max_execution_time'] max_execution_time = config['PHP']['max_execution_time']
config.read('/etc/{0}/fpm/pool.d/www.conf'.format("php/7.2")) config.read('/etc/{0}/fpm/pool.d/www.conf'.format("php/7.2"))
www_listen = config['www-php72']['listen'] wo_sec = (config.sections())[0]
www_ping_path = config['www-php72']['ping.path'] www_listen = config[[wo_sec]]['listen']
www_pm_status_path = config['www-php72']['pm.status_path'] www_ping_path = config[[wo_sec]]['ping.path']
www_pm = config['www-php72']['pm'] www_pm_status_path = config[[wo_sec]]['pm.status_path']
www_pm_max_requests = config['www-php72']['pm.max_requests'] www_pm = config[[wo_sec]]['pm']
www_pm_max_children = config['www-php72']['pm.max_children'] www_pm_max_requests = config[[wo_sec]]['pm.max_requests']
www_pm_start_servers = config['www-php72']['pm.start_servers'] www_pm_max_children = config[[wo_sec]]['pm.max_children']
www_pm_min_spare_servers = config['www-php72']['pm.min_spare_servers'] www_pm_start_servers = config[[wo_sec]]['pm.start_servers']
www_pm_max_spare_servers = config['www-php72']['pm.max_spare_servers'] www_pm_min_spare_servers = config[[wo_sec]]['pm.min_spare_servers']
www_request_terminate_time = (config['www-php72'] www_pm_max_spare_servers = config[[wo_sec]]['pm.max_spare_servers']
www_request_terminate_time = (config[[wo_sec]]
['request_terminate_timeout']) ['request_terminate_timeout'])
try: try:
www_xdebug = (config['www-php72']['php_admin_flag[xdebug.profiler_enable' www_xdebug = (
config[[wo_sec]]['php_admin_flag[xdebug.profiler_enable'
'_trigger]']) '_trigger]'])
except Exception as e: except Exception as e:
Log.debug(self, "{0}".format(e)) Log.debug(self, "{0}".format(e))
@@ -156,19 +158,20 @@ class WOInfoController(CementBaseController):
max_execution_time = config['PHP']['max_execution_time'] max_execution_time = config['PHP']['max_execution_time']
config.read('/etc/php/7.3/fpm/pool.d/www.conf') config.read('/etc/php/7.3/fpm/pool.d/www.conf')
www_listen = config['www-php73']['listen'] wo_sec = (config.sections())[0]
www_ping_path = config['www-php73']['ping.path'] www_listen = config[wo_sec]['listen']
www_pm_status_path = config['www-php73']['pm.status_path'] www_ping_path = config[wo_sec]['ping.path']
www_pm = config['www-php73']['pm'] www_pm_status_path = config[wo_sec]['pm.status_path']
www_pm_max_requests = config['www-php73']['pm.max_requests'] www_pm = config[wo_sec]['pm']
www_pm_max_children = config['www-php73']['pm.max_children'] www_pm_max_requests = config[wo_sec]['pm.max_requests']
www_pm_start_servers = config['www-php73']['pm.start_servers'] www_pm_max_children = config[wo_sec]['pm.max_children']
www_pm_min_spare_servers = config['www-php73']['pm.min_spare_servers'] www_pm_start_servers = config[wo_sec]['pm.start_servers']
www_pm_max_spare_servers = config['www-php73']['pm.max_spare_servers'] www_pm_min_spare_servers = config[wo_sec]['pm.min_spare_servers']
www_request_terminate_time = (config['www-php73'] www_pm_max_spare_servers = config[wo_sec]['pm.max_spare_servers']
www_request_terminate_time = (config[wo_sec]
['request_terminate_timeout']) ['request_terminate_timeout'])
try: try:
www_xdebug = (config['www-php73'] www_xdebug = (config[wo_sec]
['php_admin_flag[xdebug.profiler_enable' ['php_admin_flag[xdebug.profiler_enable'
'_trigger]']) '_trigger]'])
except Exception as e: except Exception as e:
@@ -266,7 +269,8 @@ class WOInfoController(CementBaseController):
if self.app.pargs.nginx: if self.app.pargs.nginx:
if (WOAptGet.is_installed(self, 'nginx-custom') or if (WOAptGet.is_installed(self, 'nginx-custom') or
WOAptGet.is_installed(self, 'nginx-wo')): WOAptGet.is_installed(self, 'nginx-wo') or
(os.path.exists('/usr/bin/nginx'))):
self.info_nginx() self.info_nginx()
else: else:
Log.error(self, "Nginx is not installed") Log.error(self, "Nginx is not installed")

View File

@@ -78,7 +78,7 @@ class WOSiteController(CementBaseController):
Log.error(self, "service nginx reload failed. " Log.error(self, "service nginx reload failed. "
"check issues with `nginx -t` command") "check issues with `nginx -t` command")
else: else:
Log.error(self, "nginx configuration file does not exist") Log.error(self, 'nginx configuration file does not exist')
@expose(help="Disable site example.com") @expose(help="Disable site example.com")
def disable(self): def disable(self):
@@ -509,8 +509,7 @@ class WOSiteCreateController(CementBaseController):
elif data: elif data:
data['php73'] = False data['php73'] = False
if ((not pargs.wpfc) and if ((not pargs.wpfc) and (not pargs.wpsc) and
(not pargs.wpsc) and
(not pargs.wprocket) and (not pargs.wprocket) and
(not pargs.wpce) and (not pargs.wpce) and
(not pargs.wpredis)): (not pargs.wpredis)):
@@ -1294,6 +1293,11 @@ class WOSiteUpdateController(CementBaseController):
letsencrypt = False letsencrypt = False
acme_subdomain = False acme_subdomain = False
acme_wildcard = False acme_wildcard = False
else:
data['letsencrypt'] = False
letsencrypt = False
acme_subdomain = False
acme_wildcard = False
if not (acme_subdomain is True): if not (acme_subdomain is True):
if letsencrypt is check_ssl: if letsencrypt is check_ssl:

View File

@@ -539,6 +539,7 @@ class WOStackController(CementBaseController):
Log.info(self, "Successfully installed packages") Log.info(self, "Successfully installed packages")
else: else:
return self.msg return self.msg
return 0
@expose(help="Remove packages") @expose(help="Remove packages")
def remove(self): def remove(self):

View File

@@ -1016,7 +1016,8 @@ def post_pref(self, apt_packages, packages, upgrade=False):
Log.debug(self, "Setting maxmemory variable to " Log.debug(self, "Setting maxmemory variable to "
"{0} in redis.conf" "{0} in redis.conf"
.format(int(wo_ram * 1024 * 1024 * 0.1))) .format(int(wo_ram * 1024 * 1024 * 0.1)))
WOFileUtils.searchreplace(self, WOFileUtils.searchreplace
(self,
"/etc/redis/redis.conf", "/etc/redis/redis.conf",
"# maxmemory <bytes>", "# maxmemory <bytes>",
"maxmemory {0}" "maxmemory {0}"
@@ -1027,7 +1028,8 @@ def post_pref(self, apt_packages, packages, upgrade=False):
Log.debug(self, "Setting maxmemory variable to {0} " Log.debug(self, "Setting maxmemory variable to {0} "
"in redis.conf" "in redis.conf"
.format(int(wo_ram * 1024 * 1024 * 0.2))) .format(int(wo_ram * 1024 * 1024 * 0.2)))
WOFileUtils.searchreplace(self, WOFileUtils.searchreplace(
self,
"/etc/redis/redis.conf", "/etc/redis/redis.conf",
"# maxmemory <bytes>", "# maxmemory <bytes>",
"maxmemory {0}" "maxmemory {0}"

View File

@@ -3,7 +3,7 @@ import shutil
from cement.core.controller import CementBaseController, expose from cement.core.controller import CementBaseController, expose
from wo.cli.plugins.stack_pref import post_pref, pre_pref from wo.cli.plugins.stack_pref import post_pref, pre_pref, pre_stack
from wo.core.aptget import WOAptGet from wo.core.aptget import WOAptGet
from wo.core.download import WODownload from wo.core.download import WODownload
from wo.core.extract import WOExtract from wo.core.extract import WOExtract
@@ -178,6 +178,7 @@ class WOStackUpgradeController(CementBaseController):
if ((not (apt_packages)) and (not(packages))): if ((not (apt_packages)) and (not(packages))):
self.app.args.print_help() self.app.args.print_help()
else: else:
pre_stack(self)
if (apt_packages): if (apt_packages):
if (("php7.2-fpm" not in apt_packages) and if (("php7.2-fpm" not in apt_packages) and
("php7.3-fpm" not in apt_packages) and ("php7.3-fpm" not in apt_packages) and

View File

@@ -27,8 +27,8 @@ class WODownload():
if req.encoding is None: if req.encoding is None:
req.encoding = 'utf-8' req.encoding = 'utf-8'
out_file.write(req.content) out_file.write(req.content)
Log.info(self, "{0}".format("[" + Log.ENDC + "Done" Log.info(self, "{0}".format("[" + Log.ENDC + "Done" +
+ Log.OKBLUE + "]")) Log.OKBLUE + "]"))
except requests.RequestException as e: except requests.RequestException as e:
Log.debug(self, "[{err}]".format(err=str(e.reason))) Log.debug(self, "[{err}]".format(err=str(e.reason)))
Log.error(self, "Unable to download file, {0}" Log.error(self, "Unable to download file, {0}"

View File

@@ -68,10 +68,12 @@ class WOGit:
"--work-tree={0}".format(path)) "--work-tree={0}".format(path))
if os.path.isdir(path): if os.path.isdir(path):
if not os.path.isdir(path + "/.git"): if not os.path.isdir(path + "/.git"):
Log.error(self, "Unable to find a git repository at {0}" Log.error(
self, "Unable to find a git repository at {0}"
.format(path)) .format(path))
try: try:
Log.debug(self, "WOGit: git stash --include-untracked at {0}" Log.debug(
self, "WOGit: git stash --include-untracked at {0}"
.format(path)) .format(path))
git.stash("push", "--include-untracked", "-m {0}" git.stash("push", "--include-untracked", "-m {0}"
.format(msg)) .format(msg))

View File

@@ -43,7 +43,8 @@ class WOService():
return True return True
else: else:
Log.debug(self, "{0}".format(retcode[1])) Log.debug(self, "{0}".format(retcode[1]))
Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE+"]") Log.info(self, "[" + Log.FAIL +
"Failed" + Log.OKBLUE + "]")
return False return False
except OSError as e: except OSError as e:
Log.debug(self, "{0}".format(e)) Log.debug(self, "{0}".format(e))