-
Notifications
You must be signed in to change notification settings - Fork 10
/
dev_install.py
executable file
·77 lines (56 loc) · 2.15 KB
/
dev_install.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python
import os
import shutil
import sys
os.chdir(os.path.abspath(os.path.dirname(__file__)))
def preamble():
basepath = os.path.abspath(os.path.dirname(__file__))
config = os.path.join(basepath, 'nsti', 'etc', 'nsti.cfg')
print """
Today we will be running the devel install for NSTI.
Here is the deal:
- Wherever the NSTI folder is RIGHT now, is where
this installer will configure it to work
- Before continuing ensure that the config file at:
%s
Has the proper information. Meaning the user, database
and password should already exist.
- All information in this database will be destroyed.
Deal? """ % config
y = raw_input('[y|n] ')
if y.lower() != 'y':
print 'Exiting on user request...'
sys.exit(1)
def apply_sql():
from nsti import app
mysql_string = 'mysql -u%s -p"%s" %s < nsti/dist/nsti.sql' % ( app.config.get('DB_USER'),
app.config.get('DB_PASS'),
app.config.get('DB_NAME'))
retcode = os.system(mysql_string)
if retcode != 0:
print 'Whoa...bad error code! I tried to run:'
print mysql_string
sys.exit(1)
def apply_apache():
basename = os.path.abspath(os.path.dirname(__file__))
os.system('yum install mod_wsgi')
apache = open(os.path.join(basename, 'nsti', 'dist', 'apache.conf'), 'r')
target = open('/etc/httpd/conf.d/flnsti.conf', 'w')
for l in apache.readlines():
if 'WSGI' in l:
target.write('WSGIScriptAlias /nsti %s\n' % os.path.join(basename, 'wsgi.py'))
elif '/usr/local/nsti' in l:
target.write('<Directory %s>\n' % basename)
else:
target.write(l)
os.system('service httpd restart')
def check_python_prereqs():
ret = os.system('pip install -r nsti/dist/requirements.txt')
if ret != 0:
print 'Oh no! Could not install Python modules.'
sys.exit(1)
if __name__ == '__main__':
preamble()
apply_sql()
apply_apache()
check_python_prereqs()