mirror of
https://github.com/frappe/bench.git
synced 2024-11-12 00:06:36 +00:00
fix: update supervisord and sudoers for old benches
This commit is contained in:
parent
48f70aca65
commit
e12208dc25
@ -8,6 +8,7 @@ from bench.commands import bench_command
|
|||||||
|
|
||||||
logger = logging.getLogger('bench')
|
logger = logging.getLogger('bench')
|
||||||
from_command_line = False
|
from_command_line = False
|
||||||
|
change_uid_msg = "You should not run this command as root"
|
||||||
|
|
||||||
def cli():
|
def cli():
|
||||||
global from_command_line
|
global from_command_line
|
||||||
@ -72,7 +73,7 @@ def change_uid():
|
|||||||
drop_privileges(uid_name=frappe_user, gid_name=frappe_user)
|
drop_privileges(uid_name=frappe_user, gid_name=frappe_user)
|
||||||
os.environ['HOME'] = pwd.getpwnam(frappe_user).pw_dir
|
os.environ['HOME'] = pwd.getpwnam(frappe_user).pw_dir
|
||||||
else:
|
else:
|
||||||
log('You should not run this command as root', level=3)
|
log(change_uid_msg, level=3)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def old_frappe_cli(bench_path='.'):
|
def old_frappe_cli(bench_path='.'):
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
# This file is auto-generated by frappe/bench
|
||||||
|
# To re-generate this file, run "bench setup sudoers"
|
||||||
|
|
||||||
{% if service %}
|
{% if service %}
|
||||||
{{ user }} ALL = (root) {{ service }}
|
{{ user }} ALL = (root) {{ service }}
|
||||||
{{ user }} ALL = (root) NOPASSWD: {{ service }} nginx *
|
{{ user }} ALL = (root) NOPASSWD: {{ service }} nginx *
|
||||||
@ -14,3 +17,4 @@
|
|||||||
|
|
||||||
{{ user }} ALL = (root) NOPASSWD: /opt/certbot-auto
|
{{ user }} ALL = (root) NOPASSWD: /opt/certbot-auto
|
||||||
Defaults:{{ user }} !requiretty
|
Defaults:{{ user }} !requiretty
|
||||||
|
|
||||||
|
@ -4,3 +4,4 @@ bench.patches.v3.redis_bind_ip
|
|||||||
bench.patches.v4.update_node
|
bench.patches.v4.update_node
|
||||||
bench.patches.v4.update_socketio
|
bench.patches.v4.update_socketio
|
||||||
bench.patches.v4.install_yarn #2
|
bench.patches.v4.install_yarn #2
|
||||||
|
bench.patches.v5.fix_user_permissions
|
||||||
|
0
bench/patches/v5/__init__.py
Normal file
0
bench/patches/v5/__init__.py
Normal file
17
bench/patches/v5/fix_user_permissions.py
Normal file
17
bench/patches/v5/fix_user_permissions.py
Normal 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")
|
Loading…
Reference in New Issue
Block a user