From 439413ffb167ddfee8d367d5750ffdb37bc9d722 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Mon, 24 Nov 2014 14:58:00 +0530 Subject: [PATCH 1/2] fix easy install for utopic --- bench/production_setup.py | 12 ++++++++++-- install_scripts/setup_frappe.sh | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/bench/production_setup.py b/bench/production_setup.py index dcb41558..8e5cb3fc 100644 --- a/bench/production_setup.py +++ b/bench/production_setup.py @@ -8,10 +8,10 @@ def restart_service(service): program = get_program(['systemctl', 'service']) if not program: raise Exception, 'No service manager found' - elif os.path.basename(program) == 'systemctl': - exec_cmd("{prog} restart {service}".format(prog=program, service=service)) elif os.path.basename(program) == 'service': exec_cmd("{prog} {service} restart ".format(prog=program, service=service)) + elif os.path.basename(program) == 'systemctl' and is_running_systemd(): + exec_cmd("{prog} restart {service}".format(prog=program, service=service)) def get_supervisor_confdir(): possiblities = ('/etc/supervisor/conf.d', '/etc/supervisor.d/', '/etc/supervisord/conf.d', '/etc/supervisord.d') @@ -30,6 +30,14 @@ def remove_default_nginx_configs(): def is_centos7(): return os.path.exists('/etc/redhat-release') and get_cmd_output("cat /etc/redhat-release | sed 's/Linux\ //g' | cut -d' ' -f3 | cut -d. -f1").strip() == '7' +def is_running_systemd(): + with open('/proc/1/comm') as f: + comm = f.read().strip() + if comm == "init": + return False + elif comm == "systemd": + return True + return False def copy_default_nginx_config(): shutil.copy(os.path.join(os.path.dirname(__file__), 'templates', 'nginx_default.conf'), '/etc/nginx/nginx.conf') diff --git a/install_scripts/setup_frappe.sh b/install_scripts/setup_frappe.sh index 1bf1a217..7baf85fd 100644 --- a/install_scripts/setup_frappe.sh +++ b/install_scripts/setup_frappe.sh @@ -139,7 +139,9 @@ add_epel_centos7() { } add_maria_db_repo() { - if [ "$OS" == "centos" ]; then + if [ "$OS" == "Ubuntu" ] && [ $VER=="utopic" ]; then + return + elif [ "$OS" == "centos" ]; then echo Adding centos mariadb repo add_centos6_mariadb_repo From 707be68f5c667370f1ae797d9c36d96f0d72d6d8 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Mon, 24 Nov 2014 17:54:10 +0530 Subject: [PATCH 2/2] fix restart service --- bench/production_setup.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/bench/production_setup.py b/bench/production_setup.py index 8e5cb3fc..aa0b03a1 100644 --- a/bench/production_setup.py +++ b/bench/production_setup.py @@ -5,13 +5,12 @@ import os import shutil def restart_service(service): - program = get_program(['systemctl', 'service']) - if not program: + if os.path.basename(get_program(['systemctl'])) == 'systemctl' and is_running_systemd(): + exec_cmd("{prog} restart {service}".format(prog='systemctl', service=service)) + elif os.path.basename(get_program(['service'])) == 'service': + exec_cmd("{prog} {service} restart ".format(prog='service', service=service)) + else: raise Exception, 'No service manager found' - elif os.path.basename(program) == 'service': - exec_cmd("{prog} {service} restart ".format(prog=program, service=service)) - elif os.path.basename(program) == 'systemctl' and is_running_systemd(): - exec_cmd("{prog} restart {service}".format(prog=program, service=service)) def get_supervisor_confdir(): possiblities = ('/etc/supervisor/conf.d', '/etc/supervisor.d/', '/etc/supervisord/conf.d', '/etc/supervisord.d')