diff --git a/bench/patches/v5/fix_user_permissions.py b/bench/patches/v5/fix_user_permissions.py index 3bea08a6..98a8e327 100644 --- a/bench/patches/v5/fix_user_permissions.py +++ b/bench/patches/v5/fix_user_permissions.py @@ -1,16 +1,20 @@ # imports - standard imports import subprocess +import sys # imports - module imports -from bench.utils import log, get_cmd_output, exec_cmd +from bench.utils import log, get_cmd_output, exec_cmd, which from bench.cli import change_uid_msg def execute(bench_path): - """fix supervisor using root then remove bench sudo later - chronology samajhiye""" cmd = ["sudo", "-n", "bench"] + is_bench_sudoers_set = (not subprocess.call(cmd)) or (change_uid_msg in get_cmd_output(cmd)) + is_supervisor_installed = which('supervisorctl') + + if not is_supervisor_installed: + exec_cmd("{} -m pip install supervisor".format(sys.executable)) if is_bench_sudoers_set: exec_cmd("sudo bench setup supervisor --yes")