Merge branch 'letsencrypt' into updating-configuration
This commit is contained in:
@@ -678,7 +678,8 @@ class WOSiteCreateController(CementBaseController):
|
||||
Log.error(self, "Check the log for details: "
|
||||
"`tail /var/log/wo/wordops.log` and please try again")
|
||||
|
||||
if self.app.pargs.letsencrypt and (not self.app.pargs.subdomain):
|
||||
if self.app.pargs.letsencrypt and
|
||||
(not pargs.letsencrypt == "wildcard"):
|
||||
if stype in ['wpsubdomain']:
|
||||
Log.warn(
|
||||
self, "Wildcard domains are not supported in Lets Encrypt.\nWP SUBDOMAIN site will get SSL for primary site only.")
|
||||
@@ -772,7 +773,8 @@ class WOSiteUpdateController(CementBaseController):
|
||||
(['-le', '--letsencrypt'],
|
||||
dict(help="configure letsencrypt ssl for the site",
|
||||
action='store' or 'store_const',
|
||||
choices=('on', 'off', 'renew'), const='on', nargs='?')),
|
||||
choices=('on', 'off', 'renew', 'subdomain', 'wildcard'),
|
||||
const='on', nargs='?')),
|
||||
(['--proxy'],
|
||||
dict(help="update to proxy site", nargs='+')),
|
||||
(['--experimental'],
|
||||
@@ -1119,28 +1121,14 @@ class WOSiteUpdateController(CementBaseController):
|
||||
php73 = True
|
||||
|
||||
if pargs.letsencrypt == "on":
|
||||
|
||||
if pargs.experimental:
|
||||
|
||||
if oldsitetype in ['wpsubdomain']:
|
||||
Log.warn(
|
||||
self, "Wildcard domains are not supported in Lets Encrypt.\nWP SUBDOMAIN site will get SSL for primary site only.")
|
||||
|
||||
Log.info(self, "Letsencrypt is currently in beta phase."
|
||||
" \nDo you wish"
|
||||
" to enable SSl now for {0}?".format(wo_domain))
|
||||
|
||||
check_prompt = input("Type \"y\" to continue [n]:")
|
||||
if check_prompt != "Y" and check_prompt != "y":
|
||||
Log.info(self, "Not using letsencrypt for site")
|
||||
data['letsencrypt'] = False
|
||||
letsencrypt = False
|
||||
else:
|
||||
data['letsencrypt'] = True
|
||||
letsencrypt = True
|
||||
if oldsitetype in ['wpsubdomain']:
|
||||
data['letsencrypt'] = True
|
||||
letsencrypt = True
|
||||
wildcard = True
|
||||
else:
|
||||
data['letsencrypt'] = True
|
||||
letsencrypt = True
|
||||
wildcard = True
|
||||
|
||||
if pargs.wpredis and data['currcachetype'] != 'wpredis':
|
||||
if pargs.experimental:
|
||||
@@ -1202,7 +1190,7 @@ class WOSiteUpdateController(CementBaseController):
|
||||
" http://{0}".format(wo_domain))
|
||||
return 0
|
||||
|
||||
if pargs.letsencrypt:
|
||||
if pargs.letsencrypt and (not pargs.subdomain):
|
||||
if data['letsencrypt'] is True:
|
||||
if not os.path.isfile("{0}/conf/nginx/ssl.conf.disabled"
|
||||
.format(wo_site_webroot)):
|
||||
@@ -1215,9 +1203,6 @@ class WOSiteUpdateController(CementBaseController):
|
||||
.format(wo_site_webroot))
|
||||
|
||||
httpsRedirect(self, wo_domain)
|
||||
Log.info(self, "Creating Cron Job for cert auto-renewal")
|
||||
WOCron.setcron_weekly(self, 'wo site update --le=renew --all 2> /dev/null'.format(wo_domain), 'Renew all'
|
||||
' letsencrypt SSL cert. Set by WordOps')
|
||||
|
||||
if not WOService.reload_service(self, 'nginx'):
|
||||
Log.error(self, "service nginx reload failed. "
|
||||
@@ -1245,8 +1230,58 @@ class WOSiteUpdateController(CementBaseController):
|
||||
if not WOService.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")
|
||||
# WOCron.remove_cron(self,'wo site update {0} --le=renew --min_expiry_limit 30 2> \/dev\/null'.format(wo_domain))
|
||||
# Log.info(self,"Removing Cron Job set for cert
|
||||
# auto-renewal") WOCron.remove_cron(self,'wo site
|
||||
# update {0} --le=renew --min_expiry_limit 30
|
||||
# 2> \/dev\/null'.format(wo_domain))
|
||||
Log.info(self, "Successfully Disabled SSl for Site "
|
||||
" http://{0}".format(wo_domain))
|
||||
|
||||
if pargs.letsencrypt and (pargs.subdomain):
|
||||
if data['letsencrypt'] is True:
|
||||
if not os.path.isfile("{0}/conf/nginx/ssl.conf.disabled"
|
||||
.format(wo_site_webroot)):
|
||||
setupLetsEncryptSubdomain(self, wo_domain)
|
||||
|
||||
else:
|
||||
WOFileUtils.mvfile(self, "{0}/conf/nginx/ssl.conf.disabled"
|
||||
.format(wo_site_webroot),
|
||||
'{0}/conf/nginx/ssl.conf'
|
||||
.format(wo_site_webroot))
|
||||
|
||||
httpsRedirect(self, wo_domain)
|
||||
|
||||
if not WOService.reload_service(self, 'nginx'):
|
||||
Log.error(self, "service nginx reload failed. "
|
||||
"check issues with `nginx -t` command")
|
||||
|
||||
Log.info(self, "Congratulations! Successfully Configured SSl for Site "
|
||||
" https://{0}".format(wo_domain))
|
||||
|
||||
if (SSL.getExpirationDays(self, wo_domain) > 0):
|
||||
Log.info(self, "Your cert will expire within " +
|
||||
str(SSL.getExpirationDays(self, wo_domain)) + " days.")
|
||||
else:
|
||||
Log.warn(
|
||||
self, "Your cert already EXPIRED ! .PLEASE renew soon . ")
|
||||
|
||||
elif data['letsencrypt'] is False:
|
||||
if os.path.isfile("{0}/conf/nginx/ssl.conf"
|
||||
.format(wo_site_webroot)):
|
||||
Log.info(self, 'Setting Nginx configuration')
|
||||
WOFileUtils.mvfile(self, "{0}/conf/nginx/ssl.conf"
|
||||
.format(wo_site_webroot),
|
||||
'{0}/conf/nginx/ssl.conf.disabled'
|
||||
.format(wo_site_webroot))
|
||||
httpsRedirect(self, wo_domain, False)
|
||||
if not WOService.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")
|
||||
# WOCron.remove_cron(self,'wo site update {0}
|
||||
# --le=renew --min_expiry_limit 30 2> \/dev\/null'
|
||||
# .format(wo_domain))
|
||||
Log.info(self, "Successfully Disabled SSl for Site "
|
||||
" http://{0}".format(wo_domain))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user