diff --git a/.travis.yml b/.travis.yml index 550aa53e..aa4416c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,17 +58,17 @@ matrix: - name: "Python 3.6 Easy Install" python: 3.6 env: TEST=easy_install - script: sudo python $TRAVIS_BUILD_DIR/playbooks/install.py --user travis --run-travis --production --verbose + script: sudo python $TRAVIS_BUILD_DIR/install.py --user travis --run-travis --production --verbose - name: "Python 3.7 Easy Install" python: 3.7 env: TEST=easy_install - script: sudo python $TRAVIS_BUILD_DIR/playbooks/install.py --user travis --run-travis --production --verbose + script: sudo python $TRAVIS_BUILD_DIR/install.py --user travis --run-travis --production --verbose - name: "Python 3.8 Easy Install" python: 3.8 env: TEST=easy_install - script: sudo python $TRAVIS_BUILD_DIR/playbooks/install.py --user travis --run-travis --production --verbose + script: sudo python $TRAVIS_BUILD_DIR/install.py --user travis --run-travis --production --verbose install: - pip install urllib3 pyOpenSSL ndg-httpsclient pyasn1 diff --git a/LICENSE.md b/LICENSE similarity index 100% rename from LICENSE.md rename to LICENSE diff --git a/MANIFEST.in b/MANIFEST.in index e84c5e61..f9ed1524 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,9 @@ include *.md include *.py recursive-include bench *.conf +recursive-include bench *.sh recursive-include bench *.py recursive-include bench *.txt recursive-include bench *.json recursive-include bench/config/templates * +recursive-include bench/playbooks * diff --git a/README.md b/README.md index 294520d8..9497802c 100755 --- a/README.md +++ b/README.md @@ -1,131 +1,236 @@
-

bench

+

Bench

