-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpost_setup.py
More file actions
49 lines (38 loc) · 1.16 KB
/
post_setup.py
File metadata and controls
49 lines (38 loc) · 1.16 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
try:
from setuptools.command.install import install
except ImportError:
from distutils.command.install import install
import os
import shutil
class PostInstallCommand(install):
"""
Post-installation for installation mode.
"""
def run(self):
"""
Run post-installation
"""
install.run(self)
self.create_home_path()
def create_home_path(self):
"""
Create home directory with config and web files
"""
# Getting user id and group id
uid = int(os.getuid())
gid = int(os.getgid())
# sudo?
if uid == 0:
uid = int(os.environ.get('SUDO_UID'))
gid = int(os.environ.get('SUDO_GID'))
# Home directory
directory = os.path.expanduser('~') + '/.smartrcs'
# Recreating home directory
if os.path.exists(directory):
shutil.rmtree(directory)
os.mkdir(directory)
# Copy stuffs
shutil.copytree('./config', directory + '/config')
shutil.copytree('./web', directory + '/web')
# Set permissions
os.system('chown -R %d:%d %s' % (uid, gid, directory))