Skip to content

Commit

Permalink
fix: dont abort script if not overwriting scripts
Browse files Browse the repository at this point in the history
why: currently, running of `bench ` or `bench setup
production` creates nginx conf files and asks for confirmation before
overwriting them. in case user doesnt want to overwrite files,
`setup production` and `lets-encrypt` is exitted abrubtly and nginx isnt started again after
  • Loading branch information
gavindsouza committed Feb 10, 2020
1 parent 40f7e09 commit f321ee2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions bench/config/nginx.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import os, json, click, random, string, hashlib
from bench.utils import get_sites, get_bench_name, exec_cmd
from six import string_types
from six.moves import input


def make_nginx_conf(bench_path, yes=False):
conf_path = os.path.join(bench_path, "config", "nginx.conf")

if not yes and os.path.exists(conf_path):
if input('nginx.conf already exists and this will overwrite it. Do you want to continue? [y/N]').lower() == 'n':
return

from bench import env
from bench.config.common_site_config import get_config

Expand Down Expand Up @@ -37,10 +45,6 @@ def make_nginx_conf(bench_path, yes=False):

nginx_conf = template.render(**template_vars)

conf_path = os.path.join(bench_path, "config", "nginx.conf")
if not yes and os.path.exists(conf_path):
click.confirm('nginx.conf already exists and this will overwrite it. Do you want to continue?',
abort=True)

with open(conf_path, "w") as f:
f.write(nginx_conf)
Expand Down

0 comments on commit f321ee2

Please sign in to comment.