From 615240247a4497c88f8d7731f17be9e7f4b12baf Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Wed, 30 May 2018 16:38:27 +0000 Subject: [PATCH 01/33] PR and Issue Templates updated --- .github/ISSUE_TEMPLATE/bug_report.md | 68 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 21 +++++++ .github/PULL_REQUEST_TEMPLATE.md | 28 ++++++++++ 3 files changed, 117 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..aa3a104e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,68 @@ +--- +name: Bug report +about: Create a report to help us improve + +--- + +Issue: Bug report + +Our project, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly. + +**Do the checklist before filing an issue:** + - [ ] Have a usage question? Ask your question on [Discuss Forum](https://discuss.erpnext.com). We use [Discuss Forum](https://discuss.erpnext.com) for usage question and GitHub for bugs. + - [ ] Can you replicate the issue? + - [ ] Is this something you can debug and fix? Send a pull request! Bug fixes and documentation fixes are welcome + +**Describe the bug** :chart_with_downwards_trend: +A clear and concise description of what the bug is. + +**To Reproduce** :page_with_curl: +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** :chart_with_upwards_trend: +A clear and concise description of what you expected to happen. + +**Screenshots** :crystal_ball: +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** :cyclone: + - OS: + - [ ] Linux + - [ ] macOS + - [ ] Windows + - [ ] Others? Please mention: + - Browser: + - [ ] Safari + - [ ] Chrome + - [ ] Firefox + - [ ] Other? Please mention: + +**Smartphone (please complete the following information):** :iphone: :computer: + - Device: + - [ ] iPhone + - [ ] Android + - Browser: + - [ ] Safari + - [ ] Chrome + - [ ] Firefox + - [ ] Other? Please mention: + +**Version Information** +- Which branch are you on? + - [ ] `master` :star2: + - [ ] `develop` :fire: +- Frappe Version: +- ERPNext Version: + +**Additional context** :page_facing_up: +Add any other context about the problem here. + +**Possible Solution** :bookmark_tabs: +Any idea what might be causing the issue. Or if you have a proposed solution to the problem, + +**Please don't be intimidated by the long list of options you've fill. Try to fill out as much as you can. Remember, the more the information the easier it is for us to replicate and fix the issue** :grin: + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..e09e5e95 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,21 @@ +--- +name: Feature request +about: Suggest an idea for this project + +--- + +Issue: Feature Request + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..8e2bd857 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,28 @@ +Pull-Request + +- [ ] Have you followed the guidelines in our Contributing document? +- [ ] Have you checked to ensure there aren't other open [Pull Requests](../pulls) for the same update/change? +- [ ] Have you lint your code locally prior to submission? +- [ ] Have you successfully run tests with your changes locally? +- [ ] Does your commit message have an explanation for your changes and why you'd like us to include them? +- [ ] Docs have been added / updated +- [ ] Tests for the changes have been added (for bug fixes / features) +- [ ] Did you modify the existing test cases? If yes, why? + +--- + +What type of a PR is this? + +- [ ] Changes to Existing Features +- [ ] New Feature Submissions +- [ ] Bug Fix +- [ ] Breaking Change + +--- + +- Motivation and Context (What existing problem does the pull request solve): +- Related Issue: +- Screenshots (if applicable, remember, a picture tells a thousand words): + +**Please don't be intimidated by the long list of options you've fill. Try to fill out as much as you can. Remember, the more the information the easier it is for us to test and get your pull request merged** :grin: + From 2913f6d64882bb9b11297eb6e6e9b8cf0a0b1ba3 Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Sat, 9 Jun 2018 08:48:20 +0000 Subject: [PATCH 02/33] mariadb fixes --- playbooks/roles/mariadb/README.md | 13 +++--- playbooks/roles/mariadb/defaults/main.yml | 1 - playbooks/roles/mariadb/handlers/main.yml | 1 - playbooks/roles/mariadb/tasks/centos.yml | 7 +++- playbooks/roles/mariadb/tasks/main.yml | 10 +++-- .../tasks/mysql_secure_installation.yml | 42 ++++--------------- .../tasks/{ubuntu.yml => ubuntu-trusty.yml} | 14 +++---- .../roles/mariadb/tasks/ubuntu-xenial.yml | 27 ++++++++++++ .../mariadb/templates/mariadb_centos.repo.j2 | 2 +- .../mariadb/templates/mariadb_ubuntu.list.j2 | 2 +- playbooks/roles/mariadb/vars/main.yml | 3 +- 11 files changed, 60 insertions(+), 62 deletions(-) rename playbooks/roles/mariadb/tasks/{ubuntu.yml => ubuntu-trusty.yml} (63%) create mode 100644 playbooks/roles/mariadb/tasks/ubuntu-xenial.yml diff --git a/playbooks/roles/mariadb/README.md b/playbooks/roles/mariadb/README.md index bc872db5..72e42382 100644 --- a/playbooks/roles/mariadb/README.md +++ b/playbooks/roles/mariadb/README.md @@ -7,6 +7,8 @@ Installs MariaDB ``` CentOS 6 & 7 Ubuntu 14.04 +Ubuntu 16.04 +Debain 9 ``` ## Post install @@ -22,7 +24,7 @@ None MariaDB version: ``` -mariadb_version: 10.0 +mariadb_version: 10.2 ``` Configuration template: @@ -52,13 +54,10 @@ None ``` - hosts: servers roles: - - { role: pcextreme.mariadb } + - { role: mariadb } ``` -## License +## Credits -MIT / BSD +- [Attila van der Velde](https://github.com/vdvm) -## Author Information - -Created by [Attila van der Velde](https://github.com/vdvm) diff --git a/playbooks/roles/mariadb/defaults/main.yml b/playbooks/roles/mariadb/defaults/main.yml index fce5bc00..78831c10 100644 --- a/playbooks/roles/mariadb/defaults/main.yml +++ b/playbooks/roles/mariadb/defaults/main.yml @@ -5,4 +5,3 @@ mysql_conf_tpl: change_me mysql_conf_file: settings.cnf mysql_secure_installation: false -... \ No newline at end of file diff --git a/playbooks/roles/mariadb/handlers/main.yml b/playbooks/roles/mariadb/handlers/main.yml index 7072dbd9..3755d8ce 100644 --- a/playbooks/roles/mariadb/handlers/main.yml +++ b/playbooks/roles/mariadb/handlers/main.yml @@ -1,4 +1,3 @@ --- - name: restart mysql service: name=mysql state=restarted -... \ No newline at end of file diff --git a/playbooks/roles/mariadb/tasks/centos.yml b/playbooks/roles/mariadb/tasks/centos.yml index 2b5ced27..c069aacd 100644 --- a/playbooks/roles/mariadb/tasks/centos.yml +++ b/playbooks/roles/mariadb/tasks/centos.yml @@ -6,5 +6,8 @@ yum: name={{ item }} enablerepo=mariadb state=present with_items: - MariaDB-server - - MySQL-python # required for secure_install -... + - MariaDB-client + +- name: Install MySQLdb Python package for secure installations. + yum: name=MySQL-python state=present + when: mysql_secure_installation and mysql_root_password is defined diff --git a/playbooks/roles/mariadb/tasks/main.yml b/playbooks/roles/mariadb/tasks/main.yml index 8d3e6ea0..6802e7ad 100644 --- a/playbooks/roles/mariadb/tasks/main.yml +++ b/playbooks/roles/mariadb/tasks/main.yml @@ -1,10 +1,12 @@ --- +- include: centos.yml + when: ansible_distribution == 'CentOS' and ansible_distribution_major_version|int >= 6 -- include_tasks: centos.yml - when: ansible_distribution == 'CentOS' +- include: ubuntu-trusty.yml + when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '14.04' -- include_tasks: ubuntu.yml - when: ansible_distribution == 'Ubuntu' +- include: ubuntu-xenial.yml + when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '16.04' - name: Add configuration template: src={{ mysql_conf_tpl }} dest={{ mysql_conf_dir[ansible_distribution] }}/{{ mysql_conf_file }} owner=root group=root mode=0644 diff --git a/playbooks/roles/mariadb/tasks/mysql_secure_installation.yml b/playbooks/roles/mariadb/tasks/mysql_secure_installation.yml index 621ab4b0..27d1ca80 100644 --- a/playbooks/roles/mariadb/tasks/mysql_secure_installation.yml +++ b/playbooks/roles/mariadb/tasks/mysql_secure_installation.yml @@ -1,33 +1,22 @@ --- -# Set root password -# UPDATE mysql.user SET Password=PASSWORD('mysecret') WHERE User='root'; -# FLUSH PRIVILEGES; - debug: msg: "{{ mysql_root_password }}" -- name: Set root Password - mysql_user: name=root host={{ item }} password={{ mysql_root_password }} state=present - with_items: - - localhost - ignore_errors: yes - +# create root .my.cnf config file - name: Add .my.cnf template: src=my.cnf.j2 dest=/root/.my.cnf owner=root group=root mode=0600 -- name: display .my.cnf - command: cat /root/.my.cnf - register: details - -- debug: - msg: "{{ details.stdout_lines }}" +# Set root password +# UPDATE mysql.user SET Password=PASSWORD('mysecret') WHERE User='root'; +# FLUSH PRIVILEGES; - name: Set root Password - mysql_user: 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: + - localhost - 127.0.0.1 - ::1 - when: run_travis is not defined - name: Reload privilege tables command: 'mysql -ne "{{ item }}"' @@ -53,7 +42,7 @@ - name: Remove test database and access to it command: 'mysql -ne "{{ item }}"' with_items: - - DROP DATABASE if exists test + - DROP DATABASE IF EXISTS test - DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%' changed_when: False when: run_travis is not defined @@ -64,20 +53,3 @@ - FLUSH PRIVILEGES changed_when: False when: run_travis is not defined - -- name: add launchagents folder mac - file: path=~/Library/LaunchAgents state=directory - when: ansible_distribution == 'MacOSX' - -- name: add mysql to mac startup - file: src=/usr/local/opt/mariadb/homebrew.mxcl.mariadb.plist path=~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist state=link force=yes - when: ansible_distribution == 'MacOSX' - -- name: stop mysql mac - command: launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist - when: ansible_distribution == 'MacOSX' - -- name: start mysql mac - command: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist - when: ansible_distribution == 'MacOSX' -... diff --git a/playbooks/roles/mariadb/tasks/ubuntu.yml b/playbooks/roles/mariadb/tasks/ubuntu-trusty.yml similarity index 63% rename from playbooks/roles/mariadb/tasks/ubuntu.yml rename to playbooks/roles/mariadb/tasks/ubuntu-trusty.yml index 5abec54b..56cd0b66 100644 --- a/playbooks/roles/mariadb/tasks/ubuntu.yml +++ b/playbooks/roles/mariadb/tasks/ubuntu-trusty.yml @@ -6,12 +6,6 @@ - name: Add repo key apt_key: id=1BB943DB url=http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xCBCB082A1BB943DB state=present register: mariadb_key - when: ansible_distribution_version | version_compare('16.04', 'lt') - -- name: Add apt key for mariadb for Ubuntu >= 16.04 - apt_key: id=C74CD1D8 url=http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xF1656F24C74CD1D8 state=present - register: mariadb_key - when: ansible_distribution_version | version_compare('16.04', 'ge') - name: Update apt cache apt: update_cache=yes @@ -25,5 +19,9 @@ apt: pkg={{ item }} state=present with_items: - mariadb-server - - python-mysqldb # required to set the MySQL password using ansible -... + - mariadb-client + - libmariadbclient18 + +- name: Install MySQLdb Python package for secure installations. + apt: pkg=python-mysqldb state=present + when: mysql_secure_installation and mysql_root_password is defined diff --git a/playbooks/roles/mariadb/tasks/ubuntu-xenial.yml b/playbooks/roles/mariadb/tasks/ubuntu-xenial.yml new file mode 100644 index 00000000..8e834ee8 --- /dev/null +++ b/playbooks/roles/mariadb/tasks/ubuntu-xenial.yml @@ -0,0 +1,27 @@ +--- +- name: Add repo file + template: src=mariadb_ubuntu.list.j2 dest=/etc/apt/sources.list.d/mariadb.list owner=root group=root mode=0644 + register: mariadb_list + +- name: Add repo key + apt_key: id=C74CD1D8 url=http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xF1656F24C74CD1D8 state=present + register: mariadb_key + +- name: Update apt cache + apt: update_cache=yes + when: mariadb_list.changed == True or mariadb_key.changed == True + +- name: Unattended package installation + shell: export DEBIAN_FRONTEND=noninteractive + changed_when: false + +- name: Install MariaDB + apt: pkg={{ item }} state=present + with_items: + - mariadb-server + - mariadb-client + - libmariadbclient18 + +- name: Install MySQLdb Python package for secure installations. + apt: pkg=python-mysqldb state=present + when: mysql_secure_installation and mysql_root_password is defined diff --git a/playbooks/roles/mariadb/templates/mariadb_centos.repo.j2 b/playbooks/roles/mariadb/templates/mariadb_centos.repo.j2 index 0a025305..64738cc1 100644 --- a/playbooks/roles/mariadb/templates/mariadb_centos.repo.j2 +++ b/playbooks/roles/mariadb/templates/mariadb_centos.repo.j2 @@ -1,4 +1,4 @@ -# MariaDB {{ mariadb_version }} CentOS {{ ansible_distribution_major_version|int }} repository list +# MariaDB CentOS {{ ansible_distribution_major_version|int }} repository list # http://mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB diff --git a/playbooks/roles/mariadb/templates/mariadb_ubuntu.list.j2 b/playbooks/roles/mariadb/templates/mariadb_ubuntu.list.j2 index dca4e70b..981b4d6b 100644 --- a/playbooks/roles/mariadb/templates/mariadb_ubuntu.list.j2 +++ b/playbooks/roles/mariadb/templates/mariadb_ubuntu.list.j2 @@ -1,4 +1,4 @@ -# MariaDB {{ mariadb_version }} Ubuntu {{ ansible_distribution_release | title }} repository list +# MariaDB Ubuntu {{ ansible_distribution_release | title }} repository list # http://mariadb.org/mariadb/repositories/ deb http://ams2.mirrors.digitalocean.com/mariadb/repo/{{ mariadb_version }}/ubuntu {{ ansible_distribution_release | lower }} main deb-src http://ams2.mirrors.digitalocean.com/mariadb/repo/{{ mariadb_version }}/ubuntu {{ ansible_distribution_release | lower }} main diff --git a/playbooks/roles/mariadb/vars/main.yml b/playbooks/roles/mariadb/vars/main.yml index b7bf4bcf..df81b3b7 100644 --- a/playbooks/roles/mariadb/vars/main.yml +++ b/playbooks/roles/mariadb/vars/main.yml @@ -3,7 +3,6 @@ mysql_conf_dir: "CentOS": /etc/my.cnf.d "Ubuntu": /etc/mysql/conf.d "Debian": /etc/mysql/conf.d - "MacOSX": /usr/local/etc/my.cnf.d mysql_conf_tpl: files/mariadb_config.cnf mysql_secure_installation: True -... \ No newline at end of file +... From c565269acfb7e13d3239da65b13d7304147d5535 Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Sat, 9 Jun 2018 10:09:44 +0000 Subject: [PATCH 03/33] cryptography urllib3 fixes --- playbooks/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks/install.py b/playbooks/install.py index 529e473a..5fb99e59 100644 --- a/playbooks/install.py +++ b/playbooks/install.py @@ -36,7 +36,7 @@ def install_bench(args): # secure pip installation if find_executable('pip'): run_os_command({ - 'pip': 'sudo pip install --upgrade setuptools pip==9.0.3' + 'pip': 'sudo pip install --upgrade setuptools urllib3 requests cryptography pip==9.0.3' }) else: From bb2453f7e243d550a0c94bd789b41bbc3a19161c Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Sat, 9 Jun 2018 10:13:23 +0000 Subject: [PATCH 04/33] requests urllib3 crypto fixes --- playbooks/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks/install.py b/playbooks/install.py index 5fb99e59..4c311586 100644 --- a/playbooks/install.py +++ b/playbooks/install.py @@ -51,7 +51,7 @@ def install_bench(args): if success: run_os_command({ - 'pip': 'sudo pip install --upgrade pip==9.0.3 setuptools', + 'pip': 'sudo pip install --upgrade setuptools urllib3 requests cryptography pip==9.0.3' }) success = run_os_command({ From e61227c973d85f6e91d22f723f17a00e94487b1e Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Sat, 9 Jun 2018 10:23:12 +0000 Subject: [PATCH 05/33] cryto --- playbooks/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks/install.py b/playbooks/install.py index 5fb99e59..255fb0b3 100644 --- a/playbooks/install.py +++ b/playbooks/install.py @@ -55,7 +55,7 @@ def install_bench(args): }) success = run_os_command({ - 'pip': "sudo pip install ansible" + 'pip': "sudo pip install --upgrade urllib3 requests cryptography ansible" }) if not success: From 4559eba08ffd1911616bbf04b26659e9ff1a0387 Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Tue, 12 Jun 2018 12:44:07 +0530 Subject: [PATCH 06/33] added bench manager to readme --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 9cfff9e4..724ec338 100755 --- a/README.md +++ b/README.md @@ -144,6 +144,22 @@ For production: --- +## Bench Manger (GUI for Bench) + +Bench Manager is a graphical user interface to emulate the functionalities of Frappé Bench. Like the command line utility it helps you install apps, manage multiple sites, update apps and much more. + +### Installation + +``` +$ bench setup manager +``` + +What all it does: + +1. Create new site bench-manager.local +2. Gets the bench_manager app from https://github.com/frappe/bench_manager if it doesn't exist already +3. Installs the bench_manager app on the site bench-manager.local + ## Docker Install - For Developers (beta) 1. For developer setup, you can also use the official [Frappé Docker](https://github.com/frappe/frappe_docker/). From 8c5d7837163e9f71911e3e2b7501300f9069ed0b Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Thu, 14 Jun 2018 09:10:55 +0530 Subject: [PATCH 07/33] [install] update frappe,erpnext docs apps to be installed (#677) --- bench/app.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/bench/app.py b/bench/app.py index 663b6a34..6cd495f2 100755 --- a/bench/app.py +++ b/bench/app.py @@ -75,7 +75,7 @@ def add_to_excluded_apps_txt(app, bench_path='.'): if app == 'frappe': raise ValueError('Frappe app cannot be excludeed from update') if app not in os.listdir('apps'): - raise ValueError('The app {} does not exist'.format(app)) + raise ValueError('The app {} does not exist'.format(app)) apps = get_excluded_apps(bench_path=bench_path) if app not in apps: apps.append(app) @@ -130,6 +130,22 @@ def get_app(git_url, branch=None, bench_path='.', build_asset_files=True, verbos apps_path = os.path.join(os.path.abspath(bench_path), 'apps') os.rename(os.path.join(apps_path, repo_name), os.path.join(apps_path, app_name)) + docs_app = '' + docs_app_url = '' + app_docs_map = { + 'frappe': 'frappe/frappe_io', + 'erpnext': 'erpnext/foundation' + } + if repo_name in app_docs_map.keys(): + docs_app = app_docs_map[repo_name] + docs_app_url = 'https://github.com/{docs_app}'.format(docs_app=docs_app) + print('Getting docs app for ' + app_name + '' + docs_app) + exec_cmd("git clone {git_url} {branch} {shallow_clone} --origin upstream".format( + git_url=docs_app_url, + shallow_clone=shallow_clone, + branch=branch), + cwd=os.path.join(bench_path, 'apps')) + print('installing', app_name) install_app(app=app_name, bench_path=bench_path, verbose=verbose) From 49d3887d76fe869aaffe121818b878be2cb39143 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 14 Jun 2018 09:27:08 +0530 Subject: [PATCH 08/33] [ask] for changelog --- bench/release.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bench/release.py b/bench/release.py index 6025d4a7..f0c0a65f 100755 --- a/bench/release.py +++ b/bench/release.py @@ -59,6 +59,7 @@ def confirm_testing(): print('') print('') click.confirm('Is manual testing done?', abort = True) + click.confirm('Have you added the change log?', abort = True) def bump(bench_path, app, bump_type, from_branch, to_branch, remote, owner, repo_name=None): assert bump_type in ['minor', 'major', 'patch', 'stable', 'prerelease'] From c342a82aa17215da94ee7ea7e8eccce14c08b039 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 14 Jun 2018 10:37:11 +0530 Subject: [PATCH 09/33] better way to install docs --- bench/app.py | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/bench/app.py b/bench/app.py index 6cd495f2..9c7e5999 100755 --- a/bench/app.py +++ b/bench/app.py @@ -130,21 +130,12 @@ def get_app(git_url, branch=None, bench_path='.', build_asset_files=True, verbos apps_path = os.path.join(os.path.abspath(bench_path), 'apps') os.rename(os.path.join(apps_path, repo_name), os.path.join(apps_path, app_name)) - docs_app = '' - docs_app_url = '' - app_docs_map = { - 'frappe': 'frappe/frappe_io', - 'erpnext': 'erpnext/foundation' - } - if repo_name in app_docs_map.keys(): - docs_app = app_docs_map[repo_name] - docs_app_url = 'https://github.com/{docs_app}'.format(docs_app=docs_app) - print('Getting docs app for ' + app_name + '' + docs_app) - exec_cmd("git clone {git_url} {branch} {shallow_clone} --origin upstream".format( - git_url=docs_app_url, - shallow_clone=shallow_clone, - branch=branch), - cwd=os.path.join(bench_path, 'apps')) + # get apps for docs + if repo_name=='frappe': + get_app('https://github.com/frappe/frappe_io') + + if repo_name=='erpnext': + get_app('https://github.com/erpnext/foundation') print('installing', app_name) install_app(app=app_name, bench_path=bench_path, verbose=verbose) From 8fc3a87a37fbdde79e02af0aab3196e127d5231a Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 14 Jun 2018 10:52:17 +0530 Subject: [PATCH 10/33] better way to install docs --- bench/app.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/bench/app.py b/bench/app.py index 9c7e5999..437a864c 100755 --- a/bench/app.py +++ b/bench/app.py @@ -91,7 +91,8 @@ def remove_from_excluded_apps_txt(app, bench_path='.'): apps.remove(app) return write_excluded_apps_txt(apps, bench_path=bench_path) -def get_app(git_url, branch=None, bench_path='.', build_asset_files=True, verbose=False): +def get_app(git_url, branch=None, bench_path='.', build_asset_files=True, verbose=False, + postprocess = True): # from bench.utils import check_url try: from urlparse import urljoin @@ -130,23 +131,25 @@ def get_app(git_url, branch=None, bench_path='.', build_asset_files=True, verbos apps_path = os.path.join(os.path.abspath(bench_path), 'apps') os.rename(os.path.join(apps_path, repo_name), os.path.join(apps_path, app_name)) - # get apps for docs - if repo_name=='frappe': - get_app('https://github.com/frappe/frappe_io') - - if repo_name=='erpnext': - get_app('https://github.com/erpnext/foundation') - print('installing', app_name) install_app(app=app_name, bench_path=bench_path, verbose=verbose) - if build_asset_files: - build_assets(bench_path=bench_path) - conf = get_config(bench_path=bench_path) - if conf.get('restart_supervisor_on_update'): - restart_supervisor_processes(bench_path=bench_path) - if conf.get('restart_systemd_on_update'): - restart_systemd_processes(bench_path=bench_path) + if postprocess: + # get apps for docs + if repo_name=='frappe': + get_app('https://github.com/frappe/frappe_io', postprocess = False) + + if repo_name=='erpnext': + get_app('https://github.com/erpnext/foundation', post_process = False) + + if build_asset_files: + build_assets(bench_path=bench_path) + conf = get_config(bench_path=bench_path) + + if conf.get('restart_supervisor_on_update'): + restart_supervisor_processes(bench_path=bench_path) + if conf.get('restart_systemd_on_update'): + restart_systemd_processes(bench_path=bench_path) def new_app(app, bench_path='.'): # For backwards compatibility From 9f917f8464a79e93ebced72b4c793cecd93fde75 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 14 Jun 2018 11:24:04 +0530 Subject: [PATCH 11/33] better way to install docs --- bench/app.py | 6 ++++-- bench/utils.py | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bench/app.py b/bench/app.py index 437a864c..9e8e1ca9 100755 --- a/bench/app.py +++ b/bench/app.py @@ -137,10 +137,12 @@ def get_app(git_url, branch=None, bench_path='.', build_asset_files=True, verbos if postprocess: # get apps for docs if repo_name=='frappe': - get_app('https://github.com/frappe/frappe_io', postprocess = False) + get_app('https://github.com/frappe/frappe_io', bench_path = bench_path, + branch= 'master', postprocess = False) if repo_name=='erpnext': - get_app('https://github.com/erpnext/foundation', post_process = False) + get_app('https://github.com/erpnext/foundation', bench_path = bench_path, + branch= 'master', post_process = False) if build_asset_files: build_assets(bench_path=bench_path) diff --git a/bench/utils.py b/bench/utils.py index 7b079d35..36adb6ba 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -142,7 +142,8 @@ def exec_cmd(cmd, cwd='.'): logger.info(cmd) - p = subprocess.Popen(cmd, cwd=cwd, shell=True, stdout=stdout, stderr=stderr, universal_newlines=True) + p = subprocess.Popen(cmd, cwd=cwd, shell=True, stdout=stdout, stderr=stderr, + universal_newlines=True) if async: return_code = print_output(p) @@ -381,7 +382,7 @@ def restart_supervisor_processes(bench_path='.', web_workers=False): else: supervisor_status = subprocess.check_output(['sudo', 'supervisorctl', 'status'], cwd=bench_path) supervisor_status = safe_decode(supervisor_status) - + if web_workers and '{bench_name}-web:'.format(bench_name=bench_name) in supervisor_status: group = '{bench_name}-web: '.format(bench_name=bench_name) @@ -415,7 +416,7 @@ def update_requirements(bench_path='.'): print('Updating Python libraries...') pip = os.path.join(bench_path, 'env', 'bin', 'pip') - # pip 10 seems to have a few problems associated with it, temporary freeze pip at 9.0.3 + # pip 10 seems to have a few problems associated with it, temporary freeze pip at 9.0.3 exec_cmd("{pip} install --upgrade pip==9.0.3".format(pip=pip)) apps_dir = os.path.join(bench_path, 'apps') From c1a8be47915f9ec55fbecc383c4c62c7214e389c Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 14 Jun 2018 13:29:37 +0530 Subject: [PATCH 12/33] better way to install docs --- bench/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bench/app.py b/bench/app.py index 9e8e1ca9..8f156430 100755 --- a/bench/app.py +++ b/bench/app.py @@ -142,7 +142,7 @@ def get_app(git_url, branch=None, bench_path='.', build_asset_files=True, verbos if repo_name=='erpnext': get_app('https://github.com/erpnext/foundation', bench_path = bench_path, - branch= 'master', post_process = False) + branch= 'master', postprocess = False) if build_asset_files: build_assets(bench_path=bench_path) From e6defad00313d311f987c651b1afe3df6a1f2a62 Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Tue, 19 Jun 2018 00:32:45 +0530 Subject: [PATCH 13/33] removed psutil as a requirement --- bench/config/nginx.py | 3 +-- bench/config/redis.py | 4 +--- requirements.txt | 1 - 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/bench/config/nginx.py b/bench/config/nginx.py index d3ba4c97..6bbfa9ad 100644 --- a/bench/config/nginx.py +++ b/bench/config/nginx.py @@ -215,7 +215,6 @@ def get_error_pages(): def get_limit_conn_shared_memory(): """Allocate 2 percent of total virtual memory as shared memory for nginx limit_conn_zone""" - import psutil - total_vm = (psutil.virtual_memory().total) / (1024 * 1024) # in MB + total_vm = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')) / (1024 * 1024) # in MB return int(0.02 * total_vm) diff --git a/bench/config/redis.py b/bench/config/redis.py index fe102135..6a32927e 100644 --- a/bench/config/redis.py +++ b/bench/config/redis.py @@ -67,9 +67,7 @@ def get_redis_version(): return float('{major}.{minor}'.format(major=version.major, minor=version.minor)) def get_max_redis_memory(): - import psutil - - total_virtual_mem = psutil.virtual_memory().total/(pow(1024, 2)) + total_virtual_mem = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')/(pow(1024, 2)) max_memory = int(total_virtual_mem * 0.05) # Max memory for redis is 5% of virtual memory if max_memory < 50: diff --git a/requirements.txt b/requirements.txt index 4365cc1d..9b2c5b30 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,6 @@ jinja2 virtualenv requests honcho -psutil python-crontab semantic_version GitPython==0.3.2.1 From 8d2b702888a19201144f56e3f8144ce7955b5664 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 21 Jun 2018 11:45:43 +0530 Subject: [PATCH 14/33] [minor] python3 fix and fix for #663 (#664) --- bench/patches/v4/update_node.py | 2 +- bench/utils.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bench/patches/v4/update_node.py b/bench/patches/v4/update_node.py index b6bab199..ffbe280c 100644 --- a/bench/patches/v4/update_node.py +++ b/bench/patches/v4/update_node.py @@ -8,7 +8,7 @@ def execute(bench_path): if node_exec: - result = subprocess.check_output([node_exec, '-v']) + result = subprocess.check_output([node_exec, '-v']).decode() else: click.echo(''' No node executable was found on your machine. diff --git a/bench/utils.py b/bench/utils.py index 36adb6ba..8d622d1f 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -94,6 +94,11 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False, setup_backups(bench_path=path) if not no_auto_update: setup_auto_update(bench_path=path) + copy_patches_txt(bench_path) + +def copy_patches_txt(bench_path): + shutil.copy(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'patches', 'patches.txt'), + os.path.join(bench_path, 'patches.txt')) def clone_apps_from(bench_path, clone_from, update_app=True): from .app import install_app From f1e9ab0f9fc0c211addf78a6681684d0044473c9 Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Thu, 21 Jun 2018 15:28:12 +0530 Subject: [PATCH 15/33] typo fix --- bench/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bench/utils.py b/bench/utils.py index 8d622d1f..7aedfd0f 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -94,7 +94,7 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False, setup_backups(bench_path=path) if not no_auto_update: setup_auto_update(bench_path=path) - copy_patches_txt(bench_path) + copy_patches_txt(path) def copy_patches_txt(bench_path): shutil.copy(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'patches', 'patches.txt'), From 2395e242cbc905d3cd84e40f8c0bac59448dbfc2 Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Tue, 26 Jun 2018 14:06:49 +0530 Subject: [PATCH 16/33] get frappe_theme for foundation --- bench/app.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bench/app.py b/bench/app.py index 8f156430..a69231e7 100755 --- a/bench/app.py +++ b/bench/app.py @@ -141,6 +141,8 @@ def get_app(git_url, branch=None, bench_path='.', build_asset_files=True, verbos branch= 'master', postprocess = False) if repo_name=='erpnext': + get_app('https://github.com/frappe/frappe_theme', bench_path = bench_path, + branch= 'master', postprocess = False) get_app('https://github.com/erpnext/foundation', bench_path = bench_path, branch= 'master', postprocess = False) From c33cff5fd82ec1468891c2b8b97511f1d18a86f7 Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Tue, 26 Jun 2018 17:08:01 +0530 Subject: [PATCH 17/33] Revert "get frappe_theme for foundation" --- bench/app.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/bench/app.py b/bench/app.py index a69231e7..8f156430 100755 --- a/bench/app.py +++ b/bench/app.py @@ -141,8 +141,6 @@ def get_app(git_url, branch=None, bench_path='.', build_asset_files=True, verbos branch= 'master', postprocess = False) if repo_name=='erpnext': - get_app('https://github.com/frappe/frappe_theme', bench_path = bench_path, - branch= 'master', postprocess = False) get_app('https://github.com/erpnext/foundation', bench_path = bench_path, branch= 'master', postprocess = False) From 4aaae8b791103ef2886f20ba761c9f6ce1186d7f Mon Sep 17 00:00:00 2001 From: Saurabh Date: Fri, 29 Jun 2018 11:36:22 +0530 Subject: [PATCH 18/33] Setup Wildcard SSL --- bench/commands/setup.py | 9 +++++++++ bench/config/lets_encrypt.py | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/bench/commands/setup.py b/bench/commands/setup.py index 1fe014e8..88b07bca 100755 --- a/bench/commands/setup.py +++ b/bench/commands/setup.py @@ -128,6 +128,15 @@ def setup_letsencrypt(site, custom_domain, non_interactive): setup_letsencrypt(site, custom_domain, bench_path='.', interactive=not non_interactive) +@click.command('wildcard-ssl') +@click.argument('domain') +@click.option('--email') +def setup_wildcard_ssl(domain, email): + ''' Setup wildcard ssl certificate ''' + from bench.config.lets_encrypt import setup_wildcard_ssl + setup_wildcard_ssl(domain, email, bench_path='.') + + @click.command('procfile') def setup_procfile(): "Setup Procfile for bench start" diff --git a/bench/config/lets_encrypt.py b/bench/config/lets_encrypt.py index c6dceb16..26a7e682 100755 --- a/bench/config/lets_encrypt.py +++ b/bench/config/lets_encrypt.py @@ -1,5 +1,5 @@ import bench, os, click, errno -from bench.utils import exec_cmd, CommandFailedError +from bench.utils import exec_cmd, CommandFailedError, update_common_site_config from bench.config.site_config import update_site_config, remove_domain, get_domains from bench.config.nginx import make_nginx_conf from bench.config.production_setup import service @@ -116,3 +116,34 @@ def renew_certs(): service('nginx', 'stop') exec_cmd("{path} renew".format(path=get_certbot_path())) service('nginx', 'start') + + +def setup_wildcard_ssl(domain, email, bench_path): + get_certbot() + + email_param = '' + if email: + email_param = '--email {0}'.format(email) + + try: + exec_cmd("{path} certonly --manual --preferred-challenges=dns {email_param} \ + --server https://acme-v02.api.letsencrypt.org/directory \ + --agree-tos -d {domain}".format(path=get_certbot_path(), domain=domain, + email_param=email_param)) + + except CommandFailedError: + print("There was a problem trying to setup SSL") + return + + ssl_path = "/etc/letsencrypt/live/{domain}/".format(site=domain) + ssl_config = { + "wildcard": { + "domain": domain, + "ssl_certificate": os.path.join(ssl_path, "fullchain.pem"), + "ssl_certificate_key": os.path.join(ssl_path, "privkey.pem") + } + } + + update_common_site_config(ssl_config) + make_nginx_conf(bench_path) + service('nginx', 'restart') From ab6cc5164f4419a85b0b79df8c29deb238148af9 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Fri, 29 Jun 2018 13:37:03 +0530 Subject: [PATCH 19/33] check if dns mutitenancy is active --- bench/config/lets_encrypt.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bench/config/lets_encrypt.py b/bench/config/lets_encrypt.py index 26a7e682..6484fac4 100755 --- a/bench/config/lets_encrypt.py +++ b/bench/config/lets_encrypt.py @@ -121,6 +121,10 @@ def renew_certs(): def setup_wildcard_ssl(domain, email, bench_path): get_certbot() + if not get_config(bench_path).get("dns_multitenant"): + print("You cannot setup SSL without DNS Multitenancy") + return + email_param = '' if email: email_param = '--email {0}'.format(email) From 2da047cd90f87c71e860df0c716647d4ec8980ba Mon Sep 17 00:00:00 2001 From: Saurabh Date: Fri, 29 Jun 2018 13:46:40 +0530 Subject: [PATCH 20/33] add command to generate wildcard ssl --- bench/cli.py | 2 +- bench/commands/setup.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bench/cli.py b/bench/cli.py index e6ad9984..c314d90a 100755 --- a/bench/cli.py +++ b/bench/cli.py @@ -48,7 +48,7 @@ def check_uid(): def cmd_requires_root(): if len(sys.argv) > 2 and sys.argv[2] in ('production', 'sudoers', 'lets-encrypt', 'fonts', - 'print', 'firewall', 'ssh-port', 'role', 'fail2ban'): + 'print', 'firewall', 'ssh-port', 'role', 'fail2ban', 'wildcard-ssl'): return True if len(sys.argv) >= 2 and sys.argv[1] in ('patch', 'renew-lets-encrypt', 'disable-production', 'install'): diff --git a/bench/commands/setup.py b/bench/commands/setup.py index 88b07bca..d3aec204 100755 --- a/bench/commands/setup.py +++ b/bench/commands/setup.py @@ -288,6 +288,7 @@ setup.add_command(reload_nginx) setup.add_command(setup_supervisor) setup.add_command(setup_redis) setup.add_command(setup_letsencrypt) +setup.add_command(setup_wildcard_ssl) setup.add_command(setup_production) setup.add_command(setup_auto_update) setup.add_command(setup_backups) From cb2c51684bd73811804784d79f83da02b468de97 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Fri, 29 Jun 2018 13:51:42 +0530 Subject: [PATCH 21/33] typo fix --- bench/config/lets_encrypt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bench/config/lets_encrypt.py b/bench/config/lets_encrypt.py index 6484fac4..25b6c388 100755 --- a/bench/config/lets_encrypt.py +++ b/bench/config/lets_encrypt.py @@ -139,7 +139,7 @@ def setup_wildcard_ssl(domain, email, bench_path): print("There was a problem trying to setup SSL") return - ssl_path = "/etc/letsencrypt/live/{domain}/".format(site=domain) + ssl_path = "/etc/letsencrypt/live/{domain}/".format(domain=domain) ssl_config = { "wildcard": { "domain": domain, From b81904b8c86486511bfc3bd89aef8f0bcc4838d0 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Fri, 29 Jun 2018 13:57:11 +0530 Subject: [PATCH 22/33] prepend wildcard character to domain --- bench/config/lets_encrypt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bench/config/lets_encrypt.py b/bench/config/lets_encrypt.py index 25b6c388..c0361dc7 100755 --- a/bench/config/lets_encrypt.py +++ b/bench/config/lets_encrypt.py @@ -132,7 +132,7 @@ def setup_wildcard_ssl(domain, email, bench_path): try: exec_cmd("{path} certonly --manual --preferred-challenges=dns {email_param} \ --server https://acme-v02.api.letsencrypt.org/directory \ - --agree-tos -d {domain}".format(path=get_certbot_path(), domain=domain, + --agree-tos -d *.{domain}".format(path=get_certbot_path(), domain=domain, email_param=email_param)) except CommandFailedError: From 9f150c4c352c5fff9956e120b7090d44fde250bf Mon Sep 17 00:00:00 2001 From: Saurabh Date: Fri, 29 Jun 2018 14:24:15 +0530 Subject: [PATCH 23/33] check for wildcard character in domain if not exists prepend it --- bench/config/lets_encrypt.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bench/config/lets_encrypt.py b/bench/config/lets_encrypt.py index c0361dc7..18525e7b 100755 --- a/bench/config/lets_encrypt.py +++ b/bench/config/lets_encrypt.py @@ -119,12 +119,22 @@ def renew_certs(): def setup_wildcard_ssl(domain, email, bench_path): - get_certbot() + + def _get_domain_name(domain): + if domain.split('.')[0] != '*': + domain = '*.{0}'.foramt(domain) + return domain + + domain = _get_domain_name(domain) + + return if not get_config(bench_path).get("dns_multitenant"): print("You cannot setup SSL without DNS Multitenancy") return + get_certbot() + email_param = '' if email: email_param = '--email {0}'.format(email) @@ -132,7 +142,7 @@ def setup_wildcard_ssl(domain, email, bench_path): try: exec_cmd("{path} certonly --manual --preferred-challenges=dns {email_param} \ --server https://acme-v02.api.letsencrypt.org/directory \ - --agree-tos -d *.{domain}".format(path=get_certbot_path(), domain=domain, + --agree-tos -d {domain}".format(path=get_certbot_path(), domain=domain, email_param=email_param)) except CommandFailedError: From 179dfc1685976c357952f0b9e82e1580810ae252 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Fri, 29 Jun 2018 14:27:28 +0530 Subject: [PATCH 24/33] typo fix --- bench/config/lets_encrypt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bench/config/lets_encrypt.py b/bench/config/lets_encrypt.py index 18525e7b..abb61a10 100755 --- a/bench/config/lets_encrypt.py +++ b/bench/config/lets_encrypt.py @@ -122,7 +122,7 @@ def setup_wildcard_ssl(domain, email, bench_path): def _get_domain_name(domain): if domain.split('.')[0] != '*': - domain = '*.{0}'.foramt(domain) + domain = '*.{0}'.format(domain) return domain domain = _get_domain_name(domain) From 8ddfbd3e61d24db4920e64e4964b353d187f6221 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Fri, 29 Jun 2018 14:31:48 +0530 Subject: [PATCH 25/33] debug --- bench/config/lets_encrypt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bench/config/lets_encrypt.py b/bench/config/lets_encrypt.py index abb61a10..0cbd4697 100755 --- a/bench/config/lets_encrypt.py +++ b/bench/config/lets_encrypt.py @@ -126,7 +126,7 @@ def setup_wildcard_ssl(domain, email, bench_path): return domain domain = _get_domain_name(domain) - + print("domain", domain) return if not get_config(bench_path).get("dns_multitenant"): From 51f38c028989b42f2f0e456ff5ec0ea2afc66c74 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Fri, 29 Jun 2018 14:35:28 +0530 Subject: [PATCH 26/33] fix wildcard char --- bench/config/lets_encrypt.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bench/config/lets_encrypt.py b/bench/config/lets_encrypt.py index 0cbd4697..3cdfef71 100755 --- a/bench/config/lets_encrypt.py +++ b/bench/config/lets_encrypt.py @@ -124,16 +124,13 @@ def setup_wildcard_ssl(domain, email, bench_path): if domain.split('.')[0] != '*': domain = '*.{0}'.format(domain) return domain - - domain = _get_domain_name(domain) - print("domain", domain) - return if not get_config(bench_path).get("dns_multitenant"): print("You cannot setup SSL without DNS Multitenancy") return get_certbot() + domain = _get_domain_name(domain) email_param = '' if email: From 8f39df5c34a7fa40ac27e6e1c3aa12e6de7dc55b Mon Sep 17 00:00:00 2001 From: Saurabh Date: Sat, 30 Jun 2018 10:38:59 +0530 Subject: [PATCH 27/33] Include base domain while generating ssl certificate if not excluded explicitly --- bench/commands/setup.py | 3 ++- bench/config/lets_encrypt.py | 25 ++++++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/bench/commands/setup.py b/bench/commands/setup.py index d3aec204..25e0fc5e 100755 --- a/bench/commands/setup.py +++ b/bench/commands/setup.py @@ -131,7 +131,8 @@ def setup_letsencrypt(site, custom_domain, non_interactive): @click.command('wildcard-ssl') @click.argument('domain') @click.option('--email') -def setup_wildcard_ssl(domain, email): +@click.option('--exclude-base-domain', default=False, is_flag=True, help="SSL Certificate not applicable for base domain") +def setup_wildcard_ssl(domain, email, exclude_base_domain): ''' Setup wildcard ssl certificate ''' from bench.config.lets_encrypt import setup_wildcard_ssl setup_wildcard_ssl(domain, email, bench_path='.') diff --git a/bench/config/lets_encrypt.py b/bench/config/lets_encrypt.py index 3cdfef71..a225754c 100755 --- a/bench/config/lets_encrypt.py +++ b/bench/config/lets_encrypt.py @@ -118,19 +118,27 @@ def renew_certs(): service('nginx', 'start') -def setup_wildcard_ssl(domain, email, bench_path): +def setup_wildcard_ssl(domain, email, bench_path, exclude_base_domain): - def _get_domain_name(domain): - if domain.split('.')[0] != '*': - domain = '*.{0}'.format(domain) - return domain + def _get_domains(domain): + domain_list = [domain] + + if not domain.startswith('*.'): + # add wildcard caracter to domain if missing + domain_list.append('*.{0}'.format(domain)) + else: + # include base domain based on flag + if not exclude_base_domain: + domain_list.append(domain.replace('*.', '')) + + return domain_list if not get_config(bench_path).get("dns_multitenant"): print("You cannot setup SSL without DNS Multitenancy") return get_certbot() - domain = _get_domain_name(domain) + domain_list = _get_domains(domain.strip()) email_param = '' if email: @@ -139,7 +147,7 @@ def setup_wildcard_ssl(domain, email, bench_path): try: exec_cmd("{path} certonly --manual --preferred-challenges=dns {email_param} \ --server https://acme-v02.api.letsencrypt.org/directory \ - --agree-tos -d {domain}".format(path=get_certbot_path(), domain=domain, + --agree-tos -d {domain}".format(path=get_certbot_path(), domain=' -d '.join(domain_list), email_param=email_param)) except CommandFailedError: @@ -156,5 +164,8 @@ def setup_wildcard_ssl(domain, email, bench_path): } update_common_site_config(ssl_config) + setup_crontab() + make_nginx_conf(bench_path) service('nginx', 'restart') + \ No newline at end of file From 5c980dce10779935f0d46d3deae4431fc4ce1235 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Mon, 2 Jul 2018 11:44:11 +0530 Subject: [PATCH 28/33] Test --- bench/config/lets_encrypt.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bench/config/lets_encrypt.py b/bench/config/lets_encrypt.py index a225754c..6139504f 100755 --- a/bench/config/lets_encrypt.py +++ b/bench/config/lets_encrypt.py @@ -144,6 +144,13 @@ def setup_wildcard_ssl(domain, email, bench_path, exclude_base_domain): if email: email_param = '--email {0}'.format(email) + + print("{path} certonly --manual --preferred-challenges=dns {email_param} \ + --server https://acme-v02.api.letsencrypt.org/directory \ + --agree-tos -d {domain}".format(path=get_certbot_path(), domain=' -d '.join(domain_list), + email_param=email_param)) + return + try: exec_cmd("{path} certonly --manual --preferred-challenges=dns {email_param} \ --server https://acme-v02.api.letsencrypt.org/directory \ @@ -167,5 +174,6 @@ def setup_wildcard_ssl(domain, email, bench_path, exclude_base_domain): setup_crontab() make_nginx_conf(bench_path) + print("Restrting Nginx service") service('nginx', 'restart') \ No newline at end of file From 364cd8fe1b43a44f2c0bc9eb8ed6f17e183d6323 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Mon, 2 Jul 2018 11:49:51 +0530 Subject: [PATCH 29/33] [fix][args] add param exclude base domain --- bench/commands/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bench/commands/setup.py b/bench/commands/setup.py index 25e0fc5e..8039be26 100755 --- a/bench/commands/setup.py +++ b/bench/commands/setup.py @@ -135,7 +135,7 @@ def setup_letsencrypt(site, custom_domain, non_interactive): def setup_wildcard_ssl(domain, email, exclude_base_domain): ''' Setup wildcard ssl certificate ''' from bench.config.lets_encrypt import setup_wildcard_ssl - setup_wildcard_ssl(domain, email, bench_path='.') + setup_wildcard_ssl(domain, email, bench_path='.', exclude_base_domain) @click.command('procfile') From 41e227cff1e32d5c89d5437bff310ab0f479c2be Mon Sep 17 00:00:00 2001 From: Saurabh Date: Mon, 2 Jul 2018 11:56:13 +0530 Subject: [PATCH 30/33] [fix] syntax fixes --- bench/commands/setup.py | 2 +- bench/config/lets_encrypt.py | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/bench/commands/setup.py b/bench/commands/setup.py index 8039be26..d88ee80f 100755 --- a/bench/commands/setup.py +++ b/bench/commands/setup.py @@ -135,7 +135,7 @@ def setup_letsencrypt(site, custom_domain, non_interactive): def setup_wildcard_ssl(domain, email, exclude_base_domain): ''' Setup wildcard ssl certificate ''' from bench.config.lets_encrypt import setup_wildcard_ssl - setup_wildcard_ssl(domain, email, bench_path='.', exclude_base_domain) + setup_wildcard_ssl(domain, email, bench_path='.', exclude_base_domain=exclude_base_domain) @click.command('procfile') diff --git a/bench/config/lets_encrypt.py b/bench/config/lets_encrypt.py index 6139504f..9088766e 100755 --- a/bench/config/lets_encrypt.py +++ b/bench/config/lets_encrypt.py @@ -144,13 +144,6 @@ def setup_wildcard_ssl(domain, email, bench_path, exclude_base_domain): if email: email_param = '--email {0}'.format(email) - - print("{path} certonly --manual --preferred-challenges=dns {email_param} \ - --server https://acme-v02.api.letsencrypt.org/directory \ - --agree-tos -d {domain}".format(path=get_certbot_path(), domain=' -d '.join(domain_list), - email_param=email_param)) - return - try: exec_cmd("{path} certonly --manual --preferred-challenges=dns {email_param} \ --server https://acme-v02.api.letsencrypt.org/directory \ From 14f56d11773104836f58cc663f2dc26c066d556e Mon Sep 17 00:00:00 2001 From: Saurabh Date: Mon, 2 Jul 2018 12:00:58 +0530 Subject: [PATCH 31/33] check exclusion expicitly --- bench/config/lets_encrypt.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bench/config/lets_encrypt.py b/bench/config/lets_encrypt.py index 9088766e..4ec0f851 100755 --- a/bench/config/lets_encrypt.py +++ b/bench/config/lets_encrypt.py @@ -128,8 +128,10 @@ def setup_wildcard_ssl(domain, email, bench_path, exclude_base_domain): domain_list.append('*.{0}'.format(domain)) else: # include base domain based on flag - if not exclude_base_domain: - domain_list.append(domain.replace('*.', '')) + domain_list.append(domain.replace('*.', '')) + + if exclude_base_domain: + domain_list.remove(domain.replace('*.', '')) return domain_list From f90f7e141efae9304b73ae73ed4501fdf431b634 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Mon, 2 Jul 2018 16:24:53 +0530 Subject: [PATCH 32/33] Add single quotes around password variables in ansible script As mentioned in #657 admin and mysql root password with whitespaces aren't recognized properly by shell adding single quotes around them fixes this issue. --- playbooks/roles/bench/tasks/setup_erpnext.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks/roles/bench/tasks/setup_erpnext.yml b/playbooks/roles/bench/tasks/setup_erpnext.yml index 2e49219c..5dee30b3 100644 --- a/playbooks/roles/bench/tasks/setup_erpnext.yml +++ b/playbooks/roles/bench/tasks/setup_erpnext.yml @@ -15,7 +15,7 @@ register: site_folder - name: Create a new site - command: "bench new-site {{ site }} --admin-password {{ admin_password }} --mariadb-root-password {{ mysql_root_password }}" + command: "bench new-site {{ site }} --admin-password '{{ admin_password }}' --mariadb-root-password '{{ mysql_root_password }}'" args: chdir: "{{ bench_path }}" when: not site_folder.stat.exists From 297f0d4bc54a295e8ad84982e08ad64850d917d1 Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Tue, 3 Jul 2018 12:58:52 +0530 Subject: [PATCH 33/33] modified mode install method --- .travis.yml | 2 -- playbooks/roles/nodejs/defaults/main.yml | 3 +++ playbooks/roles/nodejs/tasks/debian_family.yml | 14 +------------- playbooks/roles/nodejs/tasks/main.yml | 6 ++++++ playbooks/roles/nodejs/tasks/redhat_family.yml | 15 +-------------- playbooks/site.yml | 2 +- 6 files changed, 12 insertions(+), 30 deletions(-) create mode 100644 playbooks/roles/nodejs/defaults/main.yml diff --git a/.travis.yml b/.travis.yml index e4b562b7..ae45db62 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,5 @@ language: python dist: trusty -group: deprecated-2017Q2 -sudo: required python: - "2.7" diff --git a/playbooks/roles/nodejs/defaults/main.yml b/playbooks/roles/nodejs/defaults/main.yml new file mode 100644 index 00000000..f991faa1 --- /dev/null +++ b/playbooks/roles/nodejs/defaults/main.yml @@ -0,0 +1,3 @@ +--- +node_version: 8 +... \ No newline at end of file diff --git a/playbooks/roles/nodejs/tasks/debian_family.yml b/playbooks/roles/nodejs/tasks/debian_family.yml index c64bac55..a9930529 100644 --- a/playbooks/roles/nodejs/tasks/debian_family.yml +++ b/playbooks/roles/nodejs/tasks/debian_family.yml @@ -1,17 +1,5 @@ --- -- name: Add apt key for node repo - apt_key: - url: https://keyserver.ubuntu.com/pks/lookup?op=get&fingerprint=on&search=0x1655A0AB68576280 - id: "68576280" - state: present - -- name: Add repo - apt_repository: - repo: "deb [arch=amd64,i386] https://deb.nodesource.com/node_8.x {{ ansible_distribution_release }} main" - state: present - register: node_repo - -- name: Install nodejs 8.x +- name: Install nodejs {{ node_version }} apt: name: nodejs state: present diff --git a/playbooks/roles/nodejs/tasks/main.yml b/playbooks/roles/nodejs/tasks/main.yml index 85379727..6ff013d7 100644 --- a/playbooks/roles/nodejs/tasks/main.yml +++ b/playbooks/roles/nodejs/tasks/main.yml @@ -1,6 +1,12 @@ --- # Install's prerequisites, like fonts, image libraries, vim, screen, python-dev and gcc +- name: 'Add Node.js PPA' + tags: 'nodejs' + become: 'yes' + become_method: 'sudo' + shell: "curl --silent --location https://deb.nodesource.com/setup_{{ node_version }}.x | bash -" + - include_tasks: debian_family.yml when: ansible_os_family == 'Debian' diff --git a/playbooks/roles/nodejs/tasks/redhat_family.yml b/playbooks/roles/nodejs/tasks/redhat_family.yml index 15af3846..1c3d8fb1 100644 --- a/playbooks/roles/nodejs/tasks/redhat_family.yml +++ b/playbooks/roles/nodejs/tasks/redhat_family.yml @@ -1,18 +1,5 @@ --- -- name: Import Node source RPM key - rpm_key: - key: https://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL - state: present - when: ansible_os_family == 'RedHat' - -- name: Add Node Repo for RedHat - yum: - name: 'https://rpm.nodesource.com/pub_8.x/el/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/nodesource-release-el{{ ansible_distribution_major_version }}-1.noarch.rpm' - state: present - update_cache: yes - when: ansible_os_family == 'RedHat' - -- name: Install node v8 +- name: Install node v{{ node_version }} yum: name=nodejs state=present when: ansible_os_family == 'RedHat' ... \ No newline at end of file diff --git a/playbooks/site.yml b/playbooks/site.yml index 839620ee..ca7cb51a 100644 --- a/playbooks/site.yml +++ b/playbooks/site.yml @@ -7,6 +7,7 @@ roles: - { role: common, tags: common } - { role: locale, tags: locale } + - { role: nodejs, tags: nodejs } - { role: swap, tags: swap, when: production } - { role: logwatch, tags: logwatch, when: production } - { role: bash_screen_wall, tags: bash_screen_wall, when: production } @@ -15,7 +16,6 @@ - { role: ntpd, tags: ntpd, when: production } - { role: mariadb, tags: mariadb } - { role: wkhtmltopdf, tags: wkhtmltopdf } - - { role: nodejs, tags: nodejs } - { role: psutil, tags: psutil } - { role: redis, tags: redis } - { role: supervisor, tags: supervisor, when: production }