示例#1
0
def run_certbot_and_setup_ssl(site, custom_domain, bench_path):
    service('nginx', 'stop')
    get_certbot()

    try:
        exec_cmd(
            "{path} --config /etc/letsencrypt/configs/{site}.cfg certonly".
            format(path=get_certbot_path(), site=custom_domain or site))
    except CommandFailedError:
        service('nginx', 'start')
        print "There was a problem trying to setup SSL for your site"
        return

    ssl_path = "/etc/letsencrypt/live/{site}/".format(
        site=custom_domain or site)
    ssl_config = {
        "ssl_certificate": os.path.join(ssl_path, "fullchain.pem"),
        "ssl_certificate_key": os.path.join(ssl_path, "privkey.pem")
    }

    if custom_domain:
        remove_domain(site, custom_domain, bench_path)
        domains = get_domains(site, bench_path)
        ssl_config['domain'] = custom_domain
        domains.append(ssl_config)
        update_site_config(site, {"domains": domains}, bench_path=bench_path)
    else:
        update_site_config(site, ssl_config, bench_path=bench_path)

    make_nginx_conf(bench_path)
    service('nginx', 'start')
示例#2
0
def run_certbot_and_setup_ssl(site, custom_domain, bench_path):
	service('nginx', 'stop')
	get_certbot()

	try:
		exec_cmd("{path} --config /etc/letsencrypt/configs/{site}.cfg certonly".format(path=get_certbot_path(), site=custom_domain or site))
	except CommandFailedError:
		service('nginx', 'start')
		print "There was a problem trying to setup SSL for your site"
		return

	ssl_path = "/etc/letsencrypt/live/{site}/".format(site=custom_domain or site)
	ssl_config = { "ssl_certificate": os.path.join(ssl_path, "fullchain.pem"),
					"ssl_certificate_key": os.path.join(ssl_path, "privkey.pem") }

	if custom_domain:
		remove_domain(site, custom_domain, bench_path)
		domains = get_domains(site, bench_path)
		ssl_config['domain'] = custom_domain		
		domains.append(ssl_config)
		update_site_config(site, { "domains": domains }, bench_path=bench_path)
	else:
		update_site_config(site, ssl_config, bench_path=bench_path)
	
	make_nginx_conf(bench_path)
	service('nginx', 'start')
示例#3
0
def remove_domain(domain, site=None):
    from bench.config.site_config import remove_domain

    if not site:
        print("Please specify site")
        sys.exit(1)

    remove_domain(site, domain, bench_path=".")
示例#4
0
def remove_domain(domain, site=None):
    """Remove custom domain from a site"""
    from bench.config.site_config import remove_domain

    if not site:
        print("Please specify site")
        sys.exit(1)

    remove_domain(site, domain, bench_path='.')
示例#5
0
文件: setup.py 项目: kossanah/bench
def remove_domain(domain, site=None):
	"""Remove custom domain from a site"""
	from bench.config.site_config import remove_domain

	if not site:
		print("Please specify site")
		sys.exit(1)

	remove_domain(site, domain, bench_path='.')