Fix sslutils
This commit is contained in:
@@ -628,55 +628,33 @@ class WOSiteCreateController(CementBaseController):
|
|||||||
|
|
||||||
# Setup WordPress if Wordpress site
|
# Setup WordPress if Wordpress site
|
||||||
if data['wp']:
|
if data['wp']:
|
||||||
if not pargs.vhostonly:
|
if pargs.vhostonly:
|
||||||
try:
|
vhostonly = True
|
||||||
wo_wp_creds = setupwordpress(self, data)
|
|
||||||
# Add database information for site into database
|
|
||||||
updateSiteInfo(self, wo_domain,
|
|
||||||
db_name=data['wo_db_name'],
|
|
||||||
db_user=data['wo_db_user'],
|
|
||||||
db_password=data['wo_db_pass'],
|
|
||||||
db_host=data['wo_db_host'])
|
|
||||||
except SiteError as e:
|
|
||||||
# call cleanup actions on failure
|
|
||||||
Log.debug(self, str(e))
|
|
||||||
Log.info(self, Log.FAIL +
|
|
||||||
"There was a serious error encountered...")
|
|
||||||
Log.info(self, Log.FAIL + "Cleaning up afterwards...")
|
|
||||||
doCleanupAction(self, domain=wo_domain,
|
|
||||||
webroot=data['webroot'],
|
|
||||||
dbname=data['wo_db_name'],
|
|
||||||
dbuser=data['wo_db_user'],
|
|
||||||
dbhost=data['wo_mysql_grant_host'])
|
|
||||||
deleteSiteInfo(self, wo_domain)
|
|
||||||
Log.error(self, "Check the log for details: "
|
|
||||||
"`tail /var/log/wo/wordops.log` "
|
|
||||||
"and please try again")
|
|
||||||
else:
|
else:
|
||||||
try:
|
vhostonly = False
|
||||||
wo_wp_creds = setupwordpress(
|
try:
|
||||||
self, data, vhostonly=True)
|
wo_wp_creds = setupwordpress(self, data, vhostonly)
|
||||||
# Add database information for site into database
|
# Add database information for site into database
|
||||||
updateSiteInfo(self, wo_domain,
|
updateSiteInfo(self, wo_domain,
|
||||||
db_name=data['wo_db_name'],
|
db_name=data['wo_db_name'],
|
||||||
db_user=data['wo_db_user'],
|
db_user=data['wo_db_user'],
|
||||||
db_password=data['wo_db_pass'],
|
db_password=data['wo_db_pass'],
|
||||||
db_host=data['wo_db_host'])
|
db_host=data['wo_db_host'])
|
||||||
except SiteError as e:
|
except SiteError as e:
|
||||||
# call cleanup actions on failure
|
# call cleanup actions on failure
|
||||||
Log.debug(self, str(e))
|
Log.debug(self, str(e))
|
||||||
Log.info(self, Log.FAIL +
|
Log.info(self, Log.FAIL +
|
||||||
"There was a serious error encountered...")
|
"There was a serious error encountered...")
|
||||||
Log.info(self, Log.FAIL + "Cleaning up afterwards...")
|
Log.info(self, Log.FAIL + "Cleaning up afterwards...")
|
||||||
doCleanupAction(self, domain=wo_domain,
|
doCleanupAction(self, domain=wo_domain,
|
||||||
webroot=data['webroot'],
|
webroot=data['webroot'],
|
||||||
dbname=data['wo_db_name'],
|
dbname=data['wo_db_name'],
|
||||||
dbuser=data['wo_db_user'],
|
dbuser=data['wo_db_user'],
|
||||||
dbhost=data['wo_mysql_grant_host'])
|
dbhost=data['wo_mysql_grant_host'])
|
||||||
deleteSiteInfo(self, wo_domain)
|
deleteSiteInfo(self, wo_domain)
|
||||||
Log.error(self, "Check the log for details: "
|
Log.error(self, "Check the log for details: "
|
||||||
"`tail /var/log/wo/wordops.log` "
|
"`tail /var/log/wo/wordops.log` "
|
||||||
"and please try again")
|
"and please try again")
|
||||||
|
|
||||||
# Service Nginx Reload call cleanup if failed to reload nginx
|
# Service Nginx Reload call cleanup if failed to reload nginx
|
||||||
if not WOService.reload_service(self, 'nginx'):
|
if not WOService.reload_service(self, 'nginx'):
|
||||||
@@ -1375,7 +1353,7 @@ class WOSiteUpdateController(CementBaseController):
|
|||||||
if wo_subdomain:
|
if wo_subdomain:
|
||||||
# check if a wildcard cert for the root domain exist
|
# check if a wildcard cert for the root domain exist
|
||||||
Log.debug(self, "checkWildcardExist on *.{0}"
|
Log.debug(self, "checkWildcardExist on *.{0}"
|
||||||
.format(wo_root_domain))
|
.format(wo_root_domain))
|
||||||
isWildcard = checkWildcardExist(self, wo_root_domain)
|
isWildcard = checkWildcardExist(self, wo_root_domain)
|
||||||
Log.debug(self, "isWildcard = {0}".format(isWildcard))
|
Log.debug(self, "isWildcard = {0}".format(isWildcard))
|
||||||
if not os.path.isfile("{0}/conf/nginx/ssl.conf.disabled"):
|
if not os.path.isfile("{0}/conf/nginx/ssl.conf.disabled"):
|
||||||
@@ -1422,9 +1400,10 @@ class WOSiteUpdateController(CementBaseController):
|
|||||||
" https://{0}".format(wo_domain))
|
" https://{0}".format(wo_domain))
|
||||||
if wo_subdomain and isWildcard:
|
if wo_subdomain and isWildcard:
|
||||||
if (SSL.getExpirationDays(self, wo_root_domain) > 0):
|
if (SSL.getExpirationDays(self, wo_root_domain) > 0):
|
||||||
Log.info(self, "Your cert will expire within " +
|
Log.info(
|
||||||
str(SSL.getExpirationDays(self, wo_root_domain)) +
|
self, "Your cert will expire within " +
|
||||||
" days.")
|
str(SSL.getExpirationDays(self, wo_root_domain)) +
|
||||||
|
" days.")
|
||||||
else:
|
else:
|
||||||
Log.warn(
|
Log.warn(
|
||||||
self, "Your cert already EXPIRED ! "
|
self, "Your cert already EXPIRED ! "
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ class WOStackUpgradeController(CementBaseController):
|
|||||||
apt_packages = []
|
apt_packages = []
|
||||||
packages = []
|
packages = []
|
||||||
nginx_packages = []
|
nginx_packages = []
|
||||||
empty_packages = []
|
|
||||||
self.msg = []
|
self.msg = []
|
||||||
pargs = self.app.pargs
|
pargs = self.app.pargs
|
||||||
|
|
||||||
@@ -96,7 +95,6 @@ class WOStackUpgradeController(CementBaseController):
|
|||||||
|
|
||||||
if pargs.nginx:
|
if pargs.nginx:
|
||||||
if WOAptGet.is_installed(self, 'nginx-custom'):
|
if WOAptGet.is_installed(self, 'nginx-custom'):
|
||||||
apt_packages = apt_packages + WOVariables.wo_nginx
|
|
||||||
nginx_packages = nginx_packages + WOVariables.wo_nginx
|
nginx_packages = nginx_packages + WOVariables.wo_nginx
|
||||||
else:
|
else:
|
||||||
Log.info(self, "Nginx Stable is not already installed")
|
Log.info(self, "Nginx Stable is not already installed")
|
||||||
@@ -191,8 +189,8 @@ class WOStackUpgradeController(CementBaseController):
|
|||||||
if start_upgrade != "Y" and start_upgrade != "y":
|
if start_upgrade != "Y" and start_upgrade != "y":
|
||||||
Log.error(self, "Not starting package update")
|
Log.error(self, "Not starting package update")
|
||||||
Log.info(self, "Updating APT packages, please wait...")
|
Log.info(self, "Updating APT packages, please wait...")
|
||||||
if set(WOVariables.wo_nginx).issubset(set(apt_packages)):
|
|
||||||
pre_pref(self, ["nginx-custom", "nginx-wo"])
|
pre_pref(self, nginx_packages)
|
||||||
# apt-get update
|
# apt-get update
|
||||||
WOAptGet.update(self)
|
WOAptGet.update(self)
|
||||||
if set(WOVariables.wo_php).issubset(set(apt_packages)):
|
if set(WOVariables.wo_php).issubset(set(apt_packages)):
|
||||||
@@ -202,8 +200,13 @@ class WOStackUpgradeController(CementBaseController):
|
|||||||
WOAptGet.remove(self, ['php7.3-fpm'],
|
WOAptGet.remove(self, ['php7.3-fpm'],
|
||||||
auto=False, purge=True)
|
auto=False, purge=True)
|
||||||
# Update packages
|
# Update packages
|
||||||
|
if not os.path.isfile(
|
||||||
|
'/etc/apt/preferences.d/nginx-block'):
|
||||||
|
WOAptGet.install(self, nginx_packages)
|
||||||
|
|
||||||
WOAptGet.install(self, apt_packages)
|
WOAptGet.install(self, apt_packages)
|
||||||
post_pref(self, apt_packages, empty_packages, True)
|
post_pref(self, nginx_packages, [], True)
|
||||||
|
post_pref(self, apt_packages, [], True)
|
||||||
# Post Actions after package updates
|
# Post Actions after package updates
|
||||||
|
|
||||||
if len(packages):
|
if len(packages):
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
from wo.core.shellexec import WOShellExec
|
|
||||||
from wo.core.logging import Log
|
from wo.core.logging import Log
|
||||||
|
from wo.core.shellexec import WOShellExec
|
||||||
|
|
||||||
|
|
||||||
class SSL:
|
class SSL:
|
||||||
@@ -18,15 +19,12 @@ class SSL:
|
|||||||
"`tail /var/log/wo/wordops.log` and please try again...")
|
"`tail /var/log/wo/wordops.log` and please try again...")
|
||||||
|
|
||||||
current_date = WOShellExec.cmd_exec_stdout(self, "date -d \"now\" +%s")
|
current_date = WOShellExec.cmd_exec_stdout(self, "date -d \"now\" +%s")
|
||||||
expiration_date = WOShellExec.cmd_exec_stdout(self, "date -d \""
|
expiration_date = WOShellExec.cmd_exec_stdout(
|
||||||
"`/usr/bin/openssl "
|
self, "date -d \""
|
||||||
"x509 -in "
|
"$(openssl x509 -in /etc/letsencrypt/live/"
|
||||||
"/etc/letsencrypt/live/"
|
"{0}/cert.pem -text -noout | grep \"Not After\" "
|
||||||
"{0}/cert.pem"
|
"| cut -c 25-)\" +%s"
|
||||||
" -text -noout|grep "
|
.format(domain))
|
||||||
"\"Not After\"|"
|
|
||||||
"cut -c 25-`\" "
|
|
||||||
"+%s".format(domain))
|
|
||||||
|
|
||||||
days_left = int((int(expiration_date) - int(current_date)) / 86400)
|
days_left = int((int(expiration_date) - int(current_date)) / 86400)
|
||||||
if (days_left > 0):
|
if (days_left > 0):
|
||||||
@@ -45,13 +43,9 @@ class SSL:
|
|||||||
Log.error(self, "Check the WordOps log for more details "
|
Log.error(self, "Check the WordOps log for more details "
|
||||||
"`tail /var/log/wo/wordops.log` and please try again...")
|
"`tail /var/log/wo/wordops.log` and please try again...")
|
||||||
|
|
||||||
expiration_date = WOShellExec.cmd_exec_stdout(self, "date -d "
|
expiration_date = WOShellExec.cmd_exec_stdout(
|
||||||
"\"`/usr/bin/openssl "
|
self, "date -d \"$(/usr/bin/openssl x509 -in "
|
||||||
"x509 -in "
|
"/etc/letsencrypt/live/{0}/cert.pem -text -noout | grep "
|
||||||
"/etc/letsencrypt/live/"
|
"\"Not After\" | cut -c 25-)\" "
|
||||||
"{0}/cert.pem"
|
.format(domain))
|
||||||
" -text -noout|grep "
|
|
||||||
"\"Not After\"|"
|
|
||||||
"cut -c 25-`\" "
|
|
||||||
.format(domain))
|
|
||||||
return expiration_date
|
return expiration_date
|
||||||
|
|||||||
Reference in New Issue
Block a user