From bd5f1cc204a8fc3266b5bdad47873cb407143189 Mon Sep 17 00:00:00 2001 From: Prabuddha Chakraborty Date: Mon, 21 Dec 2015 15:52:06 +0530 Subject: [PATCH] remove cron entry when ssl is disabled --- ee/cli/plugins/site.py | 6 ++++-- ee/core/cron.py | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 6c4ccd1f..4bf3629a 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -750,7 +750,7 @@ class EESiteCreateController(CementBaseController): setupLetsEncrypt(self, ee_domain) httpsRedirect(self,ee_domain) Log.info(self,"Creating Cron Job for cert auto-renewal") - EECron.setcron_daily(self,'ee site update {0} --le=renew --min_expiry_limit 30'.format(ee_domain),'Renew ' + EECron.setcron_daily(self,'ee site update {0} --le=renew --min_expiry_limit 30 2> /dev/null'.format(ee_domain),'Renew ' 'letsencrypt SSL cert. Set by EasyEngine') if not EEService.reload_service(self, 'nginx'): @@ -1316,7 +1316,7 @@ class EESiteUpdateController(CementBaseController): httpsRedirect(self,ee_domain) Log.info(self,"Creating Cron Job for cert auto-renewal") - EECron.setcron_daily(self,'ee site update {0} --le=renew --min_expiry_limit 30'.format(ee_domain),'Renew' + EECron.setcron_daily(self,'ee site update {0} --le=renew --min_expiry_limit 30 2> /dev/null'.format(ee_domain),'Renew' ' letsencrypt SSL cert. Set by EasyEngine') if not EEService.reload_service(self, 'nginx'): @@ -1343,6 +1343,8 @@ class EESiteUpdateController(CementBaseController): if not EEService.reload_service(self, 'nginx'): Log.error(self, "service nginx reload failed. " "check issues with `nginx -t` command") + Log.info(self,"Removing Cron Job set for cert auto-renewal") + EECron.remove_cron(self,'ee site update {0} --le=renew --min_expiry_limit 30 2> /dev/null'.format(ee_domain)) Log.info(self, "Successfully Disabled SSl for Site " " http://{0}".format(ee_domain)) diff --git a/ee/core/cron.py b/ee/core/cron.py index 9dcee086..13d7dcdb 100644 --- a/ee/core/cron.py +++ b/ee/core/cron.py @@ -21,3 +21,14 @@ class EECron(): Log.debug(self, "Cron already exist") + def remove_cron(self,cmd): + if EEShellExec.cmd_exec(self, "crontab -l | grep -q \'{0}\'".format(cmd)): + #root@e:~# crontab -l | sed '/ee site update example.com --le/d' | crontab - + if not EEShellExec.cmd_exec(self, "/bin/bash -c " + "\"crontab " + "-l | sed '/{0}/d'" + "| crontab -\"" + .format(cmd)): + Log.error(self, "Failed to remove crontab entry",False) + else: + Log.debug(self, "Cron not found")