2
0
mirror of https://github.com/frappe/bench.git synced 2024-11-11 15:51:03 +00:00

Merge pull request #649 from codingCoffee/letsn

fixed lets-encrypt non interactive mode
This commit is contained in:
Ameya Shenoy 2018-04-26 21:28:32 +05:30 committed by GitHub
commit 58d15e2870
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -121,10 +121,11 @@ def set_ssh_port(port, force=False):
@click.command('lets-encrypt')
@click.argument('site')
@click.option('--custom-domain')
def setup_letsencrypt(site, custom_domain):
@click.option('-n', '--non-interactive', default=False, is_flag=True, help="Run certbot non-interactively. Shouldn't be used on 1'st attempt")
def setup_letsencrypt(site, custom_domain, non_interactive):
"Setup lets-encrypt for site"
from bench.config.lets_encrypt import setup_letsencrypt
setup_letsencrypt(site, custom_domain, bench_path='.')
setup_letsencrypt(site, custom_domain, bench_path='.', interactive=not non_interactive)
@click.command('procfile')

View File

@ -11,7 +11,7 @@ try:
except ImportError:
from urllib import urlretrieve
def setup_letsencrypt(site, custom_domain, bench_path):
def setup_letsencrypt(site, custom_domain, bench_path, interactive):
site_path = os.path.join(bench_path, "sites", site, "site_config.json")
if not os.path.exists(os.path.dirname(site_path)):
@ -38,7 +38,7 @@ def setup_letsencrypt(site, custom_domain, bench_path):
return
create_config(site, custom_domain)
run_certbot_and_setup_ssl(site, custom_domain, bench_path)
run_certbot_and_setup_ssl(site, custom_domain, bench_path, interactive)
setup_crontab()
@ -51,12 +51,13 @@ def create_config(site, custom_domain):
f.write(config)
def run_certbot_and_setup_ssl(site, custom_domain, bench_path):
def run_certbot_and_setup_ssl(site, custom_domain, bench_path, interactive=True):
service('nginx', 'stop')
get_certbot()
try:
exec_cmd("{path} -n --config /etc/letsencrypt/configs/{site}.cfg certonly".format(path=get_certbot_path(), site=custom_domain or site))
interactive = '' if interactive else '-n'
exec_cmd("{path} {interactive} --config /etc/letsencrypt/configs/{site}.cfg certonly".format(path=get_certbot_path(), interactive=interactive, site=custom_domain or site))
except CommandFailedError:
service('nginx', 'start')
print("There was a problem trying to setup SSL for your site")