mirror of
https://github.com/frappe/bench.git
synced 2025-01-10 00:37:51 +00:00
add fix-file-perms
This commit is contained in:
parent
5fc81d0a3e
commit
ac9b2bcf63
18
bench/cli.py
18
bench/cli.py
@ -13,7 +13,7 @@ from .utils import set_default_site as _set_default_site
|
|||||||
from .utils import (build_assets, patch_sites, exec_cmd, update_bench, get_frappe, setup_logging,
|
from .utils import (build_assets, patch_sites, exec_cmd, update_bench, get_frappe, setup_logging,
|
||||||
get_config, update_config, restart_supervisor_processes, put_config, default_config, update_requirements,
|
get_config, update_config, restart_supervisor_processes, put_config, default_config, update_requirements,
|
||||||
backup_all_sites, backup_site, get_sites, prime_wheel_cache, is_root, set_mariadb_host, drop_privileges,
|
backup_all_sites, backup_site, get_sites, prime_wheel_cache, is_root, set_mariadb_host, drop_privileges,
|
||||||
fix_file_perms, set_ssl_certificate, set_ssl_certificate_key)
|
fix_file_perms, fix_prod_setup_perms, set_ssl_certificate, set_ssl_certificate_key)
|
||||||
from .app import get_app as _get_app
|
from .app import get_app as _get_app
|
||||||
from .app import new_app as _new_app
|
from .app import new_app as _new_app
|
||||||
from .app import pull_all_apps
|
from .app import pull_all_apps
|
||||||
@ -59,6 +59,8 @@ def change_uid():
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def change_dir():
|
def change_dir():
|
||||||
|
if os.path.exists('config.json'):
|
||||||
|
return
|
||||||
dir_path_file = '/etc/frappe_bench_dir'
|
dir_path_file = '/etc/frappe_bench_dir'
|
||||||
if os.path.exists(dir_path_file):
|
if os.path.exists(dir_path_file):
|
||||||
with open(dir_path_file) as f:
|
with open(dir_path_file) as f:
|
||||||
@ -410,20 +412,26 @@ config.add_command(config_http_timeout)
|
|||||||
def patch():
|
def patch():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@click.command('fix-perms')
|
@click.command('fix-prod-perms')
|
||||||
def _fix_perms():
|
def _fix_prod_perms():
|
||||||
"Fix permissions if supervisor processes were run as root"
|
"Fix permissions if supervisor processes were run as root"
|
||||||
if os.path.exists("config/supervisor.conf"):
|
if os.path.exists("config/supervisor.conf"):
|
||||||
exec_cmd("supervisorctl stop frappe:")
|
exec_cmd("supervisorctl stop frappe:")
|
||||||
|
|
||||||
fix_file_perms()
|
fix_prod_setup_perms()
|
||||||
|
|
||||||
if os.path.exists("config/supervisor.conf"):
|
if os.path.exists("config/supervisor.conf"):
|
||||||
exec_cmd("{bench} setup supervisor".format(bench=sys.argv[0]))
|
exec_cmd("{bench} setup supervisor".format(bench=sys.argv[0]))
|
||||||
exec_cmd("supervisorctl reload")
|
exec_cmd("supervisorctl reload")
|
||||||
|
|
||||||
|
|
||||||
patch.add_command(_fix_perms)
|
@click.command('fix-file-perms')
|
||||||
|
def _fix_file_perms():
|
||||||
|
"Fix file permissions"
|
||||||
|
fix_file_perms()
|
||||||
|
|
||||||
|
patch.add_command(_fix_file_perms)
|
||||||
|
patch.add_command(_fix_prod_perms)
|
||||||
|
|
||||||
#Bench commands
|
#Bench commands
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ def drop_privileges(uid_name='nobody', gid_name='nogroup'):
|
|||||||
# Ensure a very conservative umask
|
# Ensure a very conservative umask
|
||||||
old_umask = os.umask(022)
|
old_umask = os.umask(022)
|
||||||
|
|
||||||
def fix_file_perms(frappe_user=None):
|
def fix_prod_setup_perms(frappe_user=None):
|
||||||
files = [
|
files = [
|
||||||
"logs/web.error.log",
|
"logs/web.error.log",
|
||||||
"logs/web.log",
|
"logs/web.log",
|
||||||
@ -354,3 +354,10 @@ def fix_file_perms(frappe_user=None):
|
|||||||
uid = pwd.getpwnam(frappe_user).pw_uid
|
uid = pwd.getpwnam(frappe_user).pw_uid
|
||||||
gid = grp.getgrnam(frappe_user).gr_gid
|
gid = grp.getgrnam(frappe_user).gr_gid
|
||||||
os.chown(path, uid, gid)
|
os.chown(path, uid, gid)
|
||||||
|
|
||||||
|
def fix_file_perms():
|
||||||
|
for dir_path, dirs, files in os.walk('.'):
|
||||||
|
for _dir in dirs:
|
||||||
|
os.chmod(os.path.join(dir_path, _dir), 0755)
|
||||||
|
for _file in files:
|
||||||
|
os.chmod(os.path.join(dir_path, _file), 0644)
|
||||||
|
Loading…
Reference in New Issue
Block a user