From d23d7489d77ea650e059a78a4d8b5c8c74d3ae33 Mon Sep 17 00:00:00 2001 From: Valmik Jangla Date: Tue, 2 Aug 2016 11:58:28 +0530 Subject: [PATCH] Added macos support for version check --- bench/config/lets_encrypt.py | 4 ++-- playbooks/develop/centos.yml | 2 +- playbooks/develop/debian.yml | 14 +++++++------- playbooks/install.py | 25 +++++++++++++++---------- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/bench/config/lets_encrypt.py b/bench/config/lets_encrypt.py index a55bc82f..9e7d5c80 100755 --- a/bench/config/lets_encrypt.py +++ b/bench/config/lets_encrypt.py @@ -90,6 +90,6 @@ def renew_certs(): 'Do you want to continue?', abort=True) - service('nginx', 'start') - exec_cmd("{path} renew".format(path=get_certbot_path())) service('nginx', 'stop') + exec_cmd("{path} renew".format(path=get_certbot_path())) + service('nginx', 'start') diff --git a/playbooks/develop/centos.yml b/playbooks/develop/centos.yml index 914d8f0f..5233d9f1 100644 --- a/playbooks/develop/centos.yml +++ b/playbooks/develop/centos.yml @@ -74,7 +74,7 @@ # setup frappe-bench - include: includes/setup_bench.yml - when: not run_travis and without_bench_setup + when: not run_travis and not without_bench_setup # setup development environment - include: includes/setup_dev_env.yml diff --git a/playbooks/develop/debian.yml b/playbooks/develop/debian.yml index 88a0f55a..1d3e42c0 100755 --- a/playbooks/develop/debian.yml +++ b/playbooks/develop/debian.yml @@ -74,20 +74,20 @@ become: yes become_user: root - - name: Add nodejs v5 repo + - name: Get nodejs 6.x bash script get_url: - url: 'https://deb.nodesource.com/setup_5.x' - dest: '/tmp/setup_5.x' + url: 'https://deb.nodesource.com/setup_6.x' + dest: '/tmp/setup_6.x' mode: 0644 become: yes become_user: root - - name: Install setup_5.x - command: /bin/bash /tmp/setup_5.x + - name: Run nodejs bash script + command: /bin/bash /tmp/setup_6.x become: yes become_user: root - - name: Update and Install Node v5 + - name: Install nodejs 6.x apt: name: nodejs state: present @@ -95,7 +95,7 @@ force: yes become: yes become_user: root - + # install MariaDB - include: includes/mariadb_debian.yml diff --git a/playbooks/install.py b/playbooks/install.py index ba734080..05e5123a 100755 --- a/playbooks/install.py +++ b/playbooks/install.py @@ -114,23 +114,28 @@ def install_bench(args): shutil.rmtree(tmp_bench_repo) def check_distribution_compatibility(): - supported_dists = {'ubuntu': [14, 15, 16], 'debian': [7, 8], 'centos': [7]} - dist_name, dist_version = get_distribution_info() - for dist, versions in supported_dists.iteritems(): - if dist_name == dist: - if dist_version in versions: - return + supported_dists = {'ubuntu': [14, 15, 16], 'debian': [7, 8], + 'centos': [7], 'macos': [10.9, 10.10, 10.11, 10.12]} - print "We currently do not support {0} {1}. Aborting installation!".format(dist_name, dist_version) + dist_name, dist_version = get_distribution_info() + if dist_name in supported_dists: + if float(dist_version) in supported_dists[dist_name]: + return + + print "Sorry, the installer doesn't support {0} {1}. Aborting installation!".format(dist_name, dist_version) if dist_name in supported_dists: print "Install on {0} {1} instead".format(dist_name, supported_dists[dist_name][-1]) sys.exit(1) def get_distribution_info(): - current_dist = platform.dist() # return distribution name and major version - return current_dist[0].lower(), int(float(current_dist[1])) - + if platform.system() == "Linux": + current_dist = platform.dist() + return current_dist[0].lower(), current_dist[1].rsplit('.')[0] + elif platform.system() == "Darwin": + current_dist = platform.mac_ver() + return "macos", current_dist[0].rsplit('.', 1)[0] + def install_python27(): version = (sys.version_info[0], sys.version_info[1])