From 1e659de7668189b3726188135403626ce9b7bfc4 Mon Sep 17 00:00:00 2001 From: Prabuddha Chakraborty Date: Mon, 11 Jan 2016 18:40:02 +0530 Subject: [PATCH] set cron for --le --- ee/cli/plugins/site.py | 10 +++++++--- ee/cli/plugins/site_functions.py | 1 + ee/core/sslutils.py | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 9c49c3af..61359543 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -1112,7 +1112,9 @@ class EESiteUpdateController(CementBaseController): if pargs.all and pargs.letsencrypt == "renew": if check_ssl: - expiry_days = SSL.getExpirationDays(self,ee_domain) + expiry_days = SSL.getExpirationDays(self,ee_domain,True) + if expiry_days < 0: + return 0 min_expiry_days = 30 if (expiry_days <= min_expiry_days): renewLetsEncrypt(self,ee_domain) @@ -1122,10 +1124,12 @@ class EESiteUpdateController(CementBaseController): if (SSL.getExpirationDays(self,ee_domain)>0): Log.info(self, "Your cert will expire within " + str(SSL.getExpirationDays(self,ee_domain)) + " days.") Log.info(self, "Expiration DATE: \n\n" + str(SSL.getExpirationDate(self,ee_domain))) - + return 0 #else: # Log.warn(self, "Your cert already EXPIRED ! .PLEASE renew soon . ") - #return 0 + else: + Log.info(self,"SSL not configured for site http://{0}".format(ee_domain)) + return 0 if pargs.letsencrypt: if pargs.letsencrypt == 'on': diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 68b5a536..b6c8b4cb 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -1212,6 +1212,7 @@ def setupLetsEncrypt(self, ee_domain_name): cloneLetsEncrypt(self) EEFileUtils.chdir(self, '/opt/letsencrypt') EEShellExec.cmd_exec(self, "git pull") + Log.warn(self,"Please Wait while we fetch SSL Certificate for your site.\nIt may take time depending upon network.") ssl = EEShellExec.cmd_exec(self, "./letsencrypt-auto certonly --webroot -w /var/www/{0}/htdocs/ -d {0} -d www.{0} " .format(ee_domain_name) diff --git a/ee/core/sslutils.py b/ee/core/sslutils.py index 305f4f76..d704c71f 100644 --- a/ee/core/sslutils.py +++ b/ee/core/sslutils.py @@ -5,12 +5,14 @@ from ee.core.logging import Log class SSL: - def getExpirationDays(self,domain): + def getExpirationDays(self,domain,returnonerror=False): # check if exist if not os.path.isfile('/etc/letsencrypt/live/{0}/cert.pem' .format(domain)): Log.error(self,'File Not Found : /etc/letsencrypt/live/{0}/cert.pem' .format(domain),False) + if returnonerror: + return -1 Log.error(self, "Check logs for reason " "`tail /var/log/ee/ee.log` & Try Again!!!")