2
0
mirror of https://github.com/frappe/bench.git synced 2025-02-02 19:08:24 +00:00

Merge branch 'master' into vrms_enhance-README

This commit is contained in:
gunnar 2019-10-06 08:26:49 +02:00 committed by GitHub
commit 70ce045feb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 152 additions and 120 deletions

View File

@ -1,12 +1,10 @@
language: python language: python
dist: trusty dist: xenial
python: python:
- "2.7" - "2.7"
install: install:
- sudo rm /etc/apt/sources.list.d/mongodb*.list
- sudo rm /etc/apt/sources.list.d/docker.list
- sudo pip install urllib3 pyOpenSSL ndg-httpsclient pyasn1 - sudo pip install urllib3 pyOpenSSL ndg-httpsclient pyasn1
- sudo apt-get purge -y mysql-common mysql-server mysql-client - sudo apt-get purge -y mysql-common mysql-server mysql-client
- sudo apt-get install --only-upgrade -y git - sudo apt-get install --only-upgrade -y git
@ -16,7 +14,7 @@ install:
- cp -r $TRAVIS_BUILD_DIR/* ~/.bench - cp -r $TRAVIS_BUILD_DIR/* ~/.bench
- cp -r $TRAVIS_BUILD_DIR/* /tmp/.bench - cp -r $TRAVIS_BUILD_DIR/* /tmp/.bench
- sudo python $TRAVIS_BUILD_DIR/playbooks/install.py --user travis --run-travis --production - sudo python $TRAVIS_BUILD_DIR/playbooks/install.py --user travis --run-travis --production --verbose
# - sudo bash $TRAVIS_BUILD_DIR/install_scripts/setup_frappe.sh --skip-install-bench --mysql-root-password travis # - sudo bash $TRAVIS_BUILD_DIR/install_scripts/setup_frappe.sh --skip-install-bench --mysql-root-password travis
# - cd ~ && sudo python bench-repo/installer/install.py --only-dependencies # - cd ~ && sudo python bench-repo/installer/install.py --only-dependencies

View File

@ -31,11 +31,11 @@ To install the Frappe/ERPNext server software, you will need an operating system
### Manual Install ### Manual Install
To manually install frappe/erpnext, you can follow this [this wiki](https://github.com/frappe/frappe/wiki/The-Hitchhiker%27s-Guide-to-Installing-Frapp%C3%A9-on-Linux) for Linux and [this wiki](https://github.com/frappe/frappe/wiki/The-Hitchhiker's-Guide-to-Installing-Frapp%C3%A9-on-Mac-OS-X) for MacOS. It gives an excellent explanation about the stack. You can also follow the steps mentioned below: To manually install frappe/erpnext, you can follow this [this wiki](https://github.com/frappe/frappe/wiki/The-Hitchhiker%27s-Guide-to-Installing-Frappe-on-Linux) for Linux and [this wiki](https://github.com/frappe/frappe/wiki/The-Hitchhiker's-Guide-to-Installing-Frappe-on-Mac-OS-X) for MacOS. It gives an excellent explanation about the stack. You can also follow the steps mentioned below:
#### 1. Install Pre-requisites #### 1. Install Pre-requisites
- Python 2.7 [Python3.5+ also supported, but not recommended for production] - Python 2.7 or Python 3.5+
- MariaDB 10+ - MariaDB 10+
- Nginx (for production) - Nginx (for production)
- Nodejs - Nodejs
@ -128,10 +128,6 @@ If you are on a fresh server and logged in as root, at first create a dedicated
*(it is very common to use "frappe" as frappe-username, but this comes with the security flaw of ["frappe" ranking very high](https://www.reddit.com/r/dataisbeautiful/comments/b3sirt/i_deployed_over_a_dozen_cyber_honeypots_all_over/?st=JTJ0SC0Q&sh=76e05240) in as a username challenged in hacking attempts. So, for production sites it is highly recommended to use a custom username harder to guess)* *(it is very common to use "frappe" as frappe-username, but this comes with the security flaw of ["frappe" ranking very high](https://www.reddit.com/r/dataisbeautiful/comments/b3sirt/i_deployed_over_a_dozen_cyber_honeypots_all_over/?st=JTJ0SC0Q&sh=76e05240) in as a username challenged in hacking attempts. So, for production sites it is highly recommended to use a custom username harder to guess)*
use --user flag to create a user and install using that user
python install.py --develop --user [frappe-user]
For developer setup: For developer setup:
sudo python install.py --develop sudo python install.py --develop
@ -140,6 +136,22 @@ For production:
sudo python install.py --production --user [frappe-user] sudo python install.py --production --user [frappe-user]
use --user flag to create a user and install using that user
python install.py --develop --user [frappe-user]
use --container flag to install inside a container (this will prevent the `/proc/sys/vm/swappiness: Read-only` file system error)
sudo python install.py --production --user [frappe-user] --container
use --version flag to install specific version
python install.py --develop --version 11 --user [frappe-user]
use --python flag to specify virtual environments python version, by default script setup python 3
python install.py --develop --version 11 --python python2.7 --user [frappe-user]
#### What will this script do? #### What will this script do?
- Install all the pre-requisites - Install all the pre-requisites

View File

@ -1,3 +1,4 @@
from __future__ import print_function
import os import os
from .utils import (exec_cmd, get_frappe, check_git_for_shallow_clone, build_assets, from .utils import (exec_cmd, get_frappe, check_git_for_shallow_clone, build_assets,
restart_supervisor_processes, get_cmd_output, run_frappe_cmd, CommandFailedError, restart_supervisor_processes, get_cmd_output, run_frappe_cmd, CommandFailedError,
@ -421,3 +422,13 @@ def get_apps_json(path):
else: else:
with open(path) as f: with open(path) as f:
return json.load(f) return json.load(f)
def validate_branch():
for app in ['frappe', 'erpnext']:
branch = get_current_branch(app)
if branch == "master":
print(''' master branch is renamed to version-11 and develop to version-12. Please switch to new branches to get future updates.
To switch to version 11, run the following commands: bench switch-to-branch version-11''')
sys.exit(1)

View File

@ -89,7 +89,7 @@ except ImportError:
@click.command('migrate-env') @click.command('migrate-env')
@click.argument('python', type = str) @click.argument('python', type = str)
@click.option('--no-backup', default = False, help = 'Do not backup the existing Virtual Environment') @click.option('--no-backup', is_flag=True)
def migrate_env(python, no_backup = False): def migrate_env(python, no_backup = False):
""" """
Migrate Virtual Environment to desired Python Version. Migrate Virtual Environment to desired Python Version.

View File

@ -2,7 +2,7 @@ import click
@click.command() @click.command()
@click.argument('path') @click.argument('path')
@click.option('--python', type = str, default = 'python', help = 'Path to Python Executable.') @click.option('--python', type = str, default = 'python3', help = 'Path to Python Executable.')
@click.option('--ignore-exist', is_flag = True, default = False, help = "Ignore if Bench instance exists.") @click.option('--ignore-exist', is_flag = True, default = False, help = "Ignore if Bench instance exists.")
@click.option('--apps_path', default=None, help="path to json files with apps to install after init") @click.option('--apps_path', default=None, help="path to json files with apps to install after init")
@click.option('--frappe-path', default=None, help="path to frappe repo") @click.option('--frappe-path', default=None, help="path to frappe repo")
@ -13,11 +13,12 @@ import click
@click.option('--no-backups',is_flag=True, help="Run migrations for all sites in the bench") @click.option('--no-backups',is_flag=True, help="Run migrations for all sites in the bench")
@click.option('--no-auto-update',is_flag=True, help="Build JS and CSS artifacts for the bench") @click.option('--no-auto-update',is_flag=True, help="Build JS and CSS artifacts for the bench")
@click.option('--skip-redis-config-generation', is_flag=True, help="Skip redis config generation if already specifying the common-site-config file") @click.option('--skip-redis-config-generation', is_flag=True, help="Skip redis config generation if already specifying the common-site-config file")
@click.option('--skip-assets',is_flag=True, default=False, help="Do not build assets")
@click.option('--verbose',is_flag=True, help="Verbose output during install") @click.option('--verbose',is_flag=True, help="Verbose output during install")
def init(path, apps_path, frappe_path, frappe_branch, no_procfile, no_backups, def init(path, apps_path, frappe_path, frappe_branch, no_procfile, no_backups,
no_auto_update, clone_from, verbose, skip_redis_config_generation, clone_without_update, no_auto_update, clone_from, verbose, skip_redis_config_generation, clone_without_update,
ignore_exist = False, ignore_exist = False, skip_assets=False,
python = 'python'): # Let's change we're ready. - <achilles@frappe.io> python = 'python3'):
''' '''
Create a New Bench Instance. Create a New Bench Instance.
''' '''
@ -26,7 +27,7 @@ def init(path, apps_path, frappe_path, frappe_branch, no_procfile, no_backups,
no_auto_update=no_auto_update, frappe_path=frappe_path, frappe_branch=frappe_branch, no_auto_update=no_auto_update, frappe_path=frappe_path, frappe_branch=frappe_branch,
verbose=verbose, clone_from=clone_from, skip_redis_config_generation=skip_redis_config_generation, verbose=verbose, clone_from=clone_from, skip_redis_config_generation=skip_redis_config_generation,
clone_without_update=clone_without_update, clone_without_update=clone_without_update,
ignore_exist = ignore_exist, ignore_exist = ignore_exist, skip_assets=skip_assets,
python = python) python = python)
click.echo('Bench {} initialized'.format(path)) click.echo('Bench {} initialized'.format(path))

View File

@ -81,8 +81,8 @@ def setup_backups():
setup_backups() setup_backups()
@click.command('env') @click.command('env')
@click.option('--python', type = str, default = 'python', help = 'Path to Python Executable.') @click.option('--python', type = str, default = 'python3', help = 'Path to Python Executable.')
def setup_env(python='python'): def setup_env(python='python3'):
"Setup virtualenv for bench" "Setup virtualenv for bench"
from bench.utils import setup_env from bench.utils import setup_env
setup_env(python=python) setup_env(python=python)

View File

@ -1,7 +1,7 @@
import click import click
import sys, os import sys, os
from bench.config.common_site_config import get_config from bench.config.common_site_config import get_config, update_config
from bench.app import pull_all_apps, is_version_upgrade from bench.app import pull_all_apps, is_version_upgrade, validate_branch
from bench.utils import (update_bench, validate_upgrade, pre_upgrade, post_upgrade, before_update, from bench.utils import (update_bench, validate_upgrade, pre_upgrade, post_upgrade, before_update,
update_requirements, update_node_packages, backup_all_sites, patch_sites, build_assets, update_requirements, update_node_packages, backup_all_sites, patch_sites, build_assets,
restart_supervisor_processes, restart_systemd_processes) restart_supervisor_processes, restart_systemd_processes)
@ -48,8 +48,9 @@ def update(pull=False, patch=False, build=False, bench=False, auto=False, restar
print('Release bench, cannot update') print('Release bench, cannot update')
sys.exit(1) sys.exit(1)
version_upgrade = is_version_upgrade() validate_branch()
version_upgrade = is_version_upgrade()
if version_upgrade[0]: if version_upgrade[0]:
print() print()
print() print()
@ -69,6 +70,13 @@ def _update(pull=False, patch=False, build=False, update_bench=False, auto=False
before_update(bench_path=bench_path, requirements=requirements) before_update(bench_path=bench_path, requirements=requirements)
conf.update({ "maintenance_mode": 1, "pause_scheduler": 1 })
update_config(conf, bench_path=bench_path)
if not no_backup:
print('Backing up sites...')
backup_all_sites(bench_path=bench_path)
if pull: if pull:
pull_all_apps(bench_path=bench_path, reset=reset) pull_all_apps(bench_path=bench_path, reset=reset)
@ -89,10 +97,6 @@ def _update(pull=False, patch=False, build=False, update_bench=False, auto=False
reload(bench.app) reload(bench.app)
if patch: if patch:
if not no_backup:
print('Backing up sites...')
backup_all_sites(bench_path=bench_path)
print('Patching sites...') print('Patching sites...')
patch_sites(bench_path=bench_path) patch_sites(bench_path=bench_path)
if build: if build:
@ -104,6 +108,9 @@ def _update(pull=False, patch=False, build=False, update_bench=False, auto=False
if restart_systemd or conf.get('restart_systemd_on_update'): if restart_systemd or conf.get('restart_systemd_on_update'):
restart_systemd_processes(bench_path=bench_path) restart_systemd_processes(bench_path=bench_path)
conf.update({ "maintenance_mode": 0, "pause_scheduler": 0 })
update_config(conf, bench_path=bench_path)
print("_"*80) print("_"*80)
print("Bench: Deployment tool for Frappe and ERPNext (https://erpnext.org).") print("Bench: Deployment tool for Frappe and ERPNext (https://erpnext.org).")
print("Open source depends on your contributions, so please contribute bug reports, patches, fixes or cash and be a part of the community") print("Open source depends on your contributions, so please contribute bug reports, patches, fixes or cash and be a part of the community")

View File

@ -5,10 +5,11 @@ import sys, os, copy
@click.command('start') @click.command('start')
@click.option('--no-dev', is_flag=True, default=False) @click.option('--no-dev', is_flag=True, default=False)
@click.option('--concurrency', '-c', type=str) @click.option('--concurrency', '-c', type=str)
def start(no_dev, concurrency): @click.option('--procfile', '-p', type=str)
def start(no_dev, concurrency, procfile):
"Start Frappe development processes" "Start Frappe development processes"
from bench.utils import start from bench.utils import start
start(no_dev=no_dev, concurrency=concurrency) start(no_dev=no_dev, concurrency=concurrency, procfile=procfile)
@click.command('restart') @click.command('restart')

View File

@ -34,7 +34,7 @@ server {
ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS"; ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";
ssl_prefer_server_ciphers on; ssl_prefer_server_ciphers on;
{% endif %} {% endif %}
add_header X-Frame-Options "SAMEORIGIN"; add_header X-Frame-Options "SAMEORIGIN";
location /assets { location /assets {
@ -58,6 +58,12 @@ server {
} }
location / { location / {
location ~ ^/files/.*.(htm|html|svg|xml) {
add_header Content-disposition "attachment";
try_files /{{ site_name }}/public/$uri @webserver;
}
try_files /{{ site_name }}/public/$uri @webserver; try_files /{{ site_name }}/public/$uri @webserver;
} }

View File

@ -15,13 +15,16 @@ import click
branches_to_update = { branches_to_update = {
'develop': [], 'develop': [],
'hotfix': ['develop'] 'version-11-hotfix': [],
'version-12-hotfix': [],
} }
releasable_branches = ['master']
github_username = None github_username = None
github_password = None github_password = None
def release(bench_path, app, bump_type, from_branch='develop', to_branch='master', def release(bench_path, app, bump_type, from_branch, to_branch,
remote='upstream', owner='frappe', repo_name=None, frontport=True): remote='upstream', owner='frappe', repo_name=None, frontport=True):
confirm_testing() confirm_testing()
@ -30,11 +33,14 @@ def release(bench_path, app, bump_type, from_branch='develop', to_branch='master
if not config.get('release_bench'): if not config.get('release_bench'):
print('bench not configured to release') print('bench not configured to release')
sys.exit(1) sys.exit(1)
if config.get('branches_to_update'): if config.get('branches_to_update'):
branches_to_update.update(config.get('branches_to_update')) branches_to_update.update(config.get('branches_to_update'))
if config.get('releasable_branches'):
releasable_branches.extend(config.get('releasable_branches',[]))
validate(bench_path, config) validate(bench_path, config)
bump(bench_path, app, bump_type, from_branch=from_branch, to_branch=to_branch, owner=owner, bump(bench_path, app, bump_type, from_branch=from_branch, to_branch=to_branch, owner=owner,
@ -91,7 +97,7 @@ def bump(bench_path, app, bump_type, from_branch, to_branch, remote, owner, repo
create_github_release(repo_path, tag_name, message, remote=remote, owner=owner, repo_name=repo_name, prerelease=prerelease) create_github_release(repo_path, tag_name, message, remote=remote, owner=owner, repo_name=repo_name, prerelease=prerelease)
print('Released {tag} for {repo_path}'.format(tag=tag_name, repo_path=repo_path)) print('Released {tag} for {repo_path}'.format(tag=tag_name, repo_path=repo_path))
def update_branches_and_check_for_changelog(repo_path, from_branch='develop', to_branch='master', remote='upstream'): def update_branches_and_check_for_changelog(repo_path, from_branch, to_branch, remote='upstream'):
update_branch(repo_path, to_branch, remote=remote) update_branch(repo_path, to_branch, remote=remote)
update_branch(repo_path, from_branch, remote=remote) update_branch(repo_path, from_branch, remote=remote)
@ -116,7 +122,7 @@ def check_for_unmerged_changelog(repo_path):
if os.path.exists(current) and [f for f in os.listdir(current) if f != "readme.md"]: if os.path.exists(current) and [f for f in os.listdir(current) if f != "readme.md"]:
raise Exception("Unmerged change log! in " + repo_path) raise Exception("Unmerged change log! in " + repo_path)
def get_release_message(repo_path, from_branch='develop', to_branch='master', remote='upstream'): def get_release_message(repo_path, from_branch, to_branch, remote='upstream'):
print('getting release message for', repo_path, 'comparing', to_branch, '...', from_branch) print('getting release message for', repo_path, 'comparing', to_branch, '...', from_branch)
repo = git.Repo(repo_path) repo = git.Repo(repo_path)
@ -127,7 +133,7 @@ def get_release_message(repo_path, from_branch='develop', to_branch='master', re
if log: if log:
return "* " + log.replace('\n', '\n* ') return "* " + log.replace('\n', '\n* ')
def bump_repo(repo_path, bump_type, from_branch='develop', to_branch='master'): def bump_repo(repo_path, bump_type, from_branch, to_branch):
current_version = get_current_version(repo_path, to_branch) current_version = get_current_version(repo_path, to_branch)
new_version = get_bumped_version(current_version, bump_type) new_version = get_bumped_version(current_version, bump_type)
@ -140,7 +146,7 @@ def get_current_version(repo_path, to_branch):
# TODO clean this up! # TODO clean this up!
version_key = '__version__' version_key = '__version__'
if to_branch.lower() == 'master': if to_branch.lower() in releasable_branches:
filename = os.path.join(repo_path, os.path.basename(repo_path), '__init__.py') filename = os.path.join(repo_path, os.path.basename(repo_path), '__init__.py')
else: else:
filename = os.path.join(repo_path, os.path.basename(repo_path), 'hooks.py') filename = os.path.join(repo_path, os.path.basename(repo_path), 'hooks.py')
@ -194,7 +200,7 @@ def get_bumped_version(version, bump_type):
return str(v) return str(v)
def set_version(repo_path, version, to_branch): def set_version(repo_path, version, to_branch):
if to_branch.lower() == 'master': if to_branch.lower() in releasable_branches:
set_filename_version(os.path.join(repo_path, os.path.basename(repo_path),'__init__.py'), version, '__version__') set_filename_version(os.path.join(repo_path, os.path.basename(repo_path),'__init__.py'), version, '__version__')
else: else:
set_filename_version(os.path.join(repo_path, os.path.basename(repo_path),'hooks.py'), version, 'staging_version') set_filename_version(os.path.join(repo_path, os.path.basename(repo_path),'hooks.py'), version, 'staging_version')
@ -237,14 +243,14 @@ def commit_changes(repo_path, new_version, to_branch):
repo = git.Repo(repo_path) repo = git.Repo(repo_path)
app_name = os.path.basename(repo_path) app_name = os.path.basename(repo_path)
if to_branch.lower() == 'master': if to_branch.lower() in releasable_branches:
repo.index.add([os.path.join(app_name, '__init__.py')]) repo.index.add([os.path.join(app_name, '__init__.py')])
else: else:
repo.index.add([os.path.join(app_name, 'hooks.py')]) repo.index.add([os.path.join(app_name, 'hooks.py')])
repo.index.commit('bumped to version {}'.format(new_version)) repo.index.commit('bumped to version {}'.format(new_version))
def create_release(repo_path, new_version, from_branch='develop', to_branch='master', frontport=True): def create_release(repo_path, new_version, from_branch, to_branch, frontport=True):
print('creating release for version', new_version) print('creating release for version', new_version)
repo = git.Repo(repo_path) repo = git.Repo(repo_path)
g = repo.git g = repo.git
@ -283,7 +289,7 @@ def handle_merge_error(e, source, target):
print('-'*80) print('-'*80)
click.confirm('Have you manually resolved the error?', abort=True) click.confirm('Have you manually resolved the error?', abort=True)
def push_release(repo_path, from_branch='develop', to_branch='master', remote='upstream'): def push_release(repo_path, from_branch, to_branch, remote='upstream'):
print('pushing branches', to_branch, from_branch, 'of', repo_path) print('pushing branches', to_branch, from_branch, 'of', repo_path)
repo = git.Repo(repo_path) repo = git.Repo(repo_path)
g = repo.git g = repo.git

View File

@ -37,8 +37,8 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False,
no_auto_update=False, frappe_path=None, frappe_branch=None, wheel_cache_dir=None, no_auto_update=False, frappe_path=None, frappe_branch=None, wheel_cache_dir=None,
verbose=False, clone_from=None, skip_redis_config_generation=False, verbose=False, clone_from=None, skip_redis_config_generation=False,
clone_without_update=False, clone_without_update=False,
ignore_exist = False, ignore_exist = False, skip_assets=False,
python = 'python'): # Let's change when we're ready. - <achilles@frappe.io> python = 'python3'): # Let's change when we're ready. - <achilles@frappe.io>
from .app import get_app, install_apps_from_path from .app import get_app, install_apps_from_path
from .config.common_site_config import make_config from .config.common_site_config import make_config
from .config import redis from .config import redis
@ -80,10 +80,12 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False,
bench.set_frappe_version(bench_path=path) bench.set_frappe_version(bench_path=path)
if bench.FRAPPE_VERSION > 5: if bench.FRAPPE_VERSION > 5:
update_node_packages(bench_path=path) if not skip_assets:
update_node_packages(bench_path=path)
set_all_patches_executed(bench_path=path) set_all_patches_executed(bench_path=path)
build_assets(bench_path=path) if not skip_assets:
build_assets(bench_path=path)
if not skip_redis_config_generation: if not skip_redis_config_generation:
redis.generate_config(path) redis.generate_config(path)
@ -169,7 +171,7 @@ def which(executable, raise_err = False):
return exec_ return exec_
def setup_env(bench_path='.', python = 'python'): def setup_env(bench_path='.', python = 'python3'):
python = which(python, raise_err = True) python = which(python, raise_err = True)
pip = os.path.join('env', 'bin', 'pip') pip = os.path.join('env', 'bin', 'pip')
@ -315,7 +317,7 @@ def get_program(programs):
def get_process_manager(): def get_process_manager():
return get_program(['foreman', 'forego', 'honcho']) return get_program(['foreman', 'forego', 'honcho'])
def start(no_dev=False, concurrency=None): def start(no_dev=False, concurrency=None, procfile=None):
program = get_process_manager() program = get_process_manager()
if not program: if not program:
raise Exception("No process manager found") raise Exception("No process manager found")
@ -327,6 +329,9 @@ def start(no_dev=False, concurrency=None):
if concurrency: if concurrency:
command.extend(['-c', concurrency]) command.extend(['-c', concurrency])
if procfile:
command.extend(['-f', procfile])
os.execv(program, command) os.execv(program, command)
def check_cmd(cmd, cwd='.'): def check_cmd(cmd, cwd='.'):
@ -812,7 +817,7 @@ def run_playbook(playbook_name, extra_vars=None, tag=None):
if not find_executable('ansible'): if not find_executable('ansible'):
print("Ansible is needed to run this command, please install it using 'pip install ansible'") print("Ansible is needed to run this command, please install it using 'pip install ansible'")
sys.exit(1) sys.exit(1)
args = ['ansible-playbook', '-c', 'local', playbook_name] args = ['ansible-playbook', '-c', 'local', playbook_name, '-vvvv']
if extra_vars: if extra_vars:
args.extend(['-e', json.dumps(extra_vars)]) args.extend(['-e', json.dumps(extra_vars)])

View File

@ -1,6 +1,8 @@
--- ---
- hosts: localhost - hosts: localhost
become: yes
become_user: root
tasks: tasks:
- name: Create user - name: Create user
user: user:

View File

@ -1,4 +1,4 @@
# wget setup_frappe.py | python # wget setup_frappe.py | python3
import os, sys, subprocess, getpass, json, multiprocessing, shutil, platform import os, sys, subprocess, getpass, json, multiprocessing, shutil, platform
from distutils.spawn import find_executable from distutils.spawn import find_executable
@ -14,7 +14,7 @@ def install_bench(args):
success = run_os_command({ success = run_os_command({
'apt-get': [ 'apt-get': [
'sudo apt-get update', 'sudo apt-get update',
'sudo apt-get install -y git build-essential python-setuptools python-dev libffi-dev libssl-dev' 'sudo apt-get install -y git build-essential python3-setuptools python3-dev libffi-dev libssl1.0-dev'
], ],
'yum': [ 'yum': [
'sudo yum groupinstall -y "Development tools"', 'sudo yum groupinstall -y "Development tools"',
@ -46,7 +46,7 @@ def install_bench(args):
}) })
success = run_os_command({ success = run_os_command({
'python': 'sudo python get-pip.py --force-reinstall' 'python3': 'sudo python3 get-pip.py --force-reinstall'
}) })
if success: if success:
@ -85,12 +85,11 @@ def install_bench(args):
raise Exception('Please run this script as a non-root user with sudo privileges, but without using sudo or pass --user=USER') raise Exception('Please run this script as a non-root user with sudo privileges, but without using sudo or pass --user=USER')
# Python executable # Python executable
if not args.production: dist_name, dist_version = get_distribution_info()
dist_name, dist_version = get_distribution_info() if dist_name=='centos':
if dist_name=='centos': args.python = 'python3.6'
args.python = 'python3.6' else:
else: args.python = 'python3'
args.python = 'python3'
# create user if not exists # create user if not exists
extra_vars = vars(args) extra_vars = vars(args)
@ -109,16 +108,24 @@ 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)
if args.frappe_branch: frappe_branch = 'version-12'
frappe_branch = args.frappe_branch erpnext_branch = 'version-12'
else:
frappe_branch = 'master' if args.production else 'develop'
extra_vars.update(frappe_branch=frappe_branch)
if args.erpnext_branch: if args.version:
erpnext_branch = args.erpnext_branch if args.version <= 10:
frappe_branch = "{0}.x.x".format(args.version)
erpnext_branch = "{0}.x.x".format(args.version)
else:
frappe_branch = "version-{0}".format(args.version)
erpnext_branch = "version-{0}".format(args.version)
else: else:
erpnext_branch = 'master' if args.production else 'develop' if args.frappe_branch:
frappe_branch = args.frappe_branch
if args.erpnext_branch:
erpnext_branch = args.erpnext_branch
extra_vars.update(frappe_branch=frappe_branch)
extra_vars.update(erpnext_branch=erpnext_branch) 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
@ -135,7 +142,7 @@ def install_bench(args):
shutil.rmtree(tmp_bench_repo) shutil.rmtree(tmp_bench_repo)
def check_distribution_compatibility(): def check_distribution_compatibility():
supported_dists = {'ubuntu': [14, 15, 16, 18], 'debian': [8, 9], supported_dists = {'ubuntu': [14, 15, 16, 18, 19], 'debian': [8, 9],
'centos': [7], 'macos': [10.9, 10.10, 10.11, 10.12]} 'centos': [7], 'macos': [10.9, 10.10, 10.11, 10.12]}
dist_name, dist_version = get_distribution_info() dist_name, dist_version = get_distribution_info()
@ -157,27 +164,6 @@ def get_distribution_info():
current_dist = platform.mac_ver() current_dist = platform.mac_ver()
return "macos", current_dist[0].rsplit('.', 1)[0] return "macos", current_dist[0].rsplit('.', 1)[0]
def install_python27():
version = (sys.version_info[0], sys.version_info[1])
if version == (2, 7):
return
print('Installing Python 2.7')
# install python 2.7
success = run_os_command({
'apt-get': 'sudo apt-get install -y python-dev',
'yum': 'sudo yum install -y python27',
'brew': 'brew install python'
})
if not success:
could_not_install('Python 2.7')
# replace current python with python2.7
os.execvp('python2.7', ([] if is_sudo_user() else ['sudo']) + ['python2.7', __file__] + sys.argv[1:])
def install_package(package): def install_package(package):
package_exec = find_executable(package) package_exec = find_executable(package)
@ -324,14 +310,11 @@ def get_extra_vars_json(extra_args):
return ('@' + json_path) return ('@' + json_path)
def run_playbook(playbook_name, sudo=False, extra_vars=None): def run_playbook(playbook_name, sudo=False, extra_vars=None):
args = ['ansible-playbook', '-c', 'local', playbook_name] args = ['ansible-playbook', '-c', 'local', playbook_name , '-vvvv']
if extra_vars: if extra_vars:
args.extend(['-e', get_extra_vars_json(extra_vars)]) args.extend(['-e', get_extra_vars_json(extra_vars)])
if extra_vars.get('verbosity'):
args.append('-vvvv')
if sudo: if sudo:
user = extra_vars.get('user') or getpass.getuser() user = extra_vars.get('user') or getpass.getuser()
args.extend(['--become', '--become-user={0}'.format(user)]) args.extend(['--become', '--become-user={0}'.format(user)])
@ -389,6 +372,10 @@ def parse_commandline_args():
parser.add_argument('--without-erpnext', dest='without_erpnext', action='store_true', default=False, parser.add_argument('--without-erpnext', dest='without_erpnext', action='store_true', default=False,
help='Prevent fetching ERPNext') help='Prevent fetching ERPNext')
# direct provision to install versions
parser.add_argument('--version', dest='version', action='store', default='12', type=int,
help='Clone particular version of frappe and 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)
@ -407,7 +394,7 @@ def parse_commandline_args():
parser.add_argument('--bench-name', dest='bench_name', help='Create bench with specified name. Default name is frappe-bench') parser.add_argument('--bench-name', dest='bench_name', help='Create bench with specified name. Default name is frappe-bench')
# Python interpreter to be used # Python interpreter to be used
parser.add_argument('--python', dest='python', default='python', parser.add_argument('--python', dest='python', default='python3',
help=argparse.SUPPRESS help=argparse.SUPPRESS
) )
@ -421,12 +408,6 @@ def parse_commandline_args():
return args return args
if __name__ == '__main__': if __name__ == '__main__':
try:
import argparse
except ImportError:
# install python2.7
install_python27()
args = parse_commandline_args() args = parse_commandline_args()
install_bench(args) install_bench(args)

View File

@ -34,8 +34,8 @@
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: python3 bench init for production
command: bench init {{ bench_path }} --frappe-path {{ frappe_repo_url }} --frappe-branch {{ frappe_branch }} 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 production when: not bench_stat.stat.exists and production

View File

@ -12,7 +12,7 @@
- libcrypto++-dev - libcrypto++-dev
- libfreetype6-dev - libfreetype6-dev
- liblcms2-dev - liblcms2-dev
- libssl-dev - libssl1.0-dev
- libwebp-dev - libwebp-dev
- libxext6 - libxext6
- libxrender1 - libxrender1
@ -21,10 +21,9 @@
- libffi-dev - libffi-dev
- ntp # Clock synchronization - ntp # Clock synchronization
- postfix # Mail Server - postfix # Mail Server
- python-dev # Installing python developer suite - python3-dev # Installing python developer suite
- python3-dev # For python3 compatibility
- python-tk - python-tk
- screen # To aid ssh sessions with connectivity problems - screen # To aid ssh sessions with connectivity problems
- vim # Is that supposed to be a question!? - vim # Is that supposed to be a question!?
- xfonts-75dpi - xfonts-75dpi
- xfonts-base - xfonts-base
@ -34,7 +33,7 @@
- libldap2-dev - libldap2-dev
- libcups2-dev - libcups2-dev
- pv # Show progress during database restore - pv # Show progress during database restore
- include_tasks: debian.yml - include_tasks: debian.yml
when: ansible_distribution == 'Debian' when: ansible_distribution == 'Debian'

View File

@ -1,5 +1,5 @@
--- ---
# Install's prerequisites, like fonts, image libraries, vim, screen, python-dev # Install's prerequisites, like fonts, image libraries, vim, screen, python3-dev
- include_tasks: debian_family.yml - include_tasks: debian_family.yml
when: ansible_os_family == 'Debian' when: ansible_os_family == 'Debian'

View File

@ -27,6 +27,5 @@
- mariadb-client - mariadb-client
- mariadb-common - mariadb-common
- libmariadbclient18 - libmariadbclient18
- python-mysqldb
- python3-mysqldb - python3-mysqldb
... ...

View File

@ -12,7 +12,7 @@
# FLUSH PRIVILEGES; # FLUSH PRIVILEGES;
- name: Set root Password - name: Set root Password
mysql_user: login_password={{ mysql_root_password }} check_implicit_admin=yes name=root host={{ item }} password={{ mysql_root_password }} state=present mysql_user: login_password={{ mysql_root_password }} check_implicit_admin=yes name=root host={{ item }} password={{ mysql_root_password }} state=present
with_items: with_items:
- localhost - localhost
- 127.0.0.1 - 127.0.0.1

View File

@ -23,5 +23,5 @@
- libmariadbclient18 - libmariadbclient18
- name: Install MySQLdb Python package for secure installations. - name: Install MySQLdb Python package for secure installations.
apt: pkg=python-mysqldb state=present apt: pkg=python3-mysqldb state=present
when: mysql_secure_installation and mysql_root_password is defined when: mysql_secure_installation and mysql_root_password is defined

View File

@ -23,5 +23,5 @@
- libmariadbclient18 - libmariadbclient18
- name: Install MySQLdb Python package for secure installations. - name: Install MySQLdb Python package for secure installations.
apt: pkg=python-mysqldb state=present apt: pkg=python3-mysqldb state=present
when: mysql_secure_installation and mysql_root_password is defined when: mysql_secure_installation and mysql_root_password is defined

View File

@ -33,7 +33,7 @@ def install_virtualbox():
check_output(['bench', 'install', 'virtualbox']) check_output(['bench', 'install', 'virtualbox'])
def install_packer(): def install_packer():
if not spawn.find_executable("packer") or not os.path.exists(os.path.join('/', 'opt', 'packer')): if not spawn.find_executable("packer") and not os.path.exists(os.path.join('/', 'opt', 'packer')):
check_output(['bench', 'install', 'packer']) check_output(['bench', 'install', 'packer'])
def silent_remove(name, is_dir=False): def silent_remove(name, is_dir=False):

View File

@ -1,8 +1,5 @@
#!/bin/bash -eux #!/bin/bash -eux
# Install base requirements.
apt-get install -y curl git wget vim python-dev gcc
# Install ERPNext # Install ERPNext
wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py
sudo python install.py --develop --user frappe --mysql-root-password frappe --admin-password admin python install.py --develop --user frappe --mysql-root-password frappe --admin-password admin

View File

@ -1,8 +1,5 @@
#!/bin/bash -eux #!/bin/bash -eux
# Install base requirements.
apt-get install -y curl git wget vim python-dev gcc
# Install ERPNext # Install ERPNext
wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py
sudo python install.py --production --user frappe --mysql-root-password frappe --admin-password admin python install.py --production --user frappe --mysql-root-password frappe --admin-password admin

View File

@ -0,0 +1,4 @@
#!/bin/bash -eux
# Install base requirements.
apt-get install -y curl git wget vim python-dev gcc

View File

@ -38,7 +38,7 @@
"iso_checksum_type": "md5", "iso_checksum_type": "md5",
"ssh_username": "frappe", "ssh_username": "frappe",
"ssh_password": "frappe", "ssh_password": "frappe",
"ssh_port": 22, "ssh_port": 22,
"ssh_wait_timeout": "10000s", "ssh_wait_timeout": "10000s",
"http_directory": "http", "http_directory": "http",
"guest_additions_mode": "disable", "guest_additions_mode": "disable",
@ -70,9 +70,12 @@
"type": "shell", "type": "shell",
"execute_command": "echo 'frappe' | {{.Vars}} sudo -S -E bash '{{.Path}}'", "execute_command": "echo 'frappe' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
"script": "scripts/debian_family/setup.sh" "script": "scripts/debian_family/setup.sh"
}, { },{
"type": "shell", "type": "shell",
"execute_command": "echo 'frappe' | {{.Vars}} sudo -S -E bash '{{.Path}}'", "execute_command": "echo 'frappe' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
"script": "scripts/debian_family/install_prerequisites.sh"
}, {
"type": "shell",
"script": "scripts/debian_family/install_erpnext_develop.sh" "script": "scripts/debian_family/install_erpnext_develop.sh"
}, { }, {
"type": "shell", "type": "shell",

View File

@ -38,7 +38,7 @@
"iso_checksum_type": "md5", "iso_checksum_type": "md5",
"ssh_username": "frappe", "ssh_username": "frappe",
"ssh_password": "frappe", "ssh_password": "frappe",
"ssh_port": 22, "ssh_port": 22,
"ssh_wait_timeout": "10000s", "ssh_wait_timeout": "10000s",
"http_directory": "http", "http_directory": "http",
"guest_additions_mode": "disable", "guest_additions_mode": "disable",
@ -69,9 +69,12 @@
"type": "shell", "type": "shell",
"execute_command": "echo 'frappe' | {{.Vars}} sudo -S -E bash '{{.Path}}'", "execute_command": "echo 'frappe' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
"script": "scripts/debian_family/setup.sh" "script": "scripts/debian_family/setup.sh"
}, { },{
"type": "shell", "type": "shell",
"execute_command": "echo 'frappe' | {{.Vars}} sudo -S -E bash '{{.Path}}'", "execute_command": "echo 'frappe' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
"script": "scripts/debian_family/install_prerequisites.sh"
}, {
"type": "shell",
"script": "scripts/debian_family/install_erpnext_production.sh" "script": "scripts/debian_family/install_erpnext_production.sh"
}, { }, {
"type": "shell", "type": "shell",