-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmanage.py
executable file
·27 lines (21 loc) · 963 Bytes
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python
from __future__ import absolute_import, division, generators, nested_scopes, print_function, unicode_literals, with_statement
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dbs.settings")
if os.getuid() == 0 and 'collectstatic' not in sys.argv:
from django.conf import settings
import pwd, grp
user = pwd.getpwnam(getattr(settings, 'USERNAME', 'dbs'))
groups = [g.gr_gid for g in grp.getgrall() if user.pw_name in g.gr_mem]
os.setgid(user.pw_gid)
os.setgroups(groups)
os.setuid(user.pw_uid)
os.environ['USER'] = user.pw_name
os.environ['LOGNAME'] = user.pw_name
os.environ['HOME'] = user.pw_dir
os.environ['SHELL'] = user.pw_shell
os.chdir(os.environ['HOME'])
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)