-bench is a command-line utility that helps you to install apps, manage multiple sites and update Frappe / ERPNext apps on */nix (macOS, Ubuntu, Debian, CentOS, etc) for development and production. +Bench is a command-line utility that helps you to install, update, and manage multiple sites for Frappe/ERPNext applications on [*nix systems](https://en.wikipedia.org/wiki/Unix-like) for development and production. +## Table of Contents -> **Note**: If you are looking for easier ways to get started and evaluate ERPNext, [download the Virtual Machine](https://erpnext.com/download) or take [a free trial on erpnext.com](https://erpnext.com/pricing). - ---- - -# Table of Contents - - - [bench CLI](#bench-cli) - - [Usage](#usage) - - [Installation](#installation) - - [Custom Bench commands](#custom-bench-commands) - - [Easy Install Script](#easy-install-script) - - [Release Bench](#release-bench) + - [Installation](#installation) + - [Docker Installation](#docker-installation) + - [Development Setup](#docker-installation-for-development) + - [Production Setup](#docker-installation-for-production) + - [Easy Install Script](#easy-install-script) + - [Manual Installation](#manual-installation) + - [Usage](#usage) + - [Custom Bench commands](#custom-bench-commands) + - [Bench Manager](#bench-manager) - [Guides](#guides) - [Resources](#resources) - [License](#license) ---- -# bench CLI - -Bench is a command line tool that helps you install, setup, manage multiple sites and apps based on Frappe Framework. - ---- - -## Usage - -* Create a new bench - - bench init [bench-name] - -* Add a site under current bench - - bench new-site [site-name] - - **Optional**: If the database for the site does not reside on localhost or listens on a custom port, you can use the flags `--db-host` to set a custom host and/or `--db-port` to set a custom port. - - bench new-site [site-name] --db-host [custom-db-host-ip] --db-port [custom-db-port] - -* Add apps to bench - - bench get-app [app-name] [app-link] - -* Install apps on a particular site - - bench --site [site-name] install-app [app-name] - -* Start bench (only for development) - - bench start - -* Show bench help - - bench --help - -_Note:_ Apart from `bench init`, all other bench commands have to be run having the respective bench directory as the working directory. _(`bench update` may also be run, but it's behaviour is covered in depth in the docs)_ - -For more in depth information on commands and usage follow [here](https://github.com/frappe/bench/blob/master/docs/commands_and_usage.md). As for a consolidated list of bench commands, go through [this page](https://github.com/frappe/bench/blob/master/docs/bench_usage.md). - ---- ## Installation -To do this install, you must have basic information on how Linux works and should be able to use the command-line. bench will also create nginx and supervisor config files, setup backups and much more. If you are using on a VPS make sure it has >= 1Gb of RAM or has swap setup properly. +A typical bench setup provides two types of environments — Development and Production. - git clone https://github.com/frappe/bench ~/.bench - pip3 install --user -e ~/.bench +The setup for each of these installations can be achieved in multiple ways: -As bench is a python application, its installation really depends on `python` + `pip` + `git`. The Frappe Framework, however has various other system dependencies like `nodejs`, `yarn`, `redis` and a database system like `mariadb` or `postgres`. Go through the [installation requirements](https://github.com/frappe/bench/blob/master/docs/installation.md) for an updated list. + - [Docker Installation](#docker-installation) + - [Easy Install Script](#easy-install-script) + - [Manual Installation](#manual-installation) -If you have questions, please ask them on the [forum](https://discuss.erpnext.com/c/bench) under the "Install / Update" category. +We recommend using either the Docker Installation or the Easy Install Script to setup a Production Environment. For Development, you may choose either of the three methods to setup an instance. + +Otherwise, if you are looking to evaluate ERPNext, you can also download the [Virtual Machine Image](https://erpnext.com/download) or register for [a free trial on erpnext.com](https://erpnext.com/pricing). + + +### Docker Installation + +A Frappe/ERPNext instance can be setup and replicated easily using [Docker](https://docker.com). The officially supported Docker installation can be used to setup either of both Development and Production environments. + +To setup either of the environments, you will need to clone the official docker repository: + +```sh +$ git clone https://github.com/frappe/frappe_docker.git +$ cd frappe_docker +``` + +A quick setup guide for both the envionments can be found below. For more details, check out the [Frappe/ERPNext Docker Repository](https://github.com/frappe/frappe_docker). + +#### Docker Installation for Development + +To setup a development environment for Docker, follow the [Frappe/ERPNext Docker for Development Guide](https://github.com/frappe/frappe_docker/blob/develop/development/README.md). + +#### Docker Installation for Production + +Copy the `env-example` file to `.env` + +```sh +$ cp installation/env-example installation/.env +``` + +Make a directory for handling sites: + +```sh +$ mkdir installation/sites +``` + +Optionally, you may also setup an [NGINX Proxy for SSL Certificates](https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion) with auto-renewal for your Production instance. We recommend this for instances being accessed over the internet. For this to work, the DNS needs to be configured correctly so that [LetsEncrypt](https://letsencrypt.org) can verify the domain. To setup the proxy, run the following commands: + +```sh +$ git clone https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion.git +$ cd docker-compose-letsencrypt-nginx-proxy-companion +$ cp .env.sample .env +$ ./start.sh +``` + +To get the Production instance running, run the following command: + +```sh +$ docker-compose \ + --project-name \ + -f installation/docker-compose-common.yml \ + -f installation/docker-compose-erpnext.yml \ + -f installation/docker-compose-networks.yml \ + --project-directory installation up -d +``` + +Make sure to replace `` with whatever you wish to call it. This should get the instance running through docker. Now, to create a new site on the instance you may run: + +```sh +docker exec -it \ + -e "SITE_NAME=$SITE_NAME" \ + -e "DB_ROOT_USER=$DB_ROOT_USER" \ + -e "MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD" \ + -e "ADMIN_PASSWORD=$ADMIN_PASSWORD" \ + -e "INSTALL_APPS=erpnext" \ # optional, if you want to install any other apps + _erpnext-python_1 docker-entrypoint.sh new +``` + +Once this is done, you may access the instance at `$SITE_NAME`. + +**Note:** The Production setup does not contain, require, or use bench. For a list of substitute commands, check out the [Frappe/ERPNext Docker Site Operations](https://github.com/frappe/frappe_docker/#site-operations). + + +### Easy Install Script + +The Easy Install script should get you going with a Frappe/ERPNext setup with minimal manual intervention and effort. Since there are a lot of configurations being automatically setup, we recommend executing this script on a fresh server. + +**Note:** This script works only on GNU/Linux based server distributions, and has been designed and tested to work on Ubuntu 16.04+, CentOS 7+, and Debian-based systems. + +#### Prerequisites + +You need to install the following packages for the script to run: + + - ##### Ubuntu and Debian-based Distributions: + + ```sh + $ apt install python3-minimal build-essential python3-setuptools + ``` + + - ##### CentOS and other RPM Distributions: + + ```sh + $ dnf groupinstall "Development Tools" + $ dnf install python3 + ``` + +#### Setup + +Download the Easy Install script and execute it: + +```sh +$ wget https://raw.githubusercontent.com/frappe/bench/develop/install.py +$ python3 install.py --production +``` + +The script should then prompt you for the MySQL root password and an Administrator password for the Frappe/ERPNext instance, which will then be saved under `$HOME/passwords.txt` of the user used to setup the instance. This script will then install the required stack, setup bench and a default ERPNext instance. + +When the setup is complete, you will be able to access the system at `http://`, wherein you can use the administrator password to login. + +#### Troubleshooting + +In case the setup fails, the log file is saved under `/tmp/logs/install_bench.log`. You may then: + + - Create an Issue in this repository with the log file attached. + - Search for an existing issue or post the log file on the [Frappe/ERPNext Discuss Forum](https://discuss.erpnext.com/c/bench) with the tag `installation_problem` under "Install/Update" category. + +For more information and advanced setup instructions, check out the [Easy Install Documentation](https://github.com/frappe/bench/blob/master/docs/easy_install.md). + + +### Manual Installation + +Although not recommended, some might want to manually setup a bench instance locally for development. To quickly get started on installing bench the hard way, you can follow [Installing Bench and Frappe](https://frappe.io/docs/user/en/installation). + +For more extensive distribution-dependent documentation, check out the following guides: + + - [Hitchhiker's Guide to Installing Frappe on Linux](https://github.com/frappe/frappe/wiki/The-Hitchhiker%27s-Guide-to-Installing-Frappe-on-Linux) + - [Hitchhiker's Guide to Installing Frappe on MacOS](https://github.com/frappe/frappe/wiki/The-Hitchhiker%27s-Guide-to-Installing-Frappe-on-Mac-OS-X) + + +## Basic Usage + +**Note:** Apart from `bench init`, all other bench commands are expected to be run in the respective bench directory. + + * Create a new bench: + + ```sh + $ bench init [bench-name] + ``` + + * Add a site under current bench: + + ```sh + $ bench new-site [site-name] + ``` + - **Optional**: If the database for the site does not reside on localhost or listens on a custom port, you can use the flags `--db-host` to set a custom host and/or `--db-port` to set a custom port. + + ```sh + $ bench new-site [site-name] --db-host [custom-db-host-ip] --db-port [custom-db-port] + ``` + + * Download and add applications to bench: + + ```sh + $ bench get-app [app-name] [app-link] + ``` + + * Install apps on a particular site + + ```sh + $ bench --site [site-name] install-app [app-name] + ``` + + * Start bench (only for development) + + ```sh + $ bench start + ``` + + * Show bench help: + + ```sh + $ bench --help + ``` + + +For more in-depth information on commands and their usage, follow [Commands and Usage](https://github.com/frappe/bench/blob/master/docs/commands_and_usage.md). As for a consolidated list of bench commands, check out [Bench Usage](https://github.com/frappe/bench/blob/master/docs/bench_usage.md). ---- ## Custom Bench Commands -Want to utilize a bench command you've added in your custom Frappe application? [This](https://github.com/frappe/bench/blob/master/docs/bench_custom_cmd.md) guide might be of some help. +If you wish to extend the capabilities of bench with your own custom Frappe Application, you may follow [Adding Custom Bench Commands](https://github.com/frappe/bench/blob/master/docs/bench_custom_cmd.md). ---- -# Easy Install Script +## Bench Manager -- This is an opinionated setup so it is best to setup on a blank server. -- Works on Ubuntu 16.04+, CentOS 7+, Debian 8+ -- You may have to install Python 3 and other essentials by running `apt-get install python3-minimal build-essential python3-setuptools` -- This script will install the pre-requisites, install bench and setup an ERPNext site `(site1.local under frappe-bench)` -- Passwords for Frappe Administrator and MariaDB (root) will be asked and saved under `~/passwoords.txt` -- MariaDB (root) password may be `password` on a fresh server -- You can then login as **Administrator** with the Administrator password -- The log file is saved under `/tmp/logs/install_bench.log` in case you run into any issues during the install. -- If you find any problems, post them on the forum: [https://discuss.erpnext.com](https://discuss.erpnext.com/c/bench) with the `installation_problem` under "Install / Update" category. +[Bench Manager](https://github.com/frappe/bench_manager) is a GUI frontend for Bench with the same functionalties. You can install it by executing the following command: - wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py - python3 install.py --production +```sh +$ bench setup manager +``` -Follow [Easy Install Docs](https://github.com/frappe/bench/blob/master/docs/easy_install.md) for more information. + - **Note:** This will create a new site to setup Bench Manager, if you want to set it up on an existing site, run the following commands: ---- + ```sh + $ bench get-app https://github.com/frappe/bench_manager.git + $ bench --site install-app bench_manager + ``` -# Release Bench -Releases can be made for [Frappe](https://github.com/frappe/frappe) apps using bench. More information about this process can be found [here](https://github.com/frappe/bench/blob/master/docs/releasing_frappe_apps.md). - ---- - -# Bench Manager (GUI for Bench) - -[Bench Manager](https://github.com/frappe/bench_manager) is a graphical user interface to emulate the functionalities of Frappe Bench. Like the command line utility it helps you install apps, manage multiple sites, update apps and much more. Install just by executing the following command in the respective bench directory. - - bench setup manager - ---- - -# Docker - -- For official images and resources [Frappe Docker](https://github.com/frappe/frappe_docker) -- Production Installation [README](https://github.com/frappe/frappe_docker/blob/develop/README.md) -- Developer Setup [README](https://github.com/frappe/frappe_docker/blob/develop/development/README.md) - ---- - -# Guides +## Guides - [Configuring HTTPS](https://frappe.io/docs/user/en/bench/guides/configuring-https.html) - [Using Let's Encrypt to setup HTTPS](https://frappe.io/docs/user/en/bench/guides/lets-encrypt-ssl-setup.html) @@ -136,16 +241,18 @@ Releases can be made for [Frappe](https://github.com/frappe/frappe) apps using b - [Setup Multitenancy](https://frappe.io/docs/user/en/bench/guides/setup-multitenancy.html) - [Stopping Production](https://github.com/frappe/bench/wiki/Stopping-Production-and-starting-Development) ---- +For an exhaustive list of guides, check out [Bench Guides](https://frappe.io/docs/user/en/bench/guides). -# Resources -- [Background Services](https://frappe.io/docs/user/en/bench/resources/background-services.html) +## Resources + - [Bench Commands Cheat Sheet](https://frappe.io/docs/user/en/bench/resources/bench-commands-cheatsheet.html) +- [Background Services](https://frappe.io/docs/user/en/bench/resources/background-services.html) - [Bench Procfile](https://frappe.io/docs/user/en/bench/resources/bench-procfile.html) ---- +For an exhaustive list of resources, check out [Bench Resources](https://frappe.io/docs/user/en/bench/resources). -# License -bench is licensed under [GNU GPLv3](LICENSE) +## License + +This repository has been released under the [GNU GPLv3 License](LICENSE). diff --git a/bench/__init__.py b/bench/__init__.py index 1f0c5aac..f4ceb0c0 100644 --- a/bench/__init__.py +++ b/bench/__init__.py @@ -1,11 +1,8 @@ -from jinja2 import Environment, PackageLoader - -__version__ = "5.0.0" - -env = Environment(loader=PackageLoader('bench.config')) - +VERSION = "5.0.0" +PROJECT_NAME = "frappe-bench" FRAPPE_VERSION = None + def set_frappe_version(bench_path='.'): from .app import get_current_frappe_version global FRAPPE_VERSION diff --git a/bench/app.py b/bench/app.py index 48f8427e..8b165b2b 100755 --- a/bench/app.py +++ b/bench/app.py @@ -111,6 +111,9 @@ def get_app(git_url, branch=None, bench_path='.', skip_assets=False, verbose=Fal if git_url == data['name']: git_url = 'https://github.com/{org}/{app}'.format(org=org, app=git_url) break + else: + bench.utils.log("App {app} not found".format(app=git_url), level=2) + sys.exit(1) # Gets repo name from URL repo_name = git_url.rsplit('/', 1)[1].rsplit('.', 1)[0] @@ -177,8 +180,11 @@ def install_app(app, bench_path=".", verbose=False, no_cache=False, postprocess= app_path = os.path.join(bench_path, "apps", app) cache_flag = "--no-cache-dir" if no_cache else "" - exec_cmd("{pip} install {quiet} -U -e {app} {no_cache}".format(pip=pip_path, - quiet=quiet_flag, app=app_path, no_cache=cache_flag)) + exec_cmd("{pip} install {quiet} -U -e {app} {no_cache}".format(pip=pip_path, quiet=quiet_flag, app=app_path, no_cache=cache_flag)) + + if os.path.exists(os.path.join(app_path, 'package.json')): + exec_cmd("yarn install", cwd=app_path) + add_to_appstxt(app, bench_path=bench_path) if postprocess: @@ -407,7 +413,7 @@ def switch_branch(branch, apps=None, bench_path='.', upgrade=False, check_upgrad if version_upgrade[0] and upgrade: update_requirements() update_node_packages() - reload_module(utils) + reload_module(bench.utils) backup_all_sites() patch_sites() build_assets() diff --git a/bench/cli.py b/bench/cli.py index 628f2413..09c001d8 100755 --- a/bench/cli.py +++ b/bench/cli.py @@ -10,13 +10,13 @@ import sys import click # imports - module imports +import bench from bench.app import get_apps from bench.commands import bench_command from bench.config.common_site_config import get_config from bench.utils import PatchError, bench_cache_file, check_latest_version, drop_privileges, find_parent_bench, generate_command_cache, get_cmd_output, get_env_cmd, get_frappe, is_bench_directory, is_dist_editable, is_root, log - -logger = logging.getLogger('bench') +logger = logging.getLogger(bench.PROJECT_NAME) from_command_line = False change_uid_msg = "You should not run this command as root" @@ -30,7 +30,7 @@ def cli(): change_dir() change_uid() - if is_dist_editable("bench") and len(sys.argv) > 1 and sys.argv[1] != "src": + if is_dist_editable(bench.PROJECT_NAME) and len(sys.argv) > 1 and sys.argv[1] != "src": log("bench is installed in editable mode!\n\nThis is not the recommended mode of installation for production. Instead, install the package from PyPI with: `pip install frappe-bench`\n", level=3) if not is_bench_directory() and not cmd_requires_root() and len(sys.argv) > 1 and sys.argv[1] not in ("init", "find", "src"): diff --git a/bench/commands/__init__.py b/bench/commands/__init__.py index da4eb8c8..8ee317d9 100755 --- a/bench/commands/__init__.py +++ b/bench/commands/__init__.py @@ -7,13 +7,12 @@ def print_bench_version(ctx, param, value): return import bench - click.echo(bench.__version__) + click.echo(bench.VERSION) ctx.exit() @click.group() @click.option('--version', is_flag=True, is_eager=True, callback=print_bench_version, expose_value=False) def bench_command(bench_path='.'): - """Bench manager for Frappe""" import bench from bench.utils import setup_logging diff --git a/bench/commands/setup.py b/bench/commands/setup.py index 96360bea..2e516496 100755 --- a/bench/commands/setup.py +++ b/bench/commands/setup.py @@ -14,7 +14,6 @@ import bench.config.production_setup import bench.config.redis import bench.config.site_config import bench.config.supervisor - import bench.utils from bench.utils import exec_cmd, run_playbook diff --git a/bench/config/__init__.py b/bench/config/__init__.py index e69de29b..301b515b 100644 --- a/bench/config/__init__.py +++ b/bench/config/__init__.py @@ -0,0 +1,6 @@ +"""Module for setting up system and respective bench configurations""" + +# imports - third party imports +from jinja2 import Environment, PackageLoader + +env = Environment(loader=PackageLoader('bench.config')) diff --git a/bench/config/lets_encrypt.py b/bench/config/lets_encrypt.py index 4beac157..5f0396b9 100755 --- a/bench/config/lets_encrypt.py +++ b/bench/config/lets_encrypt.py @@ -1,15 +1,19 @@ -import bench, os, click, errno -from bench.utils import exec_cmd, CommandFailedError, update_common_site_config -from bench.config.site_config import update_site_config, remove_domain, get_domains +# imports - standard imports +import os + +# imports - third party imports +import click +from crontab import CronTab +from six.moves.urllib.request import urlretrieve + +# imports - module imports +import bench +from bench.config.common_site_config import get_config from bench.config.nginx import make_nginx_conf from bench.config.production_setup import service -from bench.config.common_site_config import get_config -from crontab import CronTab +from bench.config.site_config import get_domains, remove_domain, update_site_config +from bench.utils import CommandFailedError, exec_cmd, update_common_site_config -try: - from urllib.request import urlretrieve -except ImportError: - from urllib import urlretrieve def setup_letsencrypt(site, custom_domain, bench_path, interactive): @@ -44,7 +48,7 @@ def setup_letsencrypt(site, custom_domain, bench_path, interactive): def create_config(site, custom_domain): - config = bench.env.get_template('letsencrypt.cfg').render(domain=custom_domain or site) + config = bench.config.env.get_template('letsencrypt.cfg').render(domain=custom_domain or site) config_path = '/etc/letsencrypt/configs/{site}.cfg'.format(site=custom_domain or site) create_dir_if_missing(config_path) @@ -171,4 +175,3 @@ def setup_wildcard_ssl(domain, email, bench_path, exclude_base_domain): make_nginx_conf(bench_path) print("Restrting Nginx service") service('nginx', 'restart') - diff --git a/bench/config/nginx.py b/bench/config/nginx.py index 9f10c6f7..d2154112 100644 --- a/bench/config/nginx.py +++ b/bench/config/nginx.py @@ -9,6 +9,7 @@ import click from six import string_types # imports - module imports +import bench from bench.utils import get_bench_name, get_sites @@ -19,14 +20,11 @@ def make_nginx_conf(bench_path, yes=False): if not click.confirm('nginx.conf already exists and this will overwrite it. Do you want to continue?'): return - from bench import env - from bench.config.common_site_config import get_config - - template = env.get_template('nginx.conf') + template = bench.config.env.get_template('nginx.conf') bench_path = os.path.abspath(bench_path) sites_path = os.path.join(bench_path, "sites") - config = get_config(bench_path) + config = bench.config.common_site_config.get_config(bench_path) sites = prepare_sites(config, bench_path) bench_name = get_bench_name(bench_path) @@ -58,17 +56,15 @@ def make_nginx_conf(bench_path, yes=False): f.write(nginx_conf) def make_bench_manager_nginx_conf(bench_path, yes=False, port=23624, domain=None): - from bench import env from bench.config.site_config import get_site_config from bench.config.common_site_config import get_config - template = env.get_template('bench_manager_nginx.conf') + template = bench.config.env.get_template('bench_manager_nginx.conf') bench_path = os.path.abspath(bench_path) sites_path = os.path.join(bench_path, "sites") config = get_config(bench_path) site_config = get_site_config(domain, bench_path=bench_path) - sites = prepare_sites(config, bench_path) bench_name = get_bench_name(bench_path) template_vars = { @@ -153,9 +149,6 @@ def prepare_sites(config, bench_path): while site["port"] in ports_in_use: site["port"] += 1 -# if site["port"] in ports_in_use: -# raise Exception("Port {0} is being used by another site {1}".format(site["port"], ports_in_use[site["port"]])) - if site["port"] in ports_in_use and not site["name"] in ports_in_use[site["port"]]: shared_port_exception_found = True ports_in_use[site["port"]].append(site["name"]) diff --git a/bench/config/procfile.py b/bench/config/procfile.py index a6982c83..1b3f20ed 100755 --- a/bench/config/procfile.py +++ b/bench/config/procfile.py @@ -1,7 +1,15 @@ -import bench, os, click -from bench.utils import find_executable +# imports - standard imports +import os + +# imports - third party imports +import click + +# imports - module imports +import bench from bench.app import use_rq from bench.config.common_site_config import get_config +from bench.utils import find_executable + def setup_procfile(bench_path, yes=False, skip_redis=False): config = get_config(bench_path=bench_path) @@ -10,7 +18,7 @@ def setup_procfile(bench_path, yes=False, skip_redis=False): click.confirm('A Procfile already exists and this will overwrite it. Do you want to continue?', abort=True) - procfile = bench.env.get_template('Procfile').render( + procfile = bench.config.env.get_template('Procfile').render( node=find_executable("node") or find_executable("nodejs"), use_rq=use_rq(bench_path), webserver_port=config.get('webserver_port'), diff --git a/bench/config/production_setup.py b/bench/config/production_setup.py index dff6a402..4b5fc774 100755 --- a/bench/config/production_setup.py +++ b/bench/config/production_setup.py @@ -1,14 +1,13 @@ # imports - standard imports import os import sys -from distutils.spawn import find_executable # imports - module imports from bench.config.common_site_config import get_config from bench.config.nginx import make_nginx_conf from bench.config.supervisor import generate_supervisor_config from bench.config.systemd import generate_systemd_config -from bench.utils import CommandFailedError, exec_cmd, fix_prod_setup_perms, get_bench_name, get_cmd_output +from bench.utils import CommandFailedError, exec_cmd, find_executable, fix_prod_setup_perms, get_bench_name, get_cmd_output def setup_production_prerequisites(): diff --git a/bench/config/redis.py b/bench/config/redis.py index ae9b5b0f..42005b07 100644 --- a/bench/config/redis.py +++ b/bench/config/redis.py @@ -52,7 +52,7 @@ def generate_config(bench_path): os.makedirs(pid_path) def write_redis_config(template_name, context, bench_path): - template = bench.env.get_template(template_name) + template = bench.config.env.get_template(template_name) if "pid_path" not in context: context["pid_path"] = os.path.abspath(os.path.join(bench_path, "config", "pids")) diff --git a/bench/config/site_config.py b/bench/config/site_config.py index 6db83ea3..696185c8 100644 --- a/bench/config/site_config.py +++ b/bench/config/site_config.py @@ -1,8 +1,13 @@ -import os, json -from bench.utils import get_sites -from bench.config.nginx import make_nginx_conf +# imports - standard imports +import json +import os from collections import defaultdict +# imports - module imports +from bench.config.nginx import make_nginx_conf +from bench.utils import get_sites + + def get_site_config(site, bench_path='.'): config_path = os.path.join(bench_path, 'sites', site, 'site_config.json') if not os.path.exists(config_path): diff --git a/bench/config/supervisor.py b/bench/config/supervisor.py index 43560cf0..9e9b7a89 100644 --- a/bench/config/supervisor.py +++ b/bench/config/supervisor.py @@ -20,7 +20,7 @@ def generate_supervisor_config(bench_path, user=None, yes=False): update_supervisord_conf(user=user) - template = bench.env.get_template('supervisor.conf') + template = bench.config.env.get_template('supervisor.conf') config = get_config(bench_path=bench_path) bench_dir = os.path.abspath(bench_path) diff --git a/bench/config/systemd.py b/bench/config/systemd.py index 72bed1f2..4a414825 100644 --- a/bench/config/systemd.py +++ b/bench/config/systemd.py @@ -1,9 +1,16 @@ -import os, getpass, click +# imports - standard imports +import getpass +import os + +# imports - third partyimports +import click + +# imports - module imports import bench -from bench.utils import exec_cmd from bench.app import get_current_frappe_version, use_rq -from bench.utils import get_bench_name, find_executable -from bench.config.common_site_config import get_config, update_config, get_gunicorn_workers +from bench.config.common_site_config import get_config, get_gunicorn_workers, update_config +from bench.utils import exec_cmd, find_executable, get_bench_name + def generate_systemd_config(bench_path, user=None, yes=False, stop=False, create_symlinks=False, @@ -78,7 +85,7 @@ def setup_systemd_directory(bench_path): def setup_main_config(bench_info, bench_path): # Main config - bench_template = bench.env.get_template('systemd/frappe-bench.target') + bench_template = bench.config.env.get_template('systemd/frappe-bench.target') bench_config = bench_template.render(**bench_info) bench_config_path = os.path.join(bench_path, 'config', 'systemd' , bench_info.get("bench_name") + '.target') @@ -87,11 +94,11 @@ def setup_main_config(bench_info, bench_path): def setup_workers_config(bench_info, bench_path): # Worker Group - bench_workers_target_template = bench.env.get_template('systemd/frappe-bench-workers.target') - bench_default_worker_template = bench.env.get_template('systemd/frappe-bench-frappe-default-worker.service') - bench_short_worker_template = bench.env.get_template('systemd/frappe-bench-frappe-short-worker.service') - bench_long_worker_template = bench.env.get_template('systemd/frappe-bench-frappe-long-worker.service') - bench_schedule_worker_template = bench.env.get_template('systemd/frappe-bench-frappe-schedule.service') + bench_workers_target_template = bench.config.env.get_template('systemd/frappe-bench-workers.target') + bench_default_worker_template = bench.config.env.get_template('systemd/frappe-bench-frappe-default-worker.service') + bench_short_worker_template = bench.config.env.get_template('systemd/frappe-bench-frappe-short-worker.service') + bench_long_worker_template = bench.config.env.get_template('systemd/frappe-bench-frappe-long-worker.service') + bench_schedule_worker_template = bench.config.env.get_template('systemd/frappe-bench-frappe-schedule.service') bench_workers_target_config = bench_workers_target_template.render(**bench_info) bench_default_worker_config = bench_default_worker_template.render(**bench_info) @@ -122,9 +129,9 @@ def setup_workers_config(bench_info, bench_path): def setup_web_config(bench_info, bench_path): # Web Group - bench_web_target_template = bench.env.get_template('systemd/frappe-bench-web.target') - bench_web_service_template = bench.env.get_template('systemd/frappe-bench-frappe-web.service') - bench_node_socketio_template = bench.env.get_template('systemd/frappe-bench-node-socketio.service') + bench_web_target_template = bench.config.env.get_template('systemd/frappe-bench-web.target') + bench_web_service_template = bench.config.env.get_template('systemd/frappe-bench-frappe-web.service') + bench_node_socketio_template = bench.config.env.get_template('systemd/frappe-bench-node-socketio.service') bench_web_target_config = bench_web_target_template.render(**bench_info) bench_web_service_config = bench_web_service_template.render(**bench_info) @@ -145,10 +152,10 @@ def setup_web_config(bench_info, bench_path): def setup_redis_config(bench_info, bench_path): # Redis Group - bench_redis_target_template = bench.env.get_template('systemd/frappe-bench-redis.target') - bench_redis_cache_template = bench.env.get_template('systemd/frappe-bench-redis-cache.service') - bench_redis_queue_template = bench.env.get_template('systemd/frappe-bench-redis-queue.service') - bench_redis_socketio_template = bench.env.get_template('systemd/frappe-bench-redis-socketio.service') + bench_redis_target_template = bench.config.env.get_template('systemd/frappe-bench-redis.target') + bench_redis_cache_template = bench.config.env.get_template('systemd/frappe-bench-redis-cache.service') + bench_redis_queue_template = bench.config.env.get_template('systemd/frappe-bench-redis-queue.service') + bench_redis_socketio_template = bench.config.env.get_template('systemd/frappe-bench-redis-socketio.service') bench_redis_target_config = bench_redis_target_template.render(**bench_info) bench_redis_cache_config = bench_redis_cache_template.render(**bench_info) diff --git a/playbooks/README.md b/bench/playbooks/README.md similarity index 100% rename from playbooks/README.md rename to bench/playbooks/README.md diff --git a/playbooks/create_user.yml b/bench/playbooks/create_user.yml similarity index 100% rename from playbooks/create_user.yml rename to bench/playbooks/create_user.yml diff --git a/playbooks/macosx.yml b/bench/playbooks/macosx.yml similarity index 100% rename from playbooks/macosx.yml rename to bench/playbooks/macosx.yml diff --git a/playbooks/roles/bash_screen_wall/files/screen_wall.sh b/bench/playbooks/roles/bash_screen_wall/files/screen_wall.sh similarity index 100% rename from playbooks/roles/bash_screen_wall/files/screen_wall.sh rename to bench/playbooks/roles/bash_screen_wall/files/screen_wall.sh diff --git a/playbooks/roles/bash_screen_wall/tasks/main.yml b/bench/playbooks/roles/bash_screen_wall/tasks/main.yml similarity index 100% rename from playbooks/roles/bash_screen_wall/tasks/main.yml rename to bench/playbooks/roles/bash_screen_wall/tasks/main.yml diff --git a/playbooks/roles/bench/tasks/change_ssh_port.yml b/bench/playbooks/roles/bench/tasks/change_ssh_port.yml similarity index 100% rename from playbooks/roles/bench/tasks/change_ssh_port.yml rename to bench/playbooks/roles/bench/tasks/change_ssh_port.yml diff --git a/playbooks/roles/bench/tasks/main.yml b/bench/playbooks/roles/bench/tasks/main.yml similarity index 100% rename from playbooks/roles/bench/tasks/main.yml rename to bench/playbooks/roles/bench/tasks/main.yml diff --git a/playbooks/roles/bench/tasks/setup_bench_production.yml b/bench/playbooks/roles/bench/tasks/setup_bench_production.yml similarity index 100% rename from playbooks/roles/bench/tasks/setup_bench_production.yml rename to bench/playbooks/roles/bench/tasks/setup_bench_production.yml diff --git a/playbooks/roles/bench/tasks/setup_erpnext.yml b/bench/playbooks/roles/bench/tasks/setup_erpnext.yml similarity index 100% rename from playbooks/roles/bench/tasks/setup_erpnext.yml rename to bench/playbooks/roles/bench/tasks/setup_erpnext.yml diff --git a/playbooks/roles/bench/tasks/setup_firewall.yml b/bench/playbooks/roles/bench/tasks/setup_firewall.yml similarity index 100% rename from playbooks/roles/bench/tasks/setup_firewall.yml rename to bench/playbooks/roles/bench/tasks/setup_firewall.yml diff --git a/playbooks/roles/bench/tasks/setup_inputrc.yml b/bench/playbooks/roles/bench/tasks/setup_inputrc.yml similarity index 100% rename from playbooks/roles/bench/tasks/setup_inputrc.yml rename to bench/playbooks/roles/bench/tasks/setup_inputrc.yml diff --git a/playbooks/roles/common/tasks/debian.yml b/bench/playbooks/roles/common/tasks/debian.yml similarity index 100% rename from playbooks/roles/common/tasks/debian.yml rename to bench/playbooks/roles/common/tasks/debian.yml diff --git a/playbooks/roles/common/tasks/debian_family.yml b/bench/playbooks/roles/common/tasks/debian_family.yml similarity index 100% rename from playbooks/roles/common/tasks/debian_family.yml rename to bench/playbooks/roles/common/tasks/debian_family.yml diff --git a/playbooks/roles/common/tasks/macos.yml b/bench/playbooks/roles/common/tasks/macos.yml similarity index 100% rename from playbooks/roles/common/tasks/macos.yml rename to bench/playbooks/roles/common/tasks/macos.yml diff --git a/playbooks/roles/common/tasks/main.yml b/bench/playbooks/roles/common/tasks/main.yml similarity index 100% rename from playbooks/roles/common/tasks/main.yml rename to bench/playbooks/roles/common/tasks/main.yml diff --git a/playbooks/roles/common/tasks/redhat_family.yml b/bench/playbooks/roles/common/tasks/redhat_family.yml similarity index 100% rename from playbooks/roles/common/tasks/redhat_family.yml rename to bench/playbooks/roles/common/tasks/redhat_family.yml diff --git a/playbooks/roles/common/tasks/ubuntu.yml b/bench/playbooks/roles/common/tasks/ubuntu.yml similarity index 100% rename from playbooks/roles/common/tasks/ubuntu.yml rename to bench/playbooks/roles/common/tasks/ubuntu.yml diff --git a/playbooks/roles/dns_caching/handlers/main.yml b/bench/playbooks/roles/dns_caching/handlers/main.yml similarity index 100% rename from playbooks/roles/dns_caching/handlers/main.yml rename to bench/playbooks/roles/dns_caching/handlers/main.yml diff --git a/playbooks/roles/dns_caching/tasks/main.yml b/bench/playbooks/roles/dns_caching/tasks/main.yml similarity index 100% rename from playbooks/roles/dns_caching/tasks/main.yml rename to bench/playbooks/roles/dns_caching/tasks/main.yml diff --git a/playbooks/roles/fail2ban/defaults/main.yml b/bench/playbooks/roles/fail2ban/defaults/main.yml similarity index 100% rename from playbooks/roles/fail2ban/defaults/main.yml rename to bench/playbooks/roles/fail2ban/defaults/main.yml diff --git a/playbooks/roles/fail2ban/handlers/main.yml b/bench/playbooks/roles/fail2ban/handlers/main.yml similarity index 100% rename from playbooks/roles/fail2ban/handlers/main.yml rename to bench/playbooks/roles/fail2ban/handlers/main.yml diff --git a/playbooks/roles/fail2ban/tasks/configure_nginx_jail.yml b/bench/playbooks/roles/fail2ban/tasks/configure_nginx_jail.yml similarity index 100% rename from playbooks/roles/fail2ban/tasks/configure_nginx_jail.yml rename to bench/playbooks/roles/fail2ban/tasks/configure_nginx_jail.yml diff --git a/playbooks/roles/fail2ban/tasks/main.yml b/bench/playbooks/roles/fail2ban/tasks/main.yml similarity index 100% rename from playbooks/roles/fail2ban/tasks/main.yml rename to bench/playbooks/roles/fail2ban/tasks/main.yml diff --git a/playbooks/roles/fail2ban/templates/nginx-proxy-filter.conf.j2 b/bench/playbooks/roles/fail2ban/templates/nginx-proxy-filter.conf.j2 similarity index 100% rename from playbooks/roles/fail2ban/templates/nginx-proxy-filter.conf.j2 rename to bench/playbooks/roles/fail2ban/templates/nginx-proxy-filter.conf.j2 diff --git a/playbooks/roles/fail2ban/templates/nginx-proxy-jail.conf.j2 b/bench/playbooks/roles/fail2ban/templates/nginx-proxy-jail.conf.j2 similarity index 100% rename from playbooks/roles/fail2ban/templates/nginx-proxy-jail.conf.j2 rename to bench/playbooks/roles/fail2ban/templates/nginx-proxy-jail.conf.j2 diff --git a/playbooks/roles/frappe_selinux/files/frappe_selinux.te b/bench/playbooks/roles/frappe_selinux/files/frappe_selinux.te similarity index 100% rename from playbooks/roles/frappe_selinux/files/frappe_selinux.te rename to bench/playbooks/roles/frappe_selinux/files/frappe_selinux.te diff --git a/playbooks/roles/frappe_selinux/tasks/main.yml b/bench/playbooks/roles/frappe_selinux/tasks/main.yml similarity index 100% rename from playbooks/roles/frappe_selinux/tasks/main.yml rename to bench/playbooks/roles/frappe_selinux/tasks/main.yml diff --git a/playbooks/roles/locale/defaults/main.yml b/bench/playbooks/roles/locale/defaults/main.yml similarity index 100% rename from playbooks/roles/locale/defaults/main.yml rename to bench/playbooks/roles/locale/defaults/main.yml diff --git a/playbooks/roles/locale/tasks/main.yml b/bench/playbooks/roles/locale/tasks/main.yml similarity index 100% rename from playbooks/roles/locale/tasks/main.yml rename to bench/playbooks/roles/locale/tasks/main.yml diff --git a/playbooks/roles/logwatch/defaults/main.yml b/bench/playbooks/roles/logwatch/defaults/main.yml similarity index 100% rename from playbooks/roles/logwatch/defaults/main.yml rename to bench/playbooks/roles/logwatch/defaults/main.yml diff --git a/playbooks/roles/logwatch/tasks/main.yml b/bench/playbooks/roles/logwatch/tasks/main.yml similarity index 100% rename from playbooks/roles/logwatch/tasks/main.yml rename to bench/playbooks/roles/logwatch/tasks/main.yml diff --git a/playbooks/roles/logwatch/templates/logwatch.conf.j2 b/bench/playbooks/roles/logwatch/templates/logwatch.conf.j2 similarity index 100% rename from playbooks/roles/logwatch/templates/logwatch.conf.j2 rename to bench/playbooks/roles/logwatch/templates/logwatch.conf.j2 diff --git a/playbooks/roles/mariadb/README.md b/bench/playbooks/roles/mariadb/README.md similarity index 100% rename from playbooks/roles/mariadb/README.md rename to bench/playbooks/roles/mariadb/README.md diff --git a/playbooks/roles/mariadb/defaults/main.yml b/bench/playbooks/roles/mariadb/defaults/main.yml similarity index 100% rename from playbooks/roles/mariadb/defaults/main.yml rename to bench/playbooks/roles/mariadb/defaults/main.yml diff --git a/playbooks/roles/mariadb/files/debian_mariadb_config.cnf b/bench/playbooks/roles/mariadb/files/debian_mariadb_config.cnf similarity index 100% rename from playbooks/roles/mariadb/files/debian_mariadb_config.cnf rename to bench/playbooks/roles/mariadb/files/debian_mariadb_config.cnf diff --git a/playbooks/roles/mariadb/files/mariadb_config.cnf b/bench/playbooks/roles/mariadb/files/mariadb_config.cnf similarity index 100% rename from playbooks/roles/mariadb/files/mariadb_config.cnf rename to bench/playbooks/roles/mariadb/files/mariadb_config.cnf diff --git a/playbooks/roles/mariadb/handlers/main.yml b/bench/playbooks/roles/mariadb/handlers/main.yml similarity index 100% rename from playbooks/roles/mariadb/handlers/main.yml rename to bench/playbooks/roles/mariadb/handlers/main.yml diff --git a/playbooks/roles/mariadb/tasks/centos.yml b/bench/playbooks/roles/mariadb/tasks/centos.yml similarity index 100% rename from playbooks/roles/mariadb/tasks/centos.yml rename to bench/playbooks/roles/mariadb/tasks/centos.yml diff --git a/playbooks/roles/mariadb/tasks/debian.yml b/bench/playbooks/roles/mariadb/tasks/debian.yml similarity index 100% rename from playbooks/roles/mariadb/tasks/debian.yml rename to bench/playbooks/roles/mariadb/tasks/debian.yml diff --git a/playbooks/roles/mariadb/tasks/main.yml b/bench/playbooks/roles/mariadb/tasks/main.yml similarity index 100% rename from playbooks/roles/mariadb/tasks/main.yml rename to bench/playbooks/roles/mariadb/tasks/main.yml diff --git a/playbooks/roles/mariadb/tasks/mysql_secure_installation.yml b/bench/playbooks/roles/mariadb/tasks/mysql_secure_installation.yml similarity index 100% rename from playbooks/roles/mariadb/tasks/mysql_secure_installation.yml rename to bench/playbooks/roles/mariadb/tasks/mysql_secure_installation.yml diff --git a/playbooks/roles/mariadb/tasks/ubuntu-trusty.yml b/bench/playbooks/roles/mariadb/tasks/ubuntu-trusty.yml similarity index 100% rename from playbooks/roles/mariadb/tasks/ubuntu-trusty.yml rename to bench/playbooks/roles/mariadb/tasks/ubuntu-trusty.yml diff --git a/playbooks/roles/mariadb/tasks/ubuntu-xenial_bionic.yml b/bench/playbooks/roles/mariadb/tasks/ubuntu-xenial_bionic.yml similarity index 100% rename from playbooks/roles/mariadb/tasks/ubuntu-xenial_bionic.yml rename to bench/playbooks/roles/mariadb/tasks/ubuntu-xenial_bionic.yml diff --git a/playbooks/roles/mariadb/templates/mariadb_centos.repo.j2 b/bench/playbooks/roles/mariadb/templates/mariadb_centos.repo.j2 similarity index 100% rename from playbooks/roles/mariadb/templates/mariadb_centos.repo.j2 rename to bench/playbooks/roles/mariadb/templates/mariadb_centos.repo.j2 diff --git a/playbooks/roles/mariadb/templates/mariadb_debian.list.j2 b/bench/playbooks/roles/mariadb/templates/mariadb_debian.list.j2 similarity index 100% rename from playbooks/roles/mariadb/templates/mariadb_debian.list.j2 rename to bench/playbooks/roles/mariadb/templates/mariadb_debian.list.j2 diff --git a/playbooks/roles/mariadb/templates/mariadb_ubuntu.list.j2 b/bench/playbooks/roles/mariadb/templates/mariadb_ubuntu.list.j2 similarity index 100% rename from playbooks/roles/mariadb/templates/mariadb_ubuntu.list.j2 rename to bench/playbooks/roles/mariadb/templates/mariadb_ubuntu.list.j2 diff --git a/playbooks/roles/mariadb/templates/my.cnf.j2 b/bench/playbooks/roles/mariadb/templates/my.cnf.j2 similarity index 100% rename from playbooks/roles/mariadb/templates/my.cnf.j2 rename to bench/playbooks/roles/mariadb/templates/my.cnf.j2 diff --git a/playbooks/roles/mariadb/vars/main.yml b/bench/playbooks/roles/mariadb/vars/main.yml similarity index 100% rename from playbooks/roles/mariadb/vars/main.yml rename to bench/playbooks/roles/mariadb/vars/main.yml diff --git a/playbooks/roles/nginx/README.md b/bench/playbooks/roles/nginx/README.md similarity index 100% rename from playbooks/roles/nginx/README.md rename to bench/playbooks/roles/nginx/README.md diff --git a/playbooks/roles/nginx/defaults/main.yml b/bench/playbooks/roles/nginx/defaults/main.yml similarity index 100% rename from playbooks/roles/nginx/defaults/main.yml rename to bench/playbooks/roles/nginx/defaults/main.yml diff --git a/playbooks/roles/nginx/handlers/main.yml b/bench/playbooks/roles/nginx/handlers/main.yml similarity index 100% rename from playbooks/roles/nginx/handlers/main.yml rename to bench/playbooks/roles/nginx/handlers/main.yml diff --git a/playbooks/roles/nginx/meta/main.yml b/bench/playbooks/roles/nginx/meta/main.yml similarity index 100% rename from playbooks/roles/nginx/meta/main.yml rename to bench/playbooks/roles/nginx/meta/main.yml diff --git a/playbooks/roles/nginx/tasks/main.yml b/bench/playbooks/roles/nginx/tasks/main.yml similarity index 100% rename from playbooks/roles/nginx/tasks/main.yml rename to bench/playbooks/roles/nginx/tasks/main.yml diff --git a/playbooks/roles/nginx/tasks/setup-Debian.yml b/bench/playbooks/roles/nginx/tasks/setup-Debian.yml similarity index 100% rename from playbooks/roles/nginx/tasks/setup-Debian.yml rename to bench/playbooks/roles/nginx/tasks/setup-Debian.yml diff --git a/playbooks/roles/nginx/tasks/setup-RedHat.yml b/bench/playbooks/roles/nginx/tasks/setup-RedHat.yml similarity index 100% rename from playbooks/roles/nginx/tasks/setup-RedHat.yml rename to bench/playbooks/roles/nginx/tasks/setup-RedHat.yml diff --git a/playbooks/roles/nginx/tasks/vhosts.yml b/bench/playbooks/roles/nginx/tasks/vhosts.yml similarity index 100% rename from playbooks/roles/nginx/tasks/vhosts.yml rename to bench/playbooks/roles/nginx/tasks/vhosts.yml diff --git a/playbooks/roles/nginx/templates/nginx.conf.j2 b/bench/playbooks/roles/nginx/templates/nginx.conf.j2 similarity index 100% rename from playbooks/roles/nginx/templates/nginx.conf.j2 rename to bench/playbooks/roles/nginx/templates/nginx.conf.j2 diff --git a/playbooks/roles/nginx/templates/nginx.repo.j2 b/bench/playbooks/roles/nginx/templates/nginx.repo.j2 similarity index 100% rename from playbooks/roles/nginx/templates/nginx.repo.j2 rename to bench/playbooks/roles/nginx/templates/nginx.repo.j2 diff --git a/playbooks/roles/nginx/templates/vhosts.j2 b/bench/playbooks/roles/nginx/templates/vhosts.j2 similarity index 100% rename from playbooks/roles/nginx/templates/vhosts.j2 rename to bench/playbooks/roles/nginx/templates/vhosts.j2 diff --git a/playbooks/roles/nginx/tests/inventory b/bench/playbooks/roles/nginx/tests/inventory similarity index 100% rename from playbooks/roles/nginx/tests/inventory rename to bench/playbooks/roles/nginx/tests/inventory diff --git a/playbooks/roles/nginx/tests/test.yml b/bench/playbooks/roles/nginx/tests/test.yml similarity index 100% rename from playbooks/roles/nginx/tests/test.yml rename to bench/playbooks/roles/nginx/tests/test.yml diff --git a/playbooks/roles/nginx/vars/Debian.yml b/bench/playbooks/roles/nginx/vars/Debian.yml similarity index 100% rename from playbooks/roles/nginx/vars/Debian.yml rename to bench/playbooks/roles/nginx/vars/Debian.yml diff --git a/playbooks/roles/nginx/vars/RedHat.yml b/bench/playbooks/roles/nginx/vars/RedHat.yml similarity index 100% rename from playbooks/roles/nginx/vars/RedHat.yml rename to bench/playbooks/roles/nginx/vars/RedHat.yml diff --git a/playbooks/roles/nodejs/defaults/main.yml b/bench/playbooks/roles/nodejs/defaults/main.yml similarity index 100% rename from playbooks/roles/nodejs/defaults/main.yml rename to bench/playbooks/roles/nodejs/defaults/main.yml diff --git a/playbooks/roles/nodejs/tasks/debian_family.yml b/bench/playbooks/roles/nodejs/tasks/debian_family.yml similarity index 100% rename from playbooks/roles/nodejs/tasks/debian_family.yml rename to bench/playbooks/roles/nodejs/tasks/debian_family.yml diff --git a/playbooks/roles/nodejs/tasks/main.yml b/bench/playbooks/roles/nodejs/tasks/main.yml similarity index 100% rename from playbooks/roles/nodejs/tasks/main.yml rename to bench/playbooks/roles/nodejs/tasks/main.yml diff --git a/playbooks/roles/nodejs/tasks/redhat_family.yml b/bench/playbooks/roles/nodejs/tasks/redhat_family.yml similarity index 100% rename from playbooks/roles/nodejs/tasks/redhat_family.yml rename to bench/playbooks/roles/nodejs/tasks/redhat_family.yml diff --git a/playbooks/roles/ntpd/tasks/main.yml b/bench/playbooks/roles/ntpd/tasks/main.yml similarity index 100% rename from playbooks/roles/ntpd/tasks/main.yml rename to bench/playbooks/roles/ntpd/tasks/main.yml diff --git a/playbooks/roles/packer/tasks/debian_family.yml b/bench/playbooks/roles/packer/tasks/debian_family.yml similarity index 100% rename from playbooks/roles/packer/tasks/debian_family.yml rename to bench/playbooks/roles/packer/tasks/debian_family.yml diff --git a/playbooks/roles/packer/tasks/main.yml b/bench/playbooks/roles/packer/tasks/main.yml similarity index 100% rename from playbooks/roles/packer/tasks/main.yml rename to bench/playbooks/roles/packer/tasks/main.yml diff --git a/playbooks/roles/packer/tasks/redhat_family.yml b/bench/playbooks/roles/packer/tasks/redhat_family.yml similarity index 100% rename from playbooks/roles/packer/tasks/redhat_family.yml rename to bench/playbooks/roles/packer/tasks/redhat_family.yml diff --git a/playbooks/roles/psutil/tasks/main.yml b/bench/playbooks/roles/psutil/tasks/main.yml similarity index 100% rename from playbooks/roles/psutil/tasks/main.yml rename to bench/playbooks/roles/psutil/tasks/main.yml diff --git a/playbooks/roles/redis/tasks/main.yml b/bench/playbooks/roles/redis/tasks/main.yml similarity index 100% rename from playbooks/roles/redis/tasks/main.yml rename to bench/playbooks/roles/redis/tasks/main.yml diff --git a/playbooks/roles/supervisor/tasks/main.yml b/bench/playbooks/roles/supervisor/tasks/main.yml similarity index 100% rename from playbooks/roles/supervisor/tasks/main.yml rename to bench/playbooks/roles/supervisor/tasks/main.yml diff --git a/playbooks/roles/swap/defaults/main.yml b/bench/playbooks/roles/swap/defaults/main.yml similarity index 100% rename from playbooks/roles/swap/defaults/main.yml rename to bench/playbooks/roles/swap/defaults/main.yml diff --git a/playbooks/roles/swap/tasks/main.yml b/bench/playbooks/roles/swap/tasks/main.yml similarity index 100% rename from playbooks/roles/swap/tasks/main.yml rename to bench/playbooks/roles/swap/tasks/main.yml diff --git a/playbooks/roles/virtualbox/defaults/main.yml b/bench/playbooks/roles/virtualbox/defaults/main.yml similarity index 100% rename from playbooks/roles/virtualbox/defaults/main.yml rename to bench/playbooks/roles/virtualbox/defaults/main.yml diff --git a/playbooks/roles/virtualbox/files/virtualbox_centos.repo b/bench/playbooks/roles/virtualbox/files/virtualbox_centos.repo similarity index 100% rename from playbooks/roles/virtualbox/files/virtualbox_centos.repo rename to bench/playbooks/roles/virtualbox/files/virtualbox_centos.repo diff --git a/playbooks/roles/virtualbox/tasks/debian_family.yml b/bench/playbooks/roles/virtualbox/tasks/debian_family.yml similarity index 100% rename from playbooks/roles/virtualbox/tasks/debian_family.yml rename to bench/playbooks/roles/virtualbox/tasks/debian_family.yml diff --git a/playbooks/roles/virtualbox/tasks/main.yml b/bench/playbooks/roles/virtualbox/tasks/main.yml similarity index 100% rename from playbooks/roles/virtualbox/tasks/main.yml rename to bench/playbooks/roles/virtualbox/tasks/main.yml diff --git a/playbooks/roles/virtualbox/tasks/redhat_family.yml b/bench/playbooks/roles/virtualbox/tasks/redhat_family.yml similarity index 100% rename from playbooks/roles/virtualbox/tasks/redhat_family.yml rename to bench/playbooks/roles/virtualbox/tasks/redhat_family.yml diff --git a/playbooks/roles/wkhtmltopdf/tasks/main.yml b/bench/playbooks/roles/wkhtmltopdf/tasks/main.yml similarity index 100% rename from playbooks/roles/wkhtmltopdf/tasks/main.yml rename to bench/playbooks/roles/wkhtmltopdf/tasks/main.yml diff --git a/playbooks/site.yml b/bench/playbooks/site.yml similarity index 100% rename from playbooks/site.yml rename to bench/playbooks/site.yml diff --git a/playbooks/vm_build.yml b/bench/playbooks/vm_build.yml similarity index 100% rename from playbooks/vm_build.yml rename to bench/playbooks/vm_build.yml diff --git a/bench/utils.py b/bench/utils.py index bfaba366..711ab2f7 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -96,7 +96,7 @@ def check_latest_version(): if pypi_request.status_code == 200: pypi_version_str = pypi_request.json().get('info').get('version') pypi_version = Version(pypi_version_str) - local_version = Version(bench.__version__) + local_version = Version(bench.VERSION) if pypi_version > local_version: log("A newer version of bench is available: {0} → {1}".format(local_version, pypi_version)) @@ -394,8 +394,6 @@ def setup_backups(bench_path='.'): def setup_sudoers(user): - from bench import env - if not os.path.exists('/etc/sudoers.d'): os.makedirs('/etc/sudoers.d') @@ -409,7 +407,7 @@ def setup_sudoers(user): if set_permissions: os.chmod('/etc/sudoers', 0o440) - template = env.get_template('frappe_sudoers') + template = bench.config.env.get_template('frappe_sudoers') frappe_sudoers = template.render(**{ 'user': user, 'service': find_executable('service'), @@ -427,7 +425,7 @@ def setup_sudoers(user): def setup_logging(bench_path='.'): if os.path.exists(os.path.join(bench_path, 'logs')): - logger = logging.getLogger('bench') + logger = logging.getLogger(bench.PROJECT_NAME) log_file = os.path.join(bench_path, 'logs', 'bench.log') formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') hdlr = logging.FileHandler(log_file) @@ -954,7 +952,7 @@ def run_playbook(playbook_name, extra_vars=None, tag=None): if tag: args.extend(['-t', tag]) - subprocess.check_call(args, cwd=os.path.join(os.path.dirname(bench.__path__[0]), 'playbooks')) + subprocess.check_call(args, cwd=os.path.join(bench.__path__[0], 'playbooks')) def find_benches(directory=None): diff --git a/docs/easy_install.md b/docs/easy_install.md index 8caa7a30..7bf525d0 100644 --- a/docs/easy_install.md +++ b/docs/easy_install.md @@ -36,7 +36,7 @@ If you are on a fresh server and logged in as root, at first create a dedicated Switch to `[frappe-user]` (using `su [frappe-user]`) and start the setup - wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py + wget https://raw.githubusercontent.com/frappe/bench/develop/install.py #### 1. Run the install script diff --git a/playbooks/install.py b/install.py similarity index 99% rename from playbooks/install.py rename to install.py index 9867d185..cb8ecff8 100644 --- a/playbooks/install.py +++ b/install.py @@ -359,7 +359,7 @@ def run_playbook(playbook_name, sudo=False, extra_vars=None): else: cwd = os.path.join(os.path.expanduser('~'), 'bench') - success = subprocess.check_call(args, cwd=os.path.join(cwd, 'playbooks'), stdout=log_stream, stderr=sys.stderr) + success = subprocess.check_call(args, cwd=os.path.join(cwd, 'bench', 'playbooks'), stdout=log_stream, stderr=sys.stderr) return success diff --git a/setup.py b/setup.py index 6cbeddbc..055f0422 100644 --- a/setup.py +++ b/setup.py @@ -1,22 +1,15 @@ -from setuptools import setup, find_packages -import re, ast - -# get version from __version__ variable in bench/__init__.py -_version_re = re.compile(r'__version__\s+=\s+(.*)') +from setuptools import find_packages, setup +from bench import PROJECT_NAME, VERSION with open('requirements.txt') as f: install_requires = f.read().strip().split('\n') -with open('bench/__init__.py', 'rb') as f: - version = str(ast.literal_eval(_version_re.search( - f.read().decode('utf-8')).group(1))) - setup( - name='bench', + name=PROJECT_NAME, description='Metadata driven, full-stack web framework', author='Frappe Technologies', author_email='info@frappe.io', - version=version, + version=VERSION, packages=find_packages(), zip_safe=False, include_package_data=True, diff --git a/vm/scripts/debian_family/install_erpnext_develop.sh b/vm/scripts/debian_family/install_erpnext_develop.sh index 9e9c7ab7..19b1b705 100644 --- a/vm/scripts/debian_family/install_erpnext_develop.sh +++ b/vm/scripts/debian_family/install_erpnext_develop.sh @@ -1,5 +1,5 @@ #!/bin/bash -eux # Install ERPNext -wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py +wget https://raw.githubusercontent.com/frappe/bench/develop/install.py python install.py --develop --user frappe --mysql-root-password frappe --admin-password admin \ No newline at end of file diff --git a/vm/scripts/debian_family/install_erpnext_production.sh b/vm/scripts/debian_family/install_erpnext_production.sh index 91b48d1d..b8493f1e 100644 --- a/vm/scripts/debian_family/install_erpnext_production.sh +++ b/vm/scripts/debian_family/install_erpnext_production.sh @@ -1,5 +1,5 @@ #!/bin/bash -eux # Install ERPNext -wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py +wget https://raw.githubusercontent.com/frappe/bench/develop/install.py python install.py --production --user frappe --mysql-root-password frappe --admin-password admin \ No newline at end of file