2
0
mirror of https://github.com/frappe/bench.git synced 2024-09-23 20:49:01 +00:00

fix: update supervisord and sudoers for old benches

This commit is contained in:
Gavin D'souza 2020-03-15 19:31:27 +05:30
parent 48f70aca65
commit e12208dc25
5 changed files with 24 additions and 1 deletions

View File

@ -8,6 +8,7 @@ from bench.commands import bench_command
logger = logging.getLogger('bench')
from_command_line = False
change_uid_msg = "You should not run this command as root"
def cli():
global from_command_line
@ -72,7 +73,7 @@ def change_uid():
drop_privileges(uid_name=frappe_user, gid_name=frappe_user)
os.environ['HOME'] = pwd.getpwnam(frappe_user).pw_dir
else:
log('You should not run this command as root', level=3)
log(change_uid_msg, level=3)
sys.exit(1)
def old_frappe_cli(bench_path='.'):

View File

@ -1,3 +1,6 @@
# This file is auto-generated by frappe/bench
# To re-generate this file, run "bench setup sudoers"
{% if service %}
{{ user }} ALL = (root) {{ service }}
{{ user }} ALL = (root) NOPASSWD: {{ service }} nginx *
@ -14,3 +17,4 @@
{{ user }} ALL = (root) NOPASSWD: /opt/certbot-auto
Defaults:{{ user }} !requiretty

View File

@ -4,3 +4,4 @@ bench.patches.v3.redis_bind_ip
bench.patches.v4.update_node
bench.patches.v4.update_socketio
bench.patches.v4.install_yarn #2
bench.patches.v5.fix_user_permissions

View File

View File

@ -0,0 +1,17 @@
# imports - standard imports
import subprocess
# imports - module imports
from bench.utils import log, get_cmd_output, exec_cmd
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))
if is_bench_sudoers_set:
exec_cmd("sudo bench setup supervisor --yes")
exec_cmd("sudo bench setup sudoers")