Fix site url change to https

This commit is contained in:
VirtuBox
2019-07-27 21:53:52 +02:00
parent 2ae88ed7b0
commit e6a4611ee6
5 changed files with 30 additions and 20 deletions

View File

@@ -760,7 +760,6 @@ class WOSiteCreateController(CementBaseController):
if self.app.pargs.hsts:
setupHsts(self, wo_domain)
if not WOService.reload_service(self, 'nginx'):
Log.error(self, "service nginx reload failed. "
"check issues with `nginx -t` command")
@@ -1320,7 +1319,6 @@ class WOSiteUpdateController(CementBaseController):
if not WOService.reload_service(self, 'nginx'):
Log.error(self, "service nginx reload failed. "
"check issues with `nginx -t` command")
site_url_https(self, wo_domain, wo_site_webroot)
Log.info(self, "Congratulations! Successfully "
"Configured SSl for Site "
" https://{0}".format(wo_domain))
@@ -1333,6 +1331,9 @@ class WOSiteUpdateController(CementBaseController):
Log.warn(
self, "Your cert already EXPIRED ! "
".PLEASE renew soon . ")
# change site url to https
if data['wp'] is True:
site_url_https(self, data)
elif data['letsencrypt'] is False:
if self.app.pargs.letsencrypt == "off":

View File

@@ -676,26 +676,28 @@ def installwp_plugin(self, plugin_name, data):
return 1
def site_url_https(self, site_webroot='', wo_domain=''):
def site_url_https(self, data):
wo_site_webroot = data['webroot']
wo_domain_name = data['site_name']
Log.info(self, "Checking if site url already use https, please wait...")
WOFileUtils.chdir(self, '{0}/htdocs/'.format(site_webroot))
WOFileUtils.chdir(self, '{0}/htdocs/'.format(wo_site_webroot))
test_site_url = WOShellExec.cmd_exec(self, "php {0} option get siteurl "
.format(WOVariables.wo_wpcli_path) +
"--allow-root --quiet").split(":")
"--allow-root --quiet").split("://")
if not test_site_url[0] == "https":
try:
WOShellExec.cmd_exec(self, "php {0} option update siteurl "
"\"https://{1}\" --allow-root".format(
WOVariables.wo_wpcli_path, wo_domain))
WOVariables.wo_wpcli_path, wo_domain_name))
WOShellExec.cmd_exec(self, "php {0} option update home "
"\"https://{1}\" --allow-root".format(
WOVariables.wo_wpcli_path, wo_domain))
WOVariables.wo_wpcli_path, wo_domain_name))
except CommandExecutionError as e:
Log.debug(self, "{0}".format(e))
raise SiteError("plugin activation failed")
Log.info(
self, "Site address updated "
"successfully to https://{0}".format(wo_domain))
"successfully to https://{0}".format(wo_domain_name))
else:
Log.info(
self, "Site address was already using https")