1 | #!/usr/bin/env bash
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | echo 'Preparing environment'
|
15 |
|
16 | sudo apt-get update
|
17 | sudo apt-get install -y build-essential libssl-dev libelf1 dos2unix
|
18 | sudo apt-get install -y wget gzip openssh-server curl python-minimal unzip
|
19 |
|
20 |
|
21 |
|
22 | echo 'Installing YottaDB'
|
23 |
|
24 | mkdir /tmp/tmp
|
25 | cd /tmp/tmp
|
26 | wget wget https://raw.githubusercontent.com/YottaDB/YottaDB/master/sr_unix/ydbinstall.sh -O gtminstall
|
27 | chmod +x gtminstall
|
28 |
|
29 | gtmroot=/usr/lib/yottadb
|
30 | gtmcurrent=$gtmroot/current
|
31 | if [ -e "$gtmcurrent"] ; then
|
32 | mv -v $gtmcurrent $gtmroot/previous_`date -u +%Y-%m-%d:%H:%M:%S`
|
33 | fi
|
34 | sudo mkdir -p $gtmcurrent
|
35 | sudo -E ./gtminstall --utf8 default --verbose --linkenv $gtmcurrent --linkexec $gtmcurrent
|
36 | echo 'Configuring YottaDB'
|
37 |
|
38 | gtmprof=$gtmcurrent/gtmprofile
|
39 | gtmprofcmd="source $gtmprof"
|
40 | $gtmprofcmd
|
41 | tmpfile=`mktemp`
|
42 | if [ `grep -v "$gtmprofcmd" ~/.profile | grep $gtmroot >$tmpfile`] ; then
|
43 | echo "Warning: existing commands referencing $gtmroot in ~/.profile may interfere with setting up environment"
|
44 | cat $tmpfile
|
45 | fi
|
46 |
|
47 | echo 'copying ' $gtmprofcmd ' to profile...'
|
48 | echo $gtmprofcmd >> ~/.profile
|
49 |
|
50 | rm $tmpfile
|
51 | unset tmpfile gtmprofcmd gtmprof gtmcurrent gtmroot
|
52 |
|
53 | echo 'YottaDB has been installed and configured, ready for use'
|
54 |
|
55 |
|
56 |
|
57 | echo 'Installing Node.js'
|
58 |
|
59 | cd ~
|
60 |
|
61 | curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
|
62 | export NVM_DIR="$HOME/.nvm"
|
63 | [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
64 | nvm install 6
|
65 |
|
66 |
|
67 |
|
68 | sudo ln -s /usr/local/bin/node /usr/bin/node
|
69 | sudo ln -s /usr/local/lib/node /usr/lib/node
|
70 | sudo ln -s /usr/local/bin/npm /usr/bin/npm
|
71 | sudo ln -s /usr/local/bin/node-waf /usr/bin/node-waf
|
72 | n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local
|
73 |
|
74 |
|
75 |
|
76 | echo 'Installing NodeM'
|
77 |
|
78 | cd ~
|
79 | mkdir qewd
|
80 | cd qewd
|
81 |
|
82 |
|
83 |
|
84 | echo 'Installing NodeM'
|
85 |
|
86 | npm install nodem
|
87 | sudo ln -sf $gtm_dist/libgtmshr.so /usr/local/lib/
|
88 | sudo ldconfig
|
89 | base=~/qewd
|
90 | [ -f "$GTMCI" ] || export GTMCI="$(find $base -iname nodem.ci)"
|
91 | nodemgtmr="$(find $base -iname v4wnode.m | tail -n1 | xargs dirname)"
|
92 | echo "$gtmroutines" | fgrep "$nodemgtmr" || export gtmroutines="$nodemgtmr $gtmroutines"
|
93 |
|
94 | echo 'base=~/qewd' >> ~/.profile
|
95 | echo '[ -f "$GTMCI" ] || export GTMCI="$(find $base -iname nodem.ci)"' >> ~/.profile
|
96 | echo 'nodemgtmr="$(find $base -iname v4wnode.m | tail -n1 | xargs dirname)"' >> ~/.profile
|
97 | echo 'echo "$gtmroutines" | fgrep "$nodemgtmr" || export gtmroutines="$nodemgtmr $gtmroutines"' >> ~/.profile
|
98 |
|
99 |
|
100 |
|
101 |
|
102 | cd ~/qewd
|
103 | npm install qewd-ripple ewd-client
|
104 | sudo npm install -g pm2
|
105 |
|
106 |
|
107 | echo 'Moving qewd-ripple and QEWD files into place'
|
108 |
|
109 | mv ~/qewd/node_modules/qewd-ripple/example/ripple-demo.js ~/qewd/ripple-demo.js
|
110 | mv ~/qewd/node_modules/qewd-ripple/example/ripple-secure.js ~/qewd/ripple-secure.js
|
111 |
|
112 | cd ~/qewd
|
113 | mkdir www
|
114 | cd www
|
115 | mkdir qewd-monitor
|
116 | mkdir qewd-content-store
|
117 |
|
118 | cp ~/qewd/node_modules/qewd-monitor/www/bundle.js ~/qewd/www/qewd-monitor
|
119 | cp ~/qewd/node_modules/qewd-monitor/www/*.html ~/qewd/www/qewd-monitor
|
120 | cp ~/qewd/node_modules/qewd-monitor/www/*.css ~/qewd/www/qewd-monitor
|
121 |
|
122 | cp ~/qewd/node_modules/qewd-content-store/www/bundle.js ~/qewd/www/qewd-content-store
|
123 | cp ~/qewd/node_modules/qewd-content-store/www/*.html ~/qewd/www/qewd-content-store
|
124 |
|
125 | cp ~/qewd/node_modules/ewd-client/lib/proto/ewd-client.js ~/qewd/www/ewd-client.js
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 | cp -r ~/qewd/node_modules/qewd-ripple/webrtc/server/ ~/videochat-socket-server/
|
132 | cp -r ~/qewd/node_modules/qewd-ripple/webrtc/ssl/ ~/qewd/ssl/
|
133 | cd ~/videochat-socket-server
|
134 | npm install
|
135 | pm2 start pm2.json
|
136 | pm2 save
|
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 |
|
165 |
|
166 |
|
167 | echo "QEWD / Node.js middle tier is now installed"
|
168 |
|
169 | cd ~/qewd
|
170 |
|
171 |
|
172 | echo "-----------------------------------------------------------------------"
|
173 | echo " Installing MySQL Server..."
|
174 | echo "-----------------------------------------------------------------------"
|
175 |
|
176 |
|
177 | sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password password'
|
178 | sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password password'
|
179 |
|
180 |
|
181 | sudo apt-get install -y mysql-server
|
182 | sudo service mysql start
|
183 |
|
184 |
|
185 |
|
186 | cd ~
|
187 | mysql -u root -ppassword < ~/qewd/node_modules/qewd-ripple/data/create_database_and_tables.sql
|
188 | mysql -u root -ppassword < ~/qewd/node_modules/qewd-ripple/data/populate_general_practitioners_table.sql
|
189 | mysql -u root -ppassword < ~/qewd/node_modules/qewd-ripple/data/populate_medical_departments_table.sql
|
190 | mysql -u root -ppassword < ~/qewd/node_modules/qewd-ripple/data/populate_patients_table.sql
|
191 |
|
192 | echo "-----------------------------------------------------------------------"
|
193 | echo " MySQL environment and data set up"
|
194 | echo "-----------------------------------------------------------------------"
|
195 |
|
196 |
|
197 | echo "-----------------------------------------------------------------------"
|
198 | echo " Initialising deployment environment..."
|
199 | echo "-----------------------------------------------------------------------"
|
200 |
|
201 |
|
202 |
|
203 |
|
204 |
|
205 |
|
206 |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 | cd ~
|
212 |
|
213 |
|
214 |
|
215 |
|
216 |
|
217 | wget -O ripple_ui.zip https://github.com/PulseTile/PulseTile/blob/master/build/PulseTile-latest.zip?raw=true
|
218 |
|
219 |
|
220 |
|
221 | unzip ripple_ui.zip
|
222 |
|
223 |
|
224 |
|
225 | mv -v ~/dist/* ~/qewd/www/
|
226 |
|
227 |
|
228 |
|
229 |
|
230 | cd ~/qewd/www
|
231 | mkdir swagger
|
232 | git clone https://github.com/swagger-api/swagger-ui.git
|
233 | cp ~/qewd/node_modules/qewd-ripple/swagger/index.html ~/qewd/www/swagger-ui/dist
|
234 | cp ~/qewd/node_modules/qewd-ripple/swagger/*.json ~/qewd/www/swagger
|
235 | cp ~/qewd/node_modules/qewd-ripple/swagger/createSwaggerSpec.js ~/qewd
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 | sudo ln -s ~/qewd/www/ /var/www
|
254 | sudo ln -s ~/qewd/ssl/ /var/ssl
|
255 | sudo apt-get install -y nginx
|
256 | sudo cp ~/qewd/node_modules/qewd-ripple/nginx/sites-available/default /etc/nginx/sites-available/default
|
257 | sudo systemctl restart nginx
|
258 |
|
259 | cd ~/qewd
|
260 | pm2 start ripple-demo.js
|
261 | pm2 start ripple-secure.js
|
262 |
|
263 | echo "----------------------------------------------------------------------------------"
|
264 | echo " The set up of the QEWD Ripple Middle Tier on your Ubuntu server is now complete! "
|
265 | echo " Startup template files (ripple-demo.js and ripple-secure.js "
|
266 | echo " are in the ~/qewd directory. Add the appropriate Auth0 credentials "
|
267 | echo " "
|
268 | echo " ripple-demo and ripple-secure have been started in PM2 for you "
|
269 | echo "----------------------------------------------------------------------------------"
|
270 |
|