mirror of
https://github.com/frappe/bench.git
synced 2025-02-03 11:28:24 +00:00
Merge branch 'master' into systemd
This commit is contained in:
commit
ba5165ebbb
@ -55,10 +55,15 @@ def setup_production(user, yes=False):
|
|||||||
from bench.config.production_setup import setup_production
|
from bench.config.production_setup import setup_production
|
||||||
from bench.utils import run_playbook
|
from bench.utils import run_playbook
|
||||||
# Install prereqs for production
|
# Install prereqs for production
|
||||||
exec_cmd("sudo pip install ansible")
|
from distutils.spawn import find_executable
|
||||||
exec_cmd("bench setup role fail2ban")
|
if not find_executable('ansible'):
|
||||||
exec_cmd("bench setup role nginx")
|
exec_cmd("sudo pip install ansible")
|
||||||
exec_cmd("bench setup role supervisor")
|
if not find_executable('fail2ban-client'):
|
||||||
|
exec_cmd("bench setup role fail2ban")
|
||||||
|
if not find_executable('nginx'):
|
||||||
|
exec_cmd("bench setup role nginx")
|
||||||
|
if not find_executable('supervisord'):
|
||||||
|
exec_cmd("bench setup role supervisor")
|
||||||
setup_production(user=user, yes=yes)
|
setup_production(user=user, yes=yes)
|
||||||
|
|
||||||
|
|
||||||
@ -116,10 +121,11 @@ def set_ssh_port(port, force=False):
|
|||||||
@click.command('lets-encrypt')
|
@click.command('lets-encrypt')
|
||||||
@click.argument('site')
|
@click.argument('site')
|
||||||
@click.option('--custom-domain')
|
@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"
|
"Setup lets-encrypt for site"
|
||||||
from bench.config.lets_encrypt import setup_letsencrypt
|
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')
|
@click.command('procfile')
|
||||||
|
@ -11,7 +11,7 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
from urllib import urlretrieve
|
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")
|
site_path = os.path.join(bench_path, "sites", site, "site_config.json")
|
||||||
if not os.path.exists(os.path.dirname(site_path)):
|
if not os.path.exists(os.path.dirname(site_path)):
|
||||||
@ -38,7 +38,7 @@ def setup_letsencrypt(site, custom_domain, bench_path):
|
|||||||
return
|
return
|
||||||
|
|
||||||
create_config(site, custom_domain)
|
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()
|
setup_crontab()
|
||||||
|
|
||||||
|
|
||||||
@ -51,12 +51,13 @@ def create_config(site, custom_domain):
|
|||||||
f.write(config)
|
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')
|
service('nginx', 'stop')
|
||||||
get_certbot()
|
get_certbot()
|
||||||
|
|
||||||
try:
|
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:
|
except CommandFailedError:
|
||||||
service('nginx', 'start')
|
service('nginx', 'start')
|
||||||
print("There was a problem trying to setup SSL for your site")
|
print("There was a problem trying to setup SSL for your site")
|
||||||
|
@ -103,8 +103,17 @@ def install_bench(args):
|
|||||||
if args.production:
|
if args.production:
|
||||||
extra_vars.update(max_worker_connections=multiprocessing.cpu_count() * 1024)
|
extra_vars.update(max_worker_connections=multiprocessing.cpu_count() * 1024)
|
||||||
|
|
||||||
branch = 'master' if args.production else 'develop'
|
if args.frappe_branch:
|
||||||
extra_vars.update(branch=branch)
|
frappe_branch = args.frappe_branch
|
||||||
|
else:
|
||||||
|
frappe_branch = 'master' if args.production else 'develop'
|
||||||
|
extra_vars.update(frappe_branch=frappe_branch)
|
||||||
|
|
||||||
|
if args.erpnext_branch:
|
||||||
|
erpnext_branch = args.erpnext_branch
|
||||||
|
else:
|
||||||
|
erpnext_branch = 'master' if args.production else 'develop'
|
||||||
|
extra_vars.update(erpnext_branch=erpnext_branch)
|
||||||
|
|
||||||
bench_name = 'frappe-bench' if not args.bench_name else args.bench_name
|
bench_name = 'frappe-bench' if not args.bench_name else args.bench_name
|
||||||
extra_vars.update(bench_name=bench_name)
|
extra_vars.update(bench_name=bench_name)
|
||||||
@ -359,6 +368,18 @@ def parse_commandline_args():
|
|||||||
|
|
||||||
parser.add_argument('--repo-url', dest='repo_url', help='Clone bench from the given url')
|
parser.add_argument('--repo-url', dest='repo_url', help='Clone bench from the given url')
|
||||||
|
|
||||||
|
parser.add_argument('--frappe-repo-url', dest='frappe_repo_url', action='store', default='https://github.com/frappe/frappe',
|
||||||
|
help='Clone frappe from the given url')
|
||||||
|
|
||||||
|
parser.add_argument('--frappe-branch', dest='frappe_branch', action='store',
|
||||||
|
help='Clone a particular branch of frappe')
|
||||||
|
|
||||||
|
parser.add_argument('--erpnext-repo-url', dest='erpnext_repo_url', action='store', default='https://github.com/frappe/erpnext',
|
||||||
|
help='Clone erpnext from the given url')
|
||||||
|
|
||||||
|
parser.add_argument('--erpnext-branch', dest='erpnext_branch', action='store',
|
||||||
|
help='Clone a particular branch of erpnext')
|
||||||
|
|
||||||
# To enable testing of script using Travis, this should skip the prompt
|
# To enable testing of script using Travis, this should skip the prompt
|
||||||
parser.add_argument('--run-travis', dest='run_travis', action='store_true', default=False,
|
parser.add_argument('--run-travis', dest='run_travis', action='store_true', default=False,
|
||||||
help=argparse.SUPPRESS)
|
help=argparse.SUPPRESS)
|
||||||
|
@ -29,13 +29,13 @@
|
|||||||
register: bench_stat
|
register: bench_stat
|
||||||
|
|
||||||
- name: python3 bench init for develop
|
- name: python3 bench init for develop
|
||||||
command: bench init {{ bench_path }} --frappe-branch {{ branch }} --python {{ python }}
|
command: bench init {{ bench_path }} --frappe-path {{ frappe_repo_url }} --frappe-branch {{ frappe_branch }} --python {{ python }}
|
||||||
args:
|
args:
|
||||||
creates: "{{ bench_path }}"
|
creates: "{{ bench_path }}"
|
||||||
when: not bench_stat.stat.exists and not production
|
when: not bench_stat.stat.exists and not production
|
||||||
|
|
||||||
- name: python2 bench init for production
|
- name: python2 bench init for production
|
||||||
command: bench init {{ bench_path }} --frappe-branch {{ branch }}
|
command: bench init {{ bench_path }} --frappe-path {{ frappe_repo_url }} --frappe-branch {{ frappe_branch }}
|
||||||
args:
|
args:
|
||||||
creates: "{{ bench_path }}"
|
creates: "{{ bench_path }}"
|
||||||
when: not bench_stat.stat.exists and production
|
when: not bench_stat.stat.exists and production
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
register: app
|
register: app
|
||||||
|
|
||||||
- name: Get the ERPNext app
|
- name: Get the ERPNext app
|
||||||
command: bench get-app erpnext https://github.com/frappe/erpnext --branch {{ branch }}
|
command: bench get-app erpnext {{ erpnext_repo_url }} --branch {{ erpnext_branch }}
|
||||||
args:
|
args:
|
||||||
creates: "{{ bench_path }}/apps/erpnext"
|
creates: "{{ bench_path }}/apps/erpnext"
|
||||||
chdir: "{{ bench_path }}"
|
chdir: "{{ bench_path }}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user