@@ -753,8 +753,8 @@ def default(self):
753753 setupLetsEncrypt (self , ee_domain )
754754 httpsRedirect (self ,ee_domain )
755755 Log .info (self ,"Creating Cron Job for cert auto-renewal" )
756- EECron .setcron_daily (self ,'ee site update {0} --le=renew --min_expiry_limit 30 2> /dev/null' .format (ee_domain ),'Renew '
757- 'letsencrypt SSL cert. Set by EasyEngine' )
756+ EECron .setcron_weekly (self ,'ee site update --le=renew --all 2> /dev/null' .format (ee_domain ),'Renew all '
757+ ' letsencrypt SSL cert. Set by EasyEngine' )
758758
759759 if not EEService .reload_service (self , 'nginx' ):
760760 Log .error (self , "service nginx reload failed. "
@@ -828,8 +828,6 @@ class Meta:
828828 dict (help = "configure letsencrypt ssl for the site" ,
829829 action = 'store' or 'store_const' ,
830830 choices = ('on' , 'off' , 'renew' ), const = 'on' , nargs = '?' )),
831- (['--min_expiry_limit' ],
832- dict (help = "pass minimum expiry days to renew let's encrypt cert" )),
833831 (['--proxy' ],
834832 dict (help = "update to proxy site" , nargs = '+' )),
835833 (['--experimental' ],
@@ -1090,9 +1088,15 @@ def doupdatesite(self, pargs):
10901088 pargs .pagespeed = False
10911089
10921090 #--letsencrypt=renew code goes here
1093- if pargs .letsencrypt == "renew" and not pargs .min_expiry_limit :
1091+ if pargs .letsencrypt == "renew" and not pargs .all :
1092+ expiry_days = SSL .getExpirationDays (self ,ee_domain )
1093+ min_expiry_days = 30
10941094 if check_ssl :
1095- renewLetsEncrypt (self ,ee_domain )
1095+ if (expiry_days <= min_expiry_days ):
1096+ renewLetsEncrypt (self ,ee_domain )
1097+ else :
1098+ Log .error (self ,"More than 60 days left for certificate Expiry. Not renewing now." )
1099+
10961100 else :
10971101 Log .error (self ,"Cannot RENEW ! SSL is not configured for given site ." )
10981102
@@ -1103,34 +1107,31 @@ def doupdatesite(self, pargs):
11031107 Log .info (self , "Expiration DATE: " + str (SSL .getExpirationDate (self ,ee_domain )))
11041108
11051109 else :
1106- Log .warn (self , "Your cert already EXPIRED ! .PLEASE renew soon . " )
1107-
1108- if pargs .min_expiry_limit :
1109- if not int (pargs .min_expiry_limit )> 0 or not int (pargs .min_expiry_limit )< 90 :
1110- Log .error (self ,'INVALID --min_expiry_limit argument provided. Please use range 1-89 .' )
1110+ Log .warn (self , "Your cert already EXPIRED !. PLEASE renew soon . " )
11111111
1112- if not pargs .letsencrypt == "renew" :
1113- Log .error (self ,'--min_expiry_limit parameter cannot be used as a standalone. Provide --le=renew' )
1112+ if pargs .all and pargs .letsencrypt == "renew" :
11141113
1115- if not check_ssl :
1116- Log .error (self ,"Cannot RENEW ! SSL is not configured for given site ." )
1117-
1118- expiry_days = SSL .getExpirationDays (self ,ee_domain )
1119- min_expiry_days = int (pargs .min_expiry_limit )
1120- if (expiry_days <= min_expiry_days ):
1121- renewLetsEncrypt (self ,ee_domain )
1122- Log .info (self , "SUCCESS: Certificate was successfully renewed For"
1123- " https://{0}" .format (ee_domain ))
1124- else :
1125- Log .info (self , "Not renewing SSL ." )
1126-
1127- if (SSL .getExpirationDays (self ,ee_domain )> 0 ):
1128- Log .info (self , "Your cert will expire within " + str (SSL .getExpirationDays (self ,ee_domain )) + " days." )
1129- Log .info (self , "Expiration DATE: " + str (SSL .getExpirationDate (self ,ee_domain )))
1114+ if check_ssl :
1115+ expiry_days = SSL .getExpirationDays (self ,ee_domain ,True )
1116+ if expiry_days < 0 :
1117+ return 0
1118+ min_expiry_days = 30
1119+ if (expiry_days <= min_expiry_days ):
1120+ renewLetsEncrypt (self ,ee_domain )
1121+ Log .info (self , "SUCCESS: Certificate was successfully renewed For"
1122+ " https://{0}" .format (ee_domain ))
1123+ else :
1124+ Log .info (self ,"More than 60 days left for certificate Expiry. Not renewing now.\n " )
11301125
1126+ if (SSL .getExpirationDays (self ,ee_domain )> 0 ):
1127+ Log .info (self , "Your cert will expire within " + str (SSL .getExpirationDays (self ,ee_domain )) + " days." )
1128+ Log .info (self , "Expiration DATE: \n \n " + str (SSL .getExpirationDate (self ,ee_domain )))
1129+ return 0
1130+ #else:
1131+ # Log.warn(self, "Your cert already EXPIRED ! .PLEASE renew soon . ")
11311132 else :
1132- Log .warn (self , "Your cert already EXPIRED ! .PLEASE renew soon . " )
1133- return 0
1133+ Log .info (self ,"SSL not configured for site http://{0}" . format ( ee_domain ) )
1134+ return 0
11341135
11351136 if pargs .letsencrypt :
11361137 if pargs .letsencrypt == 'on' :
@@ -1300,7 +1301,7 @@ def doupdatesite(self, pargs):
13001301
13011302 if 'proxy' in data .keys () and data ['proxy' ]:
13021303 updateSiteInfo (self , ee_domain , stype = stype , cache = cache ,
1303- hhvm = hhvm , pagespeed = pagespeed )
1304+ hhvm = hhvm , pagespeed = pagespeed , ssl = True if check_site . is_ssl else False )
13041305 Log .info (self , "Successfully updated site"
13051306 " http://{0}" .format (ee_domain ))
13061307 return 0
@@ -1323,7 +1324,7 @@ def doupdatesite(self, pargs):
13231324
13241325 httpsRedirect (self ,ee_domain )
13251326 Log .info (self ,"Creating Cron Job for cert auto-renewal" )
1326- EECron .setcron_daily (self ,'ee site update {0} --le=renew --min_expiry_limit 30 2> /dev/null' .format (ee_domain ),'Renew'
1327+ EECron .setcron_weekly (self ,'ee site update --le=renew --all 2> /dev/null' .format (ee_domain ),'Renew all '
13271328 ' letsencrypt SSL cert. Set by EasyEngine' )
13281329
13291330 if not EEService .reload_service (self , 'nginx' ):
@@ -1350,8 +1351,8 @@ def doupdatesite(self, pargs):
13501351 if not EEService .reload_service (self , 'nginx' ):
13511352 Log .error (self , "service nginx reload failed. "
13521353 "check issues with `nginx -t` command" )
1353- Log .info (self ,"Removing Cron Job set for cert auto-renewal" )
1354- EECron .remove_cron (self ,'ee site update {0} --le=renew --min_expiry_limit 30 2> \/dev\/null' .format (ee_domain ))
1354+ # Log.info(self,"Removing Cron Job set for cert auto-renewal")
1355+ # EECron.remove_cron(self,'ee site update {0} --le=renew --min_expiry_limit 30 2> \/dev\/null'.format(ee_domain))
13551356 Log .info (self , "Successfully Disabled SSl for Site "
13561357 " http://{0}" .format (ee_domain ))
13571358
@@ -1371,7 +1372,7 @@ def doupdatesite(self, pargs):
13711372 "check issues with `nginx -t` command" )
13721373
13731374 updateSiteInfo (self , ee_domain , stype = stype , cache = cache ,
1374- hhvm = hhvm , pagespeed = pagespeed )
1375+ hhvm = hhvm , pagespeed = pagespeed , ssl = True if check_site . is_ssl else False )
13751376
13761377 Log .info (self , "Successfully updated site"
13771378 " http://{0}" .format (ee_domain ))
@@ -1589,10 +1590,10 @@ def doupdatesite(self, pargs):
15891590 db_user = data ['ee_db_user' ],
15901591 db_password = data ['ee_db_pass' ],
15911592 db_host = data ['ee_db_host' ], hhvm = hhvm ,
1592- pagespeed = pagespeed )
1593+ pagespeed = pagespeed , ssl = True if check_site . is_ssl else False )
15931594 else :
15941595 updateSiteInfo (self , ee_domain , stype = stype , cache = cache ,
1595- hhvm = hhvm , pagespeed = pagespeed )
1596+ hhvm = hhvm , pagespeed = pagespeed , ssl = True if check_site . is_ssl else False )
15961597 Log .info (self , "Successfully updated site"
15971598 " http://{0}" .format (ee_domain ))
15981599 return 0
0 commit comments