def setup_production(user, bench_path='.'): generate_supervisor_config(bench_path=bench_path, user=user) make_nginx_conf(bench_path=bench_path) fix_prod_setup_perms(bench_path, frappe_user=user) remove_default_nginx_configs() bench_name = get_bench_name(bench_path) nginx_conf = '/etc/nginx/conf.d/{bench_name}.conf'.format(bench_name=bench_name) supervisor_conf_extn = "ini" if is_centos7() else "conf" supervisor_conf = os.path.join(get_supervisor_confdir(), '{bench_name}.{extn}'.format( bench_name=bench_name, extn=supervisor_conf_extn)) # Check if symlink exists, If not then create it. if not os.path.islink(supervisor_conf): os.symlink(os.path.abspath(os.path.join(bench_path, 'config', 'supervisor.conf')), supervisor_conf) if not os.path.islink(nginx_conf): os.symlink(os.path.abspath(os.path.join(bench_path, 'config', 'nginx.conf')), nginx_conf) reload_supervisor() if os.environ.get('NO_SERVICE_RESTART'): return reload_nginx()
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')
def setup_production(user, bench_path='.'): generate_supervisor_config(bench_path=bench_path, user=user) make_nginx_conf(bench_path=bench_path) fix_prod_setup_perms(bench_path, frappe_user=user) remove_default_nginx_configs() bench_name = get_bench_name(bench_path) nginx_conf = '/etc/nginx/conf.d/{bench_name}.conf'.format( bench_name=bench_name) supervisor_conf_extn = "ini" if is_centos7() else "conf" supervisor_conf = os.path.join( get_supervisor_confdir(), '{bench_name}.{extn}'.format(bench_name=bench_name, extn=supervisor_conf_extn)) # Check if symlink exists, If not then create it. if not os.path.islink(supervisor_conf): os.symlink( os.path.abspath( os.path.join(bench_path, 'config', 'supervisor.conf')), supervisor_conf) if not os.path.islink(nginx_conf): os.symlink( os.path.abspath(os.path.join(bench_path, 'config', 'nginx.conf')), nginx_conf) reload_supervisor() if os.environ.get('NO_SERVICE_RESTART'): return reload_nginx()
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')
def setup_production(user, bench='.'): generate_supervisor_config(bench_path=bench, user=user) make_nginx_conf(bench_path=bench) fix_prod_setup_perms(bench, frappe_user=user) remove_default_nginx_configs() bench_name = get_bench_name(bench) nginx_conf = '/etc/nginx/conf.d/{bench_name}.conf'.format( bench_name=bench_name) supervisor_conf_extn = "ini" if is_centos7() else "conf" supervisor_conf = os.path.join( get_supervisor_confdir(), '{bench_name}.{extn}'.format(bench_name=bench_name, extn=supervisor_conf_extn)) os.symlink( os.path.abspath(os.path.join(bench, 'config', 'supervisor.conf')), supervisor_conf) os.symlink(os.path.abspath(os.path.join(bench, 'config', 'nginx.conf')), nginx_conf) exec_cmd('supervisorctl reload') if os.environ.get('NO_SERVICE_RESTART'): return restart_service('nginx')
def setup_production(user, bench_path='.', yes=False): if get_config(bench_path).get('restart_supervisor_on_update') and get_config(bench_path).get('restart_systemd_on_update'): raise Exception("You cannot use supervisor and systemd at the same time. Modify your common_site_config accordingly." ) if get_config(bench_path).get('restart_systemd_on_update'): generate_systemd_config(bench_path=bench_path, user=user, yes=yes) else: generate_supervisor_config(bench_path=bench_path, user=user, yes=yes) make_nginx_conf(bench_path=bench_path, yes=yes) fix_prod_setup_perms(bench_path, dataent_user=user) remove_default_nginx_configs() bench_name = get_bench_name(bench_path) nginx_conf = '/etc/nginx/conf.d/{bench_name}.conf'.format(bench_name=bench_name) if get_config(bench_path).get('restart_supervisor_on_update'): supervisor_conf_extn = "ini" if is_centos7() else "conf" supervisor_conf = os.path.join(get_supervisor_confdir(), '{bench_name}.{extn}'.format( bench_name=bench_name, extn=supervisor_conf_extn)) # Check if symlink exists, If not then create it. if not os.path.islink(supervisor_conf): os.symlink(os.path.abspath(os.path.join(bench_path, 'config', 'supervisor.conf')), supervisor_conf) if not os.path.islink(nginx_conf): os.symlink(os.path.abspath(os.path.join(bench_path, 'config', 'nginx.conf')), nginx_conf) if get_config(bench_path).get('restart_supervisor_on_update'): reload_supervisor() if os.environ.get('NO_SERVICE_RESTART'): return reload_nginx()
def setup_production(user, bench_path='.', yes=False): if get_config(bench_path).get('restart_supervisor_on_update') and get_config(bench_path).get('restart_systemd_on_update'): raise Exception("You cannot use supervisor and systemd at the same time. Modify your common_site_config accordingly." ) if get_config(bench_path).get('restart_systemd_on_update'): generate_systemd_config(bench_path=bench_path, user=user, yes=yes) else: generate_supervisor_config(bench_path=bench_path, user=user, yes=yes) make_nginx_conf(bench_path=bench_path, yes=yes) fix_prod_setup_perms(bench_path, frappe_user=user) remove_default_nginx_configs() bench_name = get_bench_name(bench_path) nginx_conf = '/etc/nginx/conf.d/{bench_name}.conf'.format(bench_name=bench_name) if get_config(bench_path).get('restart_supervisor_on_update'): supervisor_conf_extn = "ini" if is_centos7() else "conf" supervisor_conf = os.path.join(get_supervisor_confdir(), '{bench_name}.{extn}'.format( bench_name=bench_name, extn=supervisor_conf_extn)) # Check if symlink exists, If not then create it. if not os.path.islink(supervisor_conf): os.symlink(os.path.abspath(os.path.join(bench_path, 'config', 'supervisor.conf')), supervisor_conf) if not os.path.islink(nginx_conf): os.symlink(os.path.abspath(os.path.join(bench_path, 'config', 'nginx.conf')), nginx_conf) if get_config(bench_path).get('restart_supervisor_on_update'): reload_supervisor() if os.environ.get('NO_SERVICE_RESTART'): return reload_nginx()
def set_site_config_nginx_property(site, config, bench_path='.', gen_config=True): if site not in get_sites(bench_path=bench_path): raise Exception("No such site") update_site_config(site, config, bench_path=bench_path) if gen_config: make_nginx_conf(bench_path=bench_path)
def setup_wildcard_ssl(domain, email, bench_path, exclude_base_domain): def _get_domains(domain): domain_list = [domain] if not domain.startswith('*.'): # add wildcard caracter to domain if missing domain_list.append('*.{0}'.format(domain)) else: # include base domain based on flag domain_list.append(domain.replace('*.', '')) if exclude_base_domain: domain_list.remove(domain.replace('*.', '')) return domain_list if not get_config(bench_path).get("dns_multitenant"): print("You cannot setup SSL without DNS Multitenancy") return get_certbot() domain_list = _get_domains(domain.strip()) email_param = '' if email: email_param = '--email {0}'.format(email) try: exec_cmd( "{path} certonly --manual --preferred-challenges=dns {email_param} \ --server https://acme-v02.api.letsencrypt.org/directory \ --agree-tos -d {domain}".format(path=get_certbot_path(), domain=' -d '.join(domain_list), email_param=email_param)) except CommandFailedError: print("There was a problem trying to setup SSL") return ssl_path = "/etc/letsencrypt/live/{domain}/".format(domain=domain) ssl_config = { "wildcard": { "domain": domain, "ssl_certificate": os.path.join(ssl_path, "fullchain.pem"), "ssl_certificate_key": os.path.join(ssl_path, "privkey.pem") } } update_common_site_config(ssl_config) setup_crontab() make_nginx_conf(bench_path) print("Restrting Nginx service") service('nginx', 'restart')
def setup_wildcard_ssl(domain, email, bench_path, exclude_base_domain): def _get_domains(domain): domain_list = [domain] if not domain.startswith('*.'): # add wildcard caracter to domain if missing domain_list.append('*.{0}'.format(domain)) else: # include base domain based on flag domain_list.append(domain.replace('*.', '')) if exclude_base_domain: domain_list.remove(domain.replace('*.', '')) return domain_list if not get_config(bench_path).get("dns_multitenant"): print("You cannot setup SSL without DNS Multitenancy") return get_certbot() domain_list = _get_domains(domain.strip()) email_param = '' if email: email_param = '--email {0}'.format(email) try: exec_cmd("{path} certonly --manual --preferred-challenges=dns {email_param} \ --server https://acme-v02.api.letsencrypt.org/directory \ --agree-tos -d {domain}".format(path=get_certbot_path(), domain=' -d '.join(domain_list), email_param=email_param)) except CommandFailedError: print("There was a problem trying to setup SSL") return ssl_path = "/etc/letsencrypt/live/{domain}/".format(domain=domain) ssl_config = { "wildcard": { "domain": domain, "ssl_certificate": os.path.join(ssl_path, "fullchain.pem"), "ssl_certificate_key": os.path.join(ssl_path, "privkey.pem") } } update_common_site_config(ssl_config) setup_crontab() make_nginx_conf(bench_path) print("Restrting Nginx service") service('nginx', 'restart')
def setup_production(user, bench='.'): generate_supervisor_config(bench_path=bench, user=user) make_nginx_conf(bench_path=bench) fix_prod_setup_perms(bench, frappe_user=user) remove_default_nginx_configs() bench_name = get_bench_name(bench) nginx_conf = '/etc/nginx/conf.d/{bench_name}.conf'.format(bench_name=bench_name) supervisor_conf_extn = "ini" if is_centos7() else "conf" supervisor_conf = os.path.join(get_supervisor_confdir(), '{bench_name}.{extn}'.format( bench_name=bench_name, extn=supervisor_conf_extn)) os.symlink(os.path.abspath(os.path.join(bench, 'config', 'supervisor.conf')), supervisor_conf) os.symlink(os.path.abspath(os.path.join(bench, 'config', 'nginx.conf')), nginx_conf) exec_cmd('supervisorctl reload') if os.environ.get('NO_SERVICE_RESTART'): return restart_service('nginx')
def setup_nginx(yes=False): "generate config for nginx" from bench.config.nginx import make_nginx_conf make_nginx_conf(bench_path=".", yes=yes)
def setup_nginx(yes=False): from bench.config.nginx import make_nginx_conf make_nginx_conf(bench_path=".", yes=yes)
def setup_nginx(): "generate config for nginx" from bench.config.nginx import make_nginx_conf make_nginx_conf(bench_path=".")