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.10.0 - 2019-10-30
#### Added
- 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
- `wo clean --opcache` not working with invalid SSL certificate
- `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

View File

@@ -12,4 +12,17 @@ cover-html-dir=coverage_report/
where=tests/
[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}"
wp --allow-root --info
wo site info wp.net
wo info
echo -e "${CGREEN}#############################################${CEND}"
echo -e ' wo stack purge '
@@ -244,6 +245,3 @@ for stack in $stack_purge; do
fi
done
if [ -n "$1" ]; then
cat /var/log/wo/test.log | ccze -A -p syslog
fi

View File

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

View File

@@ -78,7 +78,7 @@ class WOSiteController(CementBaseController):
Log.error(self, "service nginx reload failed. "
"check issues with `nginx -t` command")
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")
def disable(self):
@@ -106,7 +106,7 @@ class WOSiteController(CementBaseController):
if not os.path.isfile('/etc/nginx/sites-enabled/{0}'
.format(wo_domain)):
Log.debug(self, "Site {0} already disabled".format(wo_domain))
Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE+"]")
Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE + "]")
else:
WOFileUtils.remove_symlink(self,
'/etc/nginx/sites-enabled/{0}'
@@ -176,7 +176,7 @@ class WOSiteController(CementBaseController):
dbname=wo_db_name, dbuser=wo_db_user,
php_version=php_version,
dbpass=wo_db_pass,
ssl=ssl, sslprovider=sslprovider, sslexpiry=sslexpiry,
ssl=ssl, sslprovider=sslprovider, sslexpiry=sslexpiry,
type=sitetype + " " + cachetype + " ({0})"
.format("enabled" if siteinfo.is_enabled else
"disabled"))
@@ -452,7 +452,7 @@ class WOSiteCreateController(CementBaseController):
if stype == 'proxy':
data = dict(site_name=wo_domain, www_domain=wo_www_domain,
static=True, basic=False, php73=False, wp=False,
static=True, basic=False, php73=False, wp=False,
wpfc=False, wpsc=False, wprocket=False, wpce=False,
multisite=False,
wpsubdir=False, webroot=wo_site_webroot)
@@ -463,7 +463,7 @@ class WOSiteCreateController(CementBaseController):
if pargs.php73:
data = dict(site_name=wo_domain, www_domain=wo_www_domain,
static=False, basic=False, php73=True, wp=False,
static=False, basic=False, php73=True, wp=False,
wpfc=False, wpsc=False, wprocket=False, wpce=False,
multisite=False,
wpsubdir=False, webroot=wo_site_webroot)
@@ -471,7 +471,7 @@ class WOSiteCreateController(CementBaseController):
if stype in ['html', 'php']:
data = dict(site_name=wo_domain, www_domain=wo_www_domain,
static=True, basic=False, php73=False, wp=False,
static=True, basic=False, php73=False, wp=False,
wpfc=False, wpsc=False, wprocket=False, wpce=False,
multisite=False,
wpsubdir=False, webroot=wo_site_webroot)
@@ -483,7 +483,7 @@ class WOSiteCreateController(CementBaseController):
elif stype in ['mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
data = dict(site_name=wo_domain, www_domain=wo_www_domain,
static=False, basic=True, wp=False, wpfc=False,
static=False, basic=True, wp=False, wpfc=False,
wpsc=False, wpredis=False, wprocket=False, wpce=False,
multisite=False,
wpsubdir=False, webroot=wo_site_webroot,
@@ -509,8 +509,7 @@ class WOSiteCreateController(CementBaseController):
elif data:
data['php73'] = False
if ((not pargs.wpfc) and
(not pargs.wpsc) and
if ((not pargs.wpfc) and (not pargs.wpsc) and
(not pargs.wprocket) and
(not pargs.wpce) and
(not pargs.wpredis)):
@@ -1131,7 +1130,7 @@ class WOSiteUpdateController(CementBaseController):
if stype == 'php':
data = dict(
site_name=wo_domain, www_domain=wo_www_domain,
static=False, basic=True, wp=False, wpfc=False,
static=False, basic=True, wp=False, wpfc=False,
wpsc=False, wpredis=False, wprocket=False, wpce=False,
multisite=False, wpsubdir=False, webroot=wo_site_webroot,
currsitetype=oldsitetype, currcachetype=oldcachetype)
@@ -1140,7 +1139,7 @@ class WOSiteUpdateController(CementBaseController):
data = dict(
site_name=wo_domain, www_domain=wo_www_domain,
static=False, basic=True, wp=False, wpfc=False,
static=False, basic=True, wp=False, wpfc=False,
wpsc=False, wpredis=False, wprocket=False, wpce=False,
multisite=False, wpsubdir=False, webroot=wo_site_webroot,
wo_db_name='', wo_db_user='', wo_db_pass='',
@@ -1294,6 +1293,11 @@ class WOSiteUpdateController(CementBaseController):
letsencrypt = False
acme_subdomain = False
acme_wildcard = False
else:
data['letsencrypt'] = False
letsencrypt = False
acme_subdomain = False
acme_wildcard = False
if not (acme_subdomain is True):
if letsencrypt is check_ssl:

View File

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

View File

@@ -814,14 +814,14 @@ def post_pref(self, apt_packages, packages, upgrade=False):
"/etc/mysql/my.cnf.default-pkg")
wo_ram = psutil.virtual_memory().total / (1024 * 1024)
# set InnoDB variable depending on the RAM available
wo_ram_innodb = int(wo_ram*0.3)
wo_ram_log_buffer = int(wo_ram_innodb*0.25)
wo_ram_log_size = int(wo_ram_log_buffer*0.5)
wo_ram_innodb = int(wo_ram * 0.3)
wo_ram_log_buffer = int(wo_ram_innodb * 0.25)
wo_ram_log_size = int(wo_ram_log_buffer * 0.5)
if (wo_ram < 2000):
wo_innodb_instance = int(1)
tmp_table_size = int(32)
elif (wo_ram > 2000) and (wo_ram < 64000):
wo_innodb_instance = int(wo_ram/1000)
wo_innodb_instance = int(wo_ram / 1000)
tmp_table_size = int(128)
elif (wo_ram > 64000):
wo_innodb_instance = int(64)
@@ -1015,24 +1015,26 @@ def post_pref(self, apt_packages, packages, upgrade=False):
if wo_ram < 1024:
Log.debug(self, "Setting maxmemory variable to "
"{0} in redis.conf"
.format(int(wo_ram*1024*1024*0.1)))
WOFileUtils.searchreplace(self,
"/etc/redis/redis.conf",
"# maxmemory <bytes>",
"maxmemory {0}"
.format
(int(wo_ram*1024*1024*0.1)))
.format(int(wo_ram * 1024 * 1024 * 0.1)))
WOFileUtils.searchreplace
(self,
"/etc/redis/redis.conf",
"# maxmemory <bytes>",
"maxmemory {0}"
.format
(int(wo_ram * 1024 * 1024 * 0.1)))
else:
Log.debug(self, "Setting maxmemory variable to {0} "
"in redis.conf"
.format(int(wo_ram*1024*1024*0.2)))
WOFileUtils.searchreplace(self,
"/etc/redis/redis.conf",
"# maxmemory <bytes>",
"maxmemory {0}"
.format
(int(wo_ram*1024*1024*0.2)))
.format(int(wo_ram * 1024 * 1024 * 0.2)))
WOFileUtils.searchreplace(
self,
"/etc/redis/redis.conf",
"# maxmemory <bytes>",
"maxmemory {0}"
.format
(int(wo_ram * 1024 * 1024 * 0.2)))
Log.debug(
self, "Setting maxmemory-policy variable to "

View File

@@ -3,7 +3,7 @@ import shutil
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.download import WODownload
from wo.core.extract import WOExtract
@@ -178,6 +178,7 @@ class WOStackUpgradeController(CementBaseController):
if ((not (apt_packages)) and (not(packages))):
self.app.args.print_help()
else:
pre_stack(self)
if (apt_packages):
if (("php7.2-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:
req.encoding = 'utf-8'
out_file.write(req.content)
Log.info(self, "{0}".format("[" + Log.ENDC + "Done"
+ Log.OKBLUE + "]"))
Log.info(self, "{0}".format("[" + Log.ENDC + "Done" +
Log.OKBLUE + "]"))
except requests.RequestException as e:
Log.debug(self, "[{err}]".format(err=str(e.reason)))
Log.error(self, "Unable to download file, {0}"

View File

@@ -21,7 +21,7 @@ class WOGit:
git = git.bake("--git-dir={0}/.git".format(path),
"--work-tree={0}".format(path))
if os.path.isdir(path):
if not os.path.isdir(path+"/.git"):
if not os.path.isdir(path + "/.git"):
try:
Log.debug(self, "WOGit: git init at {0}"
.format(path))
@@ -67,11 +67,13 @@ class WOGit:
git = git.bake("--git-dir={0}/.git".format(path),
"--work-tree={0}".format(path))
if os.path.isdir(path):
if not os.path.isdir(path+"/.git"):
Log.error(self, "Unable to find a git repository at {0}"
if not os.path.isdir(path + "/.git"):
Log.error(
self, "Unable to find a git repository at {0}"
.format(path))
try:
Log.debug(self, "WOGit: git stash --include-untracked at {0}"
Log.debug(
self, "WOGit: git stash --include-untracked at {0}"
.format(path))
git.stash("push", "--include-untracked", "-m {0}"
.format(msg))

View File

@@ -43,7 +43,8 @@ class WOService():
return True
else:
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
except OSError as e:
Log.debug(self, "{0}".format(e))
@@ -65,7 +66,7 @@ class WOService():
return True
else:
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
except OSError as e:
Log.debug(self, "{0}".format(e))

View File

@@ -64,7 +64,7 @@ class WOVar():
# WordOps git configuration management
config = configparser.ConfigParser()
config.read(os.path.expanduser("~")+'/.gitconfig')
config.read(os.path.expanduser("~") + '/.gitconfig')
try:
wo_user = config['user']['name']
wo_email = config['user']['email']
@@ -90,7 +90,7 @@ class WOVar():
git.config("--global", "user.email", "{0}".format(wo_email))
if not os.path.isfile('/root/.gitconfig'):
copy2(os.path.expanduser("~")+'/.gitconfig', '/root/.gitconfig')
copy2(os.path.expanduser("~") + '/.gitconfig', '/root/.gitconfig')
# MySQL hostname
wo_mysql_host = ""
@@ -98,7 +98,7 @@ class WOVar():
if os.path.exists('/etc/mysql/conf.d/my.cnf'):
cnfpath = "/etc/mysql/conf.d/my.cnf"
else:
cnfpath = os.path.expanduser("~")+"/.my.cnf"
cnfpath = os.path.expanduser("~") + "/.my.cnf"
if [cnfpath] == config.read(cnfpath):
try:
wo_mysql_host = config.get('client', 'host')