Rewrite site update with wpredis
This commit is contained in:
@@ -4,6 +4,7 @@ from cement.core import handler, hook
|
|||||||
from wo.core.cron import WOCron
|
from wo.core.cron import WOCron
|
||||||
from wo.core.sslutils import SSL
|
from wo.core.sslutils import SSL
|
||||||
from wo.core.variables import WOVariables
|
from wo.core.variables import WOVariables
|
||||||
|
from wo.core.shellexec import WOShellExec
|
||||||
from wo.core.domainvalidate import ValidateDomain
|
from wo.core.domainvalidate import ValidateDomain
|
||||||
from wo.core.fileutils import WOFileUtils
|
from wo.core.fileutils import WOFileUtils
|
||||||
from wo.cli.plugins.site_functions import *
|
from wo.cli.plugins.site_functions import *
|
||||||
@@ -1610,42 +1611,25 @@ class WOSiteUpdateController(CementBaseController):
|
|||||||
if oldcachetype != 'wpredis' and data['wpredis']:
|
if oldcachetype != 'wpredis' and data['wpredis']:
|
||||||
try:
|
try:
|
||||||
if installwp_plugin(self, 'redis-cache', data):
|
if installwp_plugin(self, 'redis-cache', data):
|
||||||
# search for wp-config.php
|
# add WP_CACHE_KEY_SALT if not already set
|
||||||
if WOFileUtils.isexist(self, "{0}/wp-config.php"
|
try:
|
||||||
.format(wo_site_webroot)):
|
Log.debug(self, "Updating wp-config.php.")
|
||||||
config_path = '{0}/wp-config.php'.format(
|
WOShellExec.cmd_exec(self,
|
||||||
wo_site_webroot)
|
"bash -c \"php {0} --allow-root "
|
||||||
elif WOFileUtils.isexist(self, "{0}/htdocs/wp-config.php"
|
.format(WOVariables.wo_wpcli_path) +
|
||||||
.format(wo_site_webroot)):
|
"config set --add "
|
||||||
config_path = '{0}/htdocs/wp-config.php'.format(
|
"WP_CACHE_KEY_SALT "
|
||||||
wo_site_webroot)
|
"\'{0}:\' --path={1}\""
|
||||||
else:
|
.format(wo_domain,
|
||||||
Log.debug(
|
wo_site_webroot))
|
||||||
self, "Updating wp-config.php failed. "
|
except IOError as e:
|
||||||
"File could not be located.")
|
Log.debug(self, str(e))
|
||||||
Log.error(
|
Log.debug(self, "Updating wp-config.php failed.")
|
||||||
self, "wp-config.php could not be located !!")
|
Log.warn(self, "Updating wp-config.php failed. "
|
||||||
raise SiteError
|
"Could not append:"
|
||||||
|
"\ndefine( \'WP_CACHE_KEY_SALT\', "
|
||||||
if WOShellExec.cmd_exec(self, "grep -q "
|
"\'{0}:\' );".format(wo_domain) +
|
||||||
"\"WP_CACHE_KEY_SALT\" {0}"
|
"\nPlease add manually")
|
||||||
.format(config_path)):
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
wpconfig = open("{0}".format(config_path),
|
|
||||||
encoding='utf-8', mode='a')
|
|
||||||
wpconfig.write("\n\ndefine( \'WP_CACHE_KEY_SALT\',"
|
|
||||||
" \'{0}:\' );".format(wo_domain))
|
|
||||||
wpconfig.close()
|
|
||||||
except IOError as e:
|
|
||||||
Log.debug(self, str(e))
|
|
||||||
Log.debug(self, "Updating wp-config.php failed.")
|
|
||||||
Log.warn(self, "Updating wp-config.php failed. "
|
|
||||||
"Could not append:"
|
|
||||||
"\ndefine( \'WP_CACHE_KEY_SALT\', "
|
|
||||||
"\'{0}:\' );".format(wo_domain) +
|
|
||||||
"\nPlease add manually")
|
|
||||||
except SiteError as e:
|
except SiteError as e:
|
||||||
Log.debug(self, str(e))
|
Log.debug(self, str(e))
|
||||||
Log.info(self, Log.FAIL + "Update site failed."
|
Log.info(self, Log.FAIL + "Update site failed."
|
||||||
|
|||||||
Reference in New Issue
Block a user