diff --git a/wo/cli/plugins/site.py b/wo/cli/plugins/site.py index 1e18b19..b4c027c 100644 --- a/wo/cli/plugins/site.py +++ b/wo/cli/plugins/site.py @@ -628,55 +628,33 @@ class WOSiteCreateController(CementBaseController): # Setup WordPress if Wordpress site if data['wp']: - if not pargs.vhostonly: - try: - 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") + if pargs.vhostonly: + vhostonly = True else: - try: - wo_wp_creds = setupwordpress( - self, data, vhostonly=True) - # 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") + vhostonly = False + try: + wo_wp_creds = setupwordpress(self, data, vhostonly) + # 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") # Service Nginx Reload call cleanup if failed to reload nginx if not WOService.reload_service(self, 'nginx'): @@ -1375,7 +1353,7 @@ class WOSiteUpdateController(CementBaseController): if wo_subdomain: # check if a wildcard cert for the root domain exist Log.debug(self, "checkWildcardExist on *.{0}" - .format(wo_root_domain)) + .format(wo_root_domain)) isWildcard = checkWildcardExist(self, wo_root_domain) Log.debug(self, "isWildcard = {0}".format(isWildcard)) if not os.path.isfile("{0}/conf/nginx/ssl.conf.disabled"): @@ -1422,9 +1400,10 @@ class WOSiteUpdateController(CementBaseController): " https://{0}".format(wo_domain)) if wo_subdomain and isWildcard: if (SSL.getExpirationDays(self, wo_root_domain) > 0): - Log.info(self, "Your cert will expire within " + - str(SSL.getExpirationDays(self, wo_root_domain)) + - " days.") + Log.info( + self, "Your cert will expire within " + + str(SSL.getExpirationDays(self, wo_root_domain)) + + " days.") else: Log.warn( self, "Your cert already EXPIRED ! " diff --git a/wo/cli/plugins/stack_upgrade.py b/wo/cli/plugins/stack_upgrade.py index abfc912..2295a47 100644 --- a/wo/cli/plugins/stack_upgrade.py +++ b/wo/cli/plugins/stack_upgrade.py @@ -62,7 +62,6 @@ class WOStackUpgradeController(CementBaseController): apt_packages = [] packages = [] nginx_packages = [] - empty_packages = [] self.msg = [] pargs = self.app.pargs @@ -96,7 +95,6 @@ class WOStackUpgradeController(CementBaseController): if pargs.nginx: if WOAptGet.is_installed(self, 'nginx-custom'): - apt_packages = apt_packages + WOVariables.wo_nginx nginx_packages = nginx_packages + WOVariables.wo_nginx else: Log.info(self, "Nginx Stable is not already installed") @@ -191,8 +189,8 @@ class WOStackUpgradeController(CementBaseController): if start_upgrade != "Y" and start_upgrade != "y": Log.error(self, "Not starting package update") 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 WOAptGet.update(self) if set(WOVariables.wo_php).issubset(set(apt_packages)): @@ -202,8 +200,13 @@ class WOStackUpgradeController(CementBaseController): WOAptGet.remove(self, ['php7.3-fpm'], auto=False, purge=True) # Update packages + if not os.path.isfile( + '/etc/apt/preferences.d/nginx-block'): + WOAptGet.install(self, nginx_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 if len(packages): diff --git a/wo/core/sslutils.py b/wo/core/sslutils.py index 98f33d5..b164913 100644 --- a/wo/core/sslutils.py +++ b/wo/core/sslutils.py @@ -1,6 +1,7 @@ import os -from wo.core.shellexec import WOShellExec + from wo.core.logging import Log +from wo.core.shellexec import WOShellExec class SSL: @@ -18,15 +19,12 @@ class SSL: "`tail /var/log/wo/wordops.log` and please try again...") current_date = WOShellExec.cmd_exec_stdout(self, "date -d \"now\" +%s") - expiration_date = WOShellExec.cmd_exec_stdout(self, "date -d \"" - "`/usr/bin/openssl " - "x509 -in " - "/etc/letsencrypt/live/" - "{0}/cert.pem" - " -text -noout|grep " - "\"Not After\"|" - "cut -c 25-`\" " - "+%s".format(domain)) + expiration_date = WOShellExec.cmd_exec_stdout( + self, "date -d \"" + "$(openssl x509 -in /etc/letsencrypt/live/" + "{0}/cert.pem -text -noout | grep \"Not After\" " + "| cut -c 25-)\" +%s" + .format(domain)) days_left = int((int(expiration_date) - int(current_date)) / 86400) if (days_left > 0): @@ -45,13 +43,9 @@ class SSL: Log.error(self, "Check the WordOps log for more details " "`tail /var/log/wo/wordops.log` and please try again...") - expiration_date = WOShellExec.cmd_exec_stdout(self, "date -d " - "\"`/usr/bin/openssl " - "x509 -in " - "/etc/letsencrypt/live/" - "{0}/cert.pem" - " -text -noout|grep " - "\"Not After\"|" - "cut -c 25-`\" " - .format(domain)) + expiration_date = WOShellExec.cmd_exec_stdout( + self, "date -d \"$(/usr/bin/openssl x509 -in " + "/etc/letsencrypt/live/{0}/cert.pem -text -noout | grep " + "\"Not After\" | cut -c 25-)\" " + .format(domain)) return expiration_date