-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·131 lines (105 loc) · 4.01 KB
/
bootstrap.sh
File metadata and controls
executable file
·131 lines (105 loc) · 4.01 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
#!/usr/bin/env bash
# This section contains arguments specific to the new instance we are starting
dev_host="192.168.56.1"
siteserver_port="3005"
setupshop_port="3006"
tutorialserver_port="3007"
mongodb_port="27017"
start_time="$(date +%s)"
# Step 1. Start MongoDB (script copied from ../mongodb/localhost/bootstrap.sh. TODO: should generate this script)
#!/usr/bin/env bash
# Import the 10gen public GPG Key
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
# Create a /etc/apt/sources.list.d/10gen.list file
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | tee /etc/apt/sources.list.d/10gen.list
# Reload the repository
apt-get update
# Install the latest stable version of MongoDB
apt-get install mongodb-10gen
# Try to repair MongoDB in case we're recovering from an abrupt shutdown or crash
sudo -u mongodb mongod --repair --dbpath /var/lib/mongodb/
sudo service mongodb start
# Step 2. Start Dispatch server
apt-get update
# load the run-time prereqs
apt-get install -y nginx
echo "apt-get installed nginx"
# create the ngnx config file
echo "
server {
listen 80;
error_log /var/log/nginx/error.log;
sendfile off;
# tutorial static files
location ~ ^/(clientlib|tutorial)/ {
proxy_pass http://$dev_host:$tutorialserver_port;
}
# tutorial micro-app
location ~ ^/tt($|_tracking|_history|/) {
set \$h \$http_host;
if (\$http_ce_resource_host) {
set \$h \$http_ce_resource_host;
}
proxy_set_header CE-Resource-Host \$h;
proxy_pass http://$dev_host:$tutorialserver_port;
}
# siteserver (hostingsite) static files
location ~ ^/site(design|server)/ {
proxy_pass http://$dev_host:$siteserver_port;
}
# ac micro-app
location ~ ^/ac(|-permissions|-resource-groups)($|/) {
set \$h \$http_host;
if (\$http_ce_resource_host) {
set \$h \$http_ce_resource_host;
}
proxy_set_header CE-Resource-Host \$h;
proxy_pass http://$dev_host:$siteserver_port;
}
# account micro-app
location ~ ^/account($|/) {
set \$h \$http_host;
if (\$http_ce_resource_host) {
set \$h \$http_ce_resource_host;
}
proxy_set_header CE-Resource-Host \$h;
proxy_pass http://$dev_host:$siteserver_port;
}
# mt micro-app
location ~ ^/($|mt) {
set \$h \$http_host;
if (\$http_ce_resource_host) {
set \$h \$http_ce_resource_host;
}
proxy_set_header CE-Resource-Host \$h;
proxy_pass http://$dev_host:$siteserver_port;
}
# setupshop static files
location ~ ^/setupshop/ {
proxy_pass http://$dev_host:$setupshop_port;
}
# cat micro-app
location ~ ^/cat($|_tracking|_history|/) {
set \$h \$http_host;
if (\$http_ce_resource_host) {
set \$h \$http_ce_resource_host;
}
proxy_set_header CE-Resource-Host \$h;
proxy_pass http://$dev_host:$setupshop_port;
}
# cart micro-app
location ~ ^/cart($|_tracking|_history|/) {
set \$h \$http_host;
if (\$http_ce_resource_host) {
set \$h \$http_ce_resource_host;
}
proxy_set_header CE-Resource-Host \$h;
proxy_pass http://$dev_host:$setupshop_port;
}
}" > /etc/nginx/conf.d/dispatcher.conf
echo "created /etc/nginx/conf.d/dispatcher.conf"
rm -f /etc/nginx/sites-enabled/default
# (re)start the nginx service
service nginx restart
elapsed_time="$(($(date +%s)-start_time))"
echo "elapsed time: ${elapsed_time} seconds"