Updating logging

This commit is contained in:
VirtuBox
2019-09-05 12:31:34 +02:00
parent 93ef756cb1
commit 4dfdf92d2d
3 changed files with 31 additions and 27 deletions

View File

@@ -1354,7 +1354,7 @@ def setupLetsEncrypt(self, wo_domain_name, subdomain=False, wildcard=False,
if subdomain: if subdomain:
Log.info(self, "Certificate type: Subdomain") Log.info(self, "Certificate type: Subdomain")
Log.info(self, "Validation mode : {0}".format(validation_mode)) Log.info(self, "Validation mode : {0}".format(validation_mode))
Log.wait(self, "Issuing SSL certificate with acme.sh") Log.wait(self, "Issuing SSL cert with acme.sh")
ssl = WOShellExec.cmd_exec(self, "{0} ".format(wo_acme_exec) + ssl = WOShellExec.cmd_exec(self, "{0} ".format(wo_acme_exec) +
"--issue " "--issue "
"-d {0} {1} " "-d {0} {1} "
@@ -1365,7 +1365,7 @@ def setupLetsEncrypt(self, wo_domain_name, subdomain=False, wildcard=False,
elif wildcard: elif wildcard:
Log.info(self, "Certificate type: Wildcard") Log.info(self, "Certificate type: Wildcard")
Log.info(self, "Validation mode : {0}".format(validation_mode)) Log.info(self, "Validation mode : {0}".format(validation_mode))
Log.wait(self, "Issuing SSL certificate with acme.sh") Log.wait(self, "Issuing SSL cert with acme.sh")
ssl = WOShellExec.cmd_exec(self, "{0} ".format(wo_acme_exec) + ssl = WOShellExec.cmd_exec(self, "{0} ".format(wo_acme_exec) +
"--issue " "--issue "
"-d {0} -d '*.{0}' --dns {1} " "-d {0} -d '*.{0}' --dns {1} "
@@ -1376,7 +1376,7 @@ def setupLetsEncrypt(self, wo_domain_name, subdomain=False, wildcard=False,
else: else:
Log.info(self, "Certificate type: Domain + www") Log.info(self, "Certificate type: Domain + www")
Log.info(self, "Validation mode : {0}".format(validation_mode)) Log.info(self, "Validation mode : {0}".format(validation_mode))
Log.wait(self, "Issuing SSL certificate with acme.sh") Log.wait(self, "Issuing SSL cert with acme.sh")
ssl = WOShellExec.cmd_exec(self, "{0} ".format(wo_acme_exec) + ssl = WOShellExec.cmd_exec(self, "{0} ".format(wo_acme_exec) +
"--issue " "--issue "
"-d {0} -d www.{0} {1} " "-d {0} -d www.{0} {1} "
@@ -1384,7 +1384,7 @@ def setupLetsEncrypt(self, wo_domain_name, subdomain=False, wildcard=False,
.format(wo_domain_name, .format(wo_domain_name,
acme_mode, keylenght)) acme_mode, keylenght))
if ssl: if ssl:
Log.valide(self, "Issuing SSL certificate with acme.sh") Log.valide(self, "Issuing SSL cert with acme.sh")
Log.wait(self, "Deploying SSL cert with acme.sh") Log.wait(self, "Deploying SSL cert with acme.sh")
Log.debug(self, "Cert deployment for domain: {0}" Log.debug(self, "Cert deployment for domain: {0}"
.format(wo_domain_name)) .format(wo_domain_name))
@@ -1582,8 +1582,8 @@ def httpsRedirect(self, wo_domain_name, redirect=True, wildcard=False):
"\tlisten [::]:80;\n" + "\tlisten [::]:80;\n" +
"\tserver_name www.{0} {0};\n" "\tserver_name www.{0} {0};\n"
.format(wo_domain_name) + .format(wo_domain_name) +
"\treturn 301 https://{0}" "\treturn 301 https://$host"
.format(wo_domain_name)+"$request_uri;\n}") "$request_uri;\n}")
sslconf.close() sslconf.close()
except IOError as e: except IOError as e:

View File

@@ -50,7 +50,7 @@ class Log:
""" """
Logs info messages with validation step Logs info messages with validation step
""" """
space_to_add = int(40 - len(msg[0:40])) space_to_add = int(30 - len(msg[0:30]))
space = " " space = " "
print( print(
Log.OKBLUE + "{0}".format(msg[0:30]) + Log.OKBLUE + "{0}".format(msg[0:30]) +
@@ -63,10 +63,10 @@ class Log:
""" """
Logs info messages after validation step Logs info messages after validation step
""" """
space_to_add = int(40 - len(msg[0:40])) space_to_add = int(30 - len(msg[0:30]))
space = " " space = " "
print( print(
Log.OKBLUE + "{0}".format(msg[0:40]) + Log.OKBLUE + "{0}".format(msg[0:30]) +
"{0}".format(space[0:space_to_add]) + "{0}".format(space[0:space_to_add]) +
" [" + Log.ENDC + Log.OKGREEN + "OK" + " [" + Log.ENDC + Log.OKGREEN + "OK" +
Log.ENDC + Log.OKBLUE + "]" + Log.ENDC, end=end) Log.ENDC + Log.OKBLUE + "]" + Log.ENDC, end=end)
@@ -77,10 +77,10 @@ class Log:
""" """
Logs info messages after validation step Logs info messages after validation step
""" """
space_to_add = int(40 - len(msg[0:40])) space_to_add = int(30 - len(msg[0:30]))
space = " " space = " "
print( print(
Log.OKBLUE + "{0}".format(msg[0:40]) + Log.OKBLUE + "{0}".format(msg[0:30]) +
"{0}".format(space[0:space_to_add]) + "{0}".format(space[0:space_to_add]) +
" [" + Log.ENDC + Log.FAIL + "OK" + " [" + Log.ENDC + Log.FAIL + "OK" +
Log.ENDC + Log.OKBLUE + "]" + Log.ENDC, end=end) Log.ENDC + Log.OKBLUE + "]" + Log.ENDC, end=end)

View File

@@ -68,22 +68,26 @@ class SSL:
"--allow-root --quiet")) "--allow-root --quiet"))
test_url = re.split(":", wo_siteurl) test_url = re.split(":", wo_siteurl)
if not (test_url[0] == 'https'): if not (test_url[0] == 'https'):
WOShellExec.cmd_exec( Log.wait(self, "Updating site url with https")
self, "{0} option update siteurl " try:
"\'https://{1}\' --allow-root".format( WOShellExec.cmd_exec(
WOVariables.wo_wpcli_path, domain)) self, "{0} option update siteurl "
WOShellExec.cmd_exec( "\'https://{1}\' --allow-root".format(
self, "{0} option update home " WOVariables.wo_wpcli_path, domain))
"\'https://{1}\' --allow-root".format( WOShellExec.cmd_exec(
WOVariables.wo_wpcli_path, domain)) self, "{0} option update home "
WOShellExec.cmd_exec( "\'https://{1}\' --allow-root".format(
self, "{0} search-replace \'http://{0}\'" WOVariables.wo_wpcli_path, domain))
"\'https://{0}\' --skip-columns=guid " WOShellExec.cmd_exec(
"--skip-tables=wp_users" self, "{0} search-replace \'http://{0}\'"
.format(domain)) "\'https://{0}\' --skip-columns=guid "
Log.info( "--skip-tables=wp_users"
self, "Site address updated " .format(domain))
"successfully to https://{0}".format(domain)) except Exception as e:
Log.debug(self, str(e))
Log.failed(self, "Updating site url with https")
else:
Log.valide(self, "Updating site url with https")
# check if a wildcard exist to secure a new subdomain # check if a wildcard exist to secure a new subdomain