-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbootstrap.sh
More file actions
164 lines (121 loc) · 3.98 KB
/
bootstrap.sh
File metadata and controls
164 lines (121 loc) · 3.98 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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#Vagrant Bootstrap for Ubuntu Server
apt-get update
#Build essentials for uwsgi
apt-get install build-essential python -y
apt-get install python2.7-dev -y
#Install NGnix
apt-get install nginx -y
mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
echo 'worker_processes 1;
events {
worker_connections 1024;
}
http {
sendfile on;
gzip on;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 500;
gzip_disable "MSIE [1-6]\.";
gzip_types text/plain text/xml text/css
text/comma-separated-values
text/javascript
application/x-javascript
application/javascript
application/atom+xml
font/woff
application/font-woff
font/truetype
font/opentype
font/eot
application/vnd.ms-fontobject
image/svg+xml
image/x-icon
image/vnd.microsoft.icon;
# Configuration containing list of application servers
upstream uwsgicluster {
server 127.0.0.1:8080;
# server 0.0.0.0;
# ..
# .
}
# Configuration for Nginx
server {
# Running port
listen 80;
# Settings to by-pass for static files
location ^~ /static/ {
# Example:
# root /full/path/to/application/static/file/dir;
root /vagrant/pqr/;
include /etc/nginx/mime.types;
# Mol2 Files
location ~* \.(?:mol2)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
# CSS and Javascript
location ~* \.(?:css|js)$ {
expires 1y;
access_log off;
add_header Cache-Control "public";
}
}
# Serve a static file (ex. favico) outside static dir.
location = /favicopqr.ico {
root /pqr/favico.ico;
}
# Proxying connections to application servers
location / {
include uwsgi_params;
uwsgi_pass uwsgicluster;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
}
}
' > /etc/nginx/nginx.conf
service nginx restart
#Install MongoDB
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.0.list
apt-get update
apt-get install -y mongodb-org
service mongod start
#Get and install PIP
wget https://bootstrap.pypa.io/get-pip.py -q
python get-pip.py
rm get-pip.py
#Install virtualenv
cd /vagrant/
pip install virtualenv
virtualenv venv
# Install requirements
. venv/bin/activate
pip install -r requirements.txt
#Setup secret key file (Add check so it only runs if it isn't there)
echo "from pqr import pqr" > pqr/secret_config.py
PQR_KEY=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 128 | head -n 1)
export PQR_KEY
echo "pqr.config['SECRET_KEY'] = \"$PQR_KEY\"" >> pqr/secret_config.py
#Setup default pqr.ini
echo "[uwsgi]
socket = 127.0.0.1:8080
wsgi-file = uwsgi.py
callable = pqr
processes = 4
" > pqr.ini
#Get some data for the JSON files
#Build the inital database
# python scripts/clear_db.py
# python