cleanup code
This commit is contained in:
@@ -1,6 +1,12 @@
|
|||||||
"""WordOps main application entry point."""
|
"""WordOps main application entry point."""
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
from cement.core import foundation
|
||||||
|
from cement.utils.misc import init_defaults
|
||||||
|
from cement.core.exc import FrameworkError, CaughtSignal
|
||||||
|
from cement.ext.ext_argparse import ArgParseArgumentHandler
|
||||||
|
from wo.core import exc
|
||||||
|
from wo.cli.ext.wo_outputhandler import WOOutputHandler
|
||||||
|
|
||||||
# this has to happen after you import sys, but before you import anything
|
# this has to happen after you import sys, but before you import anything
|
||||||
# from Cement "source: https://github.com/datafolklabs/cement/issues/290"
|
# from Cement "source: https://github.com/datafolklabs/cement/issues/290"
|
||||||
@@ -10,13 +16,6 @@ if '--debug' in sys.argv:
|
|||||||
else:
|
else:
|
||||||
TOGGLE_DEBUG = False
|
TOGGLE_DEBUG = False
|
||||||
|
|
||||||
from cement.core import foundation
|
|
||||||
from cement.utils.misc import init_defaults
|
|
||||||
from cement.core.exc import FrameworkError, CaughtSignal
|
|
||||||
from cement.ext.ext_argparse import ArgParseArgumentHandler
|
|
||||||
from wo.core import exc
|
|
||||||
from wo.cli.ext.wo_outputhandler import WOOutputHandler
|
|
||||||
|
|
||||||
# Application default. Should update config/wo.conf to reflect any
|
# Application default. Should update config/wo.conf to reflect any
|
||||||
# changes, or additions here.
|
# changes, or additions here.
|
||||||
defaults = init_defaults('wo')
|
defaults = init_defaults('wo')
|
||||||
|
|||||||
@@ -193,7 +193,8 @@ class WOStackController(CementBaseController):
|
|||||||
if len(apt_packages):
|
if len(apt_packages):
|
||||||
|
|
||||||
if set(WOVariables.wo_nginx).issubset(set(apt_packages)):
|
if set(WOVariables.wo_nginx).issubset(set(apt_packages)):
|
||||||
if set(["nginx-plus"]).issubset(set(apt_packages)) or set(["nginx"]).issubset(set(apt_packages)):
|
if set(["nginx-plus"]).issubset(set(apt_packages)) or
|
||||||
|
set(["nginx"]).issubset(set(apt_packages)):
|
||||||
# Fix for white screen death with NGINX PLUS
|
# Fix for white screen death with NGINX PLUS
|
||||||
if not WOFileUtils.grep(self, '/etc/nginx/fastcgi_params',
|
if not WOFileUtils.grep(self, '/etc/nginx/fastcgi_params',
|
||||||
'SCRIPT_FILENAME'):
|
'SCRIPT_FILENAME'):
|
||||||
@@ -372,7 +373,8 @@ class WOStackController(CementBaseController):
|
|||||||
|
|
||||||
# Nginx-Plus does not have nginx package structure like this
|
# Nginx-Plus does not have nginx package structure like this
|
||||||
# So creating directories
|
# So creating directories
|
||||||
if set(["nginx-plus"]).issubset(set(apt_packages)) or set(["nginx"]).issubset(set(apt_packages)):
|
if set(["nginx-plus"]).issubset(set(apt_packages)) or
|
||||||
|
set(["nginx"]).issubset(set(apt_packages)):
|
||||||
Log.info(self,
|
Log.info(self,
|
||||||
"Installing WordOpsConfigurations for" "NGINX")
|
"Installing WordOpsConfigurations for" "NGINX")
|
||||||
if not os.path.exists('/etc/nginx/sites-available'):
|
if not os.path.exists('/etc/nginx/sites-available'):
|
||||||
@@ -484,7 +486,8 @@ class WOStackController(CementBaseController):
|
|||||||
WOGit.add(self,
|
WOGit.add(self,
|
||||||
["/etc/nginx"], msg="Adding Nginx into Git")
|
["/etc/nginx"], msg="Adding Nginx into Git")
|
||||||
WOService.reload_service(self, 'nginx')
|
WOService.reload_service(self, 'nginx')
|
||||||
if set(["nginx-plus"]).issubset(set(apt_packages)) or set(["nginx"]).issubset(set(apt_packages)):
|
if set(["nginx-plus"]).issubset(set(apt_packages)) or
|
||||||
|
set(["nginx"]).issubset(set(apt_packages)):
|
||||||
WOShellExec.cmd_exec(self, "sed -i -e 's/^user/#user/'"
|
WOShellExec.cmd_exec(self, "sed -i -e 's/^user/#user/'"
|
||||||
" -e '/^#user/a user"
|
" -e '/^#user/a user"
|
||||||
"\ www-data\;'"
|
"\ www-data\;'"
|
||||||
@@ -558,7 +561,8 @@ class WOStackController(CementBaseController):
|
|||||||
"'\"$http_referer\" \"$http_user_agent\"';\n")
|
"'\"$http_referer\" \"$http_user_agent\"';\n")
|
||||||
# setup nginx common folder for php7
|
# setup nginx common folder for php7
|
||||||
if self.app.pargs.php73:
|
if self.app.pargs.php73:
|
||||||
if os.path.isdir("/etc/nginx/common") and (not os.path.isfile("/etc/nginx/common/php73.conf")):
|
if os.path.isdir("/etc/nginx/common") and
|
||||||
|
(not os.path.isfile("/etc/nginx/common/php73.conf")):
|
||||||
data = dict()
|
data = dict()
|
||||||
Log.debug(self, 'Writting the nginx configuration to '
|
Log.debug(self, 'Writting the nginx configuration to '
|
||||||
'file /etc/nginx/common/locations-php73.conf')
|
'file /etc/nginx/common/locations-php73.conf')
|
||||||
@@ -600,7 +604,8 @@ class WOStackController(CementBaseController):
|
|||||||
out=wo_nginx)
|
out=wo_nginx)
|
||||||
wo_nginx.close()
|
wo_nginx.close()
|
||||||
|
|
||||||
if os.path.isdir("/etc/nginx/common") and (not os.path.isfile("/etc/nginx/common/redis-php73.conf")):
|
if os.path.isdir("/etc/nginx/common") and
|
||||||
|
(not os.path.isfile("/etc/nginx/common/redis-php73.conf")):
|
||||||
data = dict()
|
data = dict()
|
||||||
Log.debug(self, 'Writting the nginx configuration to '
|
Log.debug(self, 'Writting the nginx configuration to '
|
||||||
'file /etc/nginx/common/redis-php73.conf')
|
'file /etc/nginx/common/redis-php73.conf')
|
||||||
@@ -618,7 +623,8 @@ class WOStackController(CementBaseController):
|
|||||||
"upstream debug73 {\nserver 127.0.0.1:9173;\n}\n")
|
"upstream debug73 {\nserver 127.0.0.1:9173;\n}\n")
|
||||||
|
|
||||||
if set(WOVariables.wo_redis).issubset(set(apt_packages)):
|
if set(WOVariables.wo_redis).issubset(set(apt_packages)):
|
||||||
if os.path.isfile("/etc/nginx/nginx.conf") and (not os.path.isfile("/etc/nginx/common/redis-php72.conf")):
|
if os.path.isfile("/etc/nginx/nginx.conf") and
|
||||||
|
(not os.path.isfile("/etc/nginx/common/redis-php72.conf")):
|
||||||
|
|
||||||
data = dict()
|
data = dict()
|
||||||
Log.debug(self, 'Writting the nginx configuration to '
|
Log.debug(self, 'Writting the nginx configuration to '
|
||||||
@@ -639,8 +645,10 @@ class WOStackController(CementBaseController):
|
|||||||
" server 127.0.0.1:6379;\n"
|
" server 127.0.0.1:6379;\n"
|
||||||
" keepalive 10;\n}\n")
|
" keepalive 10;\n}\n")
|
||||||
|
|
||||||
if os.path.isfile("/etc/nginx/nginx.conf") and (not os.path.isfile("/etc/nginx/conf.d/redis.conf")):
|
if os.path.isfile("/etc/nginx/nginx.conf")
|
||||||
with open("/etc/nginx/conf.d/redis.conf", "a") as redis_file:
|
and (not os.path.isfile("/etc/nginx/conf.d/redis.conf")):
|
||||||
|
with open("/etc/nginx/conf.d/redis.conf", "a") as
|
||||||
|
redis_file:
|
||||||
redis_file.write("# Log format Settings\n"
|
redis_file.write("# Log format Settings\n"
|
||||||
"log_format rt_cache_redis "
|
"log_format rt_cache_redis "
|
||||||
"'$remote_addr "
|
"'$remote_addr "
|
||||||
@@ -778,7 +786,8 @@ class WOStackController(CementBaseController):
|
|||||||
WOService.restart_service(self, 'php7.2-fpm')
|
WOService.restart_service(self, 'php7.2-fpm')
|
||||||
|
|
||||||
# PHP7.3 configuration for debian
|
# PHP7.3 configuration for debian
|
||||||
if (WOVariables.wo_platform_distro == 'debian') and set(WOVariables.wo_php73).issubset(set(apt_packages)):
|
if (WOVariables.wo_platform_distro == 'debian') and
|
||||||
|
set(WOVariables.wo_php73).issubset(set(apt_packages)):
|
||||||
# Create log directories
|
# Create log directories
|
||||||
if not os.path.exists('/var/log/php/7.3/'):
|
if not os.path.exists('/var/log/php/7.3/'):
|
||||||
Log.debug(self, 'Creating directory /var/log/php/7.3/')
|
Log.debug(self, 'Creating directory /var/log/php/7.3/')
|
||||||
@@ -903,7 +912,8 @@ class WOStackController(CementBaseController):
|
|||||||
WOService.restart_service(self, 'php7.3-fpm')
|
WOService.restart_service(self, 'php7.3-fpm')
|
||||||
|
|
||||||
# preconfiguration for php7.3
|
# preconfiguration for php7.3
|
||||||
if (WOVariables.wo_platform_distro == 'ubuntu') and set(WOVariables.wo_php73).issubset(set(apt_packages)):
|
if (WOVariables.wo_platform_distro == 'ubuntu') and
|
||||||
|
set(WOVariables.wo_php73).issubset(set(apt_packages)):
|
||||||
# Create log directories
|
# Create log directories
|
||||||
if not os.path.exists('/var/log/php/7.3/'):
|
if not os.path.exists('/var/log/php/7.3/'):
|
||||||
Log.debug(self, 'Creating directory /var/log/php/7.3/')
|
Log.debug(self, 'Creating directory /var/log/php/7.3/')
|
||||||
|
|||||||
@@ -85,15 +85,18 @@ class WOStackStatusController(CementBaseController):
|
|||||||
def stop(self):
|
def stop(self):
|
||||||
"""Stop services"""
|
"""Stop services"""
|
||||||
services = []
|
services = []
|
||||||
if not (self.app.pargs.nginx or self.app.pargs.php or self.app.pargs.php73
|
if not (self.app.pargs.nginx or self.app.pargs.php or
|
||||||
or self.app.pargs.mysql or self.app.pargs.memcached
|
self.app.pargs.php73 or
|
||||||
or self.app.pargs.redis):
|
self.app.pargs.mysql or
|
||||||
|
self.app.pargs.memcached or
|
||||||
|
self.app.pargs.redis):
|
||||||
self.app.pargs.nginx = True
|
self.app.pargs.nginx = True
|
||||||
self.app.pargs.php = True
|
self.app.pargs.php = True
|
||||||
self.app.pargs.mysql = True
|
self.app.pargs.mysql = True
|
||||||
|
|
||||||
if self.app.pargs.nginx:
|
if self.app.pargs.nginx:
|
||||||
if WOAptGet.is_installed(self, 'nginx-custom') or WOAptGet.is_installed(self, 'nginx-mainline'):
|
if WOAptGet.is_installed(self, 'nginx-custom') or
|
||||||
|
WOAptGet.is_installed(self, 'nginx-mainline'):
|
||||||
services = services + ['nginx']
|
services = services + ['nginx']
|
||||||
else:
|
else:
|
||||||
Log.info(self, "Nginx is not installed")
|
Log.info(self, "Nginx is not installed")
|
||||||
@@ -148,15 +151,18 @@ class WOStackStatusController(CementBaseController):
|
|||||||
def restart(self):
|
def restart(self):
|
||||||
"""Restart services"""
|
"""Restart services"""
|
||||||
services = []
|
services = []
|
||||||
if not (self.app.pargs.nginx or self.app.pargs.php or self.app.pargs.php73
|
if not (self.app.pargs.nginx or self.app.pargs.php or
|
||||||
or self.app.pargs.mysql or self.app.pargs.memcached
|
self.app.pargs.php73 or
|
||||||
or self.app.pargs.redis):
|
self.app.pargs.mysql or
|
||||||
|
self.app.pargs.memcached or
|
||||||
|
self.app.pargs.redis):
|
||||||
self.app.pargs.nginx = True
|
self.app.pargs.nginx = True
|
||||||
self.app.pargs.php = True
|
self.app.pargs.php = True
|
||||||
self.app.pargs.mysql = True
|
self.app.pargs.mysql = True
|
||||||
|
|
||||||
if self.app.pargs.nginx:
|
if self.app.pargs.nginx:
|
||||||
if WOAptGet.is_installed(self, 'nginx-custom') or WOAptGet.is_installed(self, 'nginx-mainline'):
|
if WOAptGet.is_installed(self, 'nginx-custom') or
|
||||||
|
WOAptGet.is_installed(self, 'nginx-mainline'):
|
||||||
services = services + ['nginx']
|
services = services + ['nginx']
|
||||||
else:
|
else:
|
||||||
Log.info(self, "Nginx is not installed")
|
Log.info(self, "Nginx is not installed")
|
||||||
@@ -219,7 +225,8 @@ class WOStackStatusController(CementBaseController):
|
|||||||
self.app.pargs.mysql = True
|
self.app.pargs.mysql = True
|
||||||
|
|
||||||
if self.app.pargs.nginx:
|
if self.app.pargs.nginx:
|
||||||
if WOAptGet.is_installed(self, 'nginx-custom') or WOAptGet.is_installed(self, 'nginx-mainline'):
|
if WOAptGet.is_installed(self, 'nginx-custom') or
|
||||||
|
WOAptGet.is_installed(self, 'nginx-mainline'):
|
||||||
services = services + ['nginx']
|
services = services + ['nginx']
|
||||||
else:
|
else:
|
||||||
Log.info(self, "Nginx is not installed")
|
Log.info(self, "Nginx is not installed")
|
||||||
@@ -274,15 +281,18 @@ class WOStackStatusController(CementBaseController):
|
|||||||
def reload(self):
|
def reload(self):
|
||||||
"""Reload service"""
|
"""Reload service"""
|
||||||
services = []
|
services = []
|
||||||
if not (self.app.pargs.nginx or self.app.pargs.php or self.app.pargs.php73
|
if not (self.app.pargs.nginx or self.app.pargs.php or
|
||||||
or self.app.pargs.mysql or self.app.pargs.memcached
|
self.app.pargs.php73 or
|
||||||
or self.app.pargs.redis):
|
self.app.pargs.mysql or
|
||||||
|
self.app.pargs.memcached or
|
||||||
|
self.app.pargs.redis):
|
||||||
self.app.pargs.nginx = True
|
self.app.pargs.nginx = True
|
||||||
self.app.pargs.php = True
|
self.app.pargs.php = True
|
||||||
self.app.pargs.mysql = True
|
self.app.pargs.mysql = True
|
||||||
|
|
||||||
if self.app.pargs.nginx:
|
if self.app.pargs.nginx:
|
||||||
if WOAptGet.is_installed(self, 'nginx-custom') or WOAptGet.is_installed(self, 'nginx-mainline'):
|
if WOAptGet.is_installed(self, 'nginx-custom') or
|
||||||
|
WOAptGet.is_installed(self, 'nginx-mainline'):
|
||||||
services = services + ['nginx']
|
services = services + ['nginx']
|
||||||
else:
|
else:
|
||||||
Log.info(self, "Nginx is not installed")
|
Log.info(self, "Nginx is not installed")
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ class WOSyncController(CementBaseController):
|
|||||||
# search for wp-config.php inside htdocs/
|
# search for wp-config.php inside htdocs/
|
||||||
if not configfiles:
|
if not configfiles:
|
||||||
Log.debug(self, "Config files not found in {0}/ "
|
Log.debug(self, "Config files not found in {0}/ "
|
||||||
.format(wo_site_webroot))
|
.format(wo_site_webroot))
|
||||||
if site.site_type != 'mysql':
|
if site.site_type != 'mysql':
|
||||||
Log.debug(self, "Searching wp-config.php in {0}/htdocs/ "
|
Log.debug(self, "Searching wp-config.php in {0}/htdocs/ "
|
||||||
.format(wo_site_webroot))
|
.format(wo_site_webroot))
|
||||||
configfiles = glob.glob(wo_site_webroot + '/htdocs/wp-config.php')
|
configfiles = glob.glob(wo_site_webroot + '/htdocs/wp-config.php')
|
||||||
|
|
||||||
if configfiles:
|
if configfiles:
|
||||||
|
|||||||
Reference in New Issue
Block a user