2
0
mirror of https://github.com/frappe/bench.git synced 2024-11-11 15:51:03 +00:00

add patch to fix perms

This commit is contained in:
Pratik Vyas 2014-11-18 17:26:37 +05:30
parent 213299e9f6
commit aff7d42717

View File

@ -23,6 +23,7 @@ import sys
import logging
import copy
import pwd
import grp
logger = logging.getLogger('bench')
@ -385,7 +386,35 @@ def _patch_mariadb_config():
repo_dir = os.path.dirname(__file__)
exec_cmd(os.path.join(repo_dir, 'patches', 'fix-mariadb.sh'), cwd=os.path.join(repo_dir, 'patches'))
@click.command('fix-perms')
def _fix_perms():
"Fix permissions if supervisor processes were run as root"
files = [
"logs/web.error.log",
"logs/web.log",
"logs/workerbeat.error.log",
"logs/workerbeat.log",
"logs/worker.error.log",
"logs/worker.log",
"config/nginx.conf",
"logs/supervisor.conf",
]
frappe_user = get_config().get('frappe_user')
if not frappe_user:
print "frappe user not set"
sys.exit(1)
for path in files:
if os.path.exists(path):
uid = pwd.getpwnam(frappe_user).pw_uid
gid = grp.getgrnam(frappe_user).gr_gid
os.chown(path, uid, gid)
exec_cmd("{bench} setup supervisor".format(bench=sys.argv[0]))
patch.add_command(_patch_mariadb_config)
patch.add_command(_fix_perms)
#Bench commands