Browse Source

--letencrypt feature

develop
Prabuddha Chakraborty 9 years ago
parent
commit
a631259dc5
  1. 76
      ee/cli/plugins/site.py

76
ee/cli/plugins/site.py

@ -813,7 +813,7 @@ class EESiteUpdateController(CementBaseController):
def doupdatesite(self, pargs): def doupdatesite(self, pargs):
hhvm = None hhvm = None
pagespeed = None pagespeed = None
letsencrypt = None letsencrypt = False
data = dict() data = dict()
try: try:
@ -1013,12 +1013,6 @@ class EESiteUpdateController(CementBaseController):
data['pagespeed'] = False data['pagespeed'] = False
pagespeed = False pagespeed = False
if pargs.letsencrypt != 'off':
data['letsencrypt'] = True
letsencrypt = True
elif pargs.letsencrypt == 'off':
data['letsencrypt'] = False
letsencrypt = False
if pargs.pagespeed: if pargs.pagespeed:
if pagespeed is old_pagespeed: if pagespeed is old_pagespeed:
@ -1031,6 +1025,13 @@ class EESiteUpdateController(CementBaseController):
pargs.pagespeed = False pargs.pagespeed = False
if pargs.letsencrypt: if pargs.letsencrypt:
if pargs.letsencrypt != 'off':
data['letsencrypt'] = True
letsencrypt = True
elif pargs.letsencrypt == 'off':
data['letsencrypt'] = False
letsencrypt = False
if letsencrypt is check_ssl: if letsencrypt is check_ssl:
if letsencrypt is False: if letsencrypt is False:
Log.info(self, "SSl is not configured for given " Log.info(self, "SSl is not configured for given "
@ -1067,14 +1068,6 @@ class EESiteUpdateController(CementBaseController):
data['pagespeed'] = False data['pagespeed'] = False
pagespeed = False pagespeed = False
if data and (not pargs.letsencrypt):
if check_ssl is True:
data['letsencrypt'] = True
letsencrypt = True
else:
data['letsencrypt'] = False
letsencrypt = False
if pargs.pagespeed=="on" or pargs.hhvm=="on" or pargs.letsencrypt=="on": if pargs.pagespeed=="on" or pargs.hhvm=="on" or pargs.letsencrypt=="on":
if pargs.hhvm == "on": if pargs.hhvm == "on":
if (not pargs.experimental): if (not pargs.experimental):
@ -1117,6 +1110,7 @@ class EESiteUpdateController(CementBaseController):
pagespeed = True pagespeed = True
if pargs.letsencrypt == "on": if pargs.letsencrypt == "on":
if (not pargs.experimental): if (not pargs.experimental):
Log.info(self, "Letsencrypt is currently in beta phase." Log.info(self, "Letsencrypt is currently in beta phase."
" \nDo you wish" " \nDo you wish"
@ -1136,13 +1130,6 @@ class EESiteUpdateController(CementBaseController):
letsencrypt = True letsencrypt = True
if pargs.letsencrypt:
if data['letsencrypt'] is True:
setupLetsEncrypt(self, ee_domain)
updateSiteInfo(self, ee_domain, ssl=True)
elif data['letsencrypt'] is False:
pass
#--letsencrypt=off code here
if pargs.wpredis and data['currcachetype'] != 'wpredis': if pargs.wpredis and data['currcachetype'] != 'wpredis':
if (not pargs.experimental): if (not pargs.experimental):
@ -1172,15 +1159,15 @@ class EESiteUpdateController(CementBaseController):
data['ee_db_user'] = check_site.db_user data['ee_db_user'] = check_site.db_user
data['ee_db_pass'] = check_site.db_password data['ee_db_pass'] = check_site.db_password
data['ee_db_host'] = check_site.db_host data['ee_db_host'] = check_site.db_host
data['old_pagespeed_status'] = check_site.is_pagespeed
if not pargs.letsencrypt:
try: try:
pre_run_checks(self) pre_run_checks(self)
except SiteError as e: except SiteError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.error(self, "NGINX configuration check failed.") Log.error(self, "NGINX configuration check failed.")
data['old_pagespeed_status'] = check_site.is_pagespeed
try: try:
sitebackup(self, data) sitebackup(self, data)
except Exception as e: except Exception as e:
@ -1210,6 +1197,47 @@ class EESiteUpdateController(CementBaseController):
if pargs.pagespeed: if pargs.pagespeed:
operateOnPagespeed(self, data) operateOnPagespeed(self, data)
if pargs.letsencrypt:
if data['letsencrypt'] is True:
if not os.path.isfile("{0}/conf/nginx/ssl.conf.disabled"
.format(ee_site_webroot)):
setupLetsEncrypt(self, ee_domain)
Log.info(self,'letsencrypts is installed ')
if not EEService.reload_service(self, 'nginx'):
Log.error(self, "service nginx reload failed. "
"check issues with `nginx -t` command")
# updateSiteInfo(self, ee_domain, ssl=letsencrypt)
Log.info(self, "Successfully Configured SSl for Site "
" https://{0}".format(ee_domain))
# return 0
else:
EEFileUtils.mvfile(self, "{0}/conf/nginx/ssl.conf.disabled"
.format(ee_site_webroot),
'{0}/conf/nginx/ssl.conf'
.format(ee_site_webroot))
elif data['letsencrypt'] is False:
Log.info(self,'letsencrypts disabled')
if os.path.isfile("{0}/conf/nginx/ssl.conf"
.format(ee_site_webroot)):
EEFileUtils.mvfile(self, "{0}/conf/nginx/ssl.conf"
.format(ee_site_webroot),
'{0}/conf/nginx/ssl.conf.disabled'
.format(ee_site_webroot))
# Add nginx conf folder into GIT
EEGit.add(self, ["{0}/conf/nginx".format(ee_site_webroot)],
msg="Adding letsencrypts config of site: {0}"
.format(ee_domain))
updateSiteInfo(self, ee_domain, ssl=letsencrypt)
return 0
#updateSiteInfo(self, ee_domain, ssl=False)
#pass
#--letsencrypt=off code here
if stype == oldsitetype and cache == oldcachetype: if stype == oldsitetype and cache == oldcachetype:

Loading…
Cancel
Save