UNPKG

9.56 kBapplication/x-shView Raw
1#!/usr/bin/env bash
2
3# run using: source install_ripple.sh
4
5# Acknowledgement: Wladimir Mutel for NodeM configuration logic
6# KS Bhaskar for GT.M installation logic
7
8# run as normal user, eg ubuntu
9
10# 20 June 2017
11
12# Prepare
13
14echo 'Preparing environment'
15
16sudo apt-get update
17sudo apt-get install -y build-essential libssl-dev libelf1 dos2unix
18sudo apt-get install -y wget gzip openssh-server curl python-minimal unzip
19
20# YottaDB
21
22echo 'Installing YottaDB'
23
24mkdir /tmp/tmp # Create a temporary directory for the installer
25cd /tmp/tmp # and change to it. Next command is to download the YottaDB installer
26wget wget https://raw.githubusercontent.com/YottaDB/YottaDB/master/sr_unix/ydbinstall.sh -O gtminstall
27chmod +x gtminstall # Make the file executable
28
29gtmroot=/usr/lib/yottadb
30gtmcurrent=$gtmroot/current
31if [ -e "$gtmcurrent"] ; then
32 mv -v $gtmcurrent $gtmroot/previous_`date -u +%Y-%m-%d:%H:%M:%S`
33fi
34sudo mkdir -p $gtmcurrent # make sure directory exists for links to current YottaDB
35sudo -E ./gtminstall --utf8 default --verbose --linkenv $gtmcurrent --linkexec $gtmcurrent
36echo 'Configuring YottaDB'
37
38gtmprof=$gtmcurrent/gtmprofile
39gtmprofcmd="source $gtmprof"
40$gtmprofcmd
41tmpfile=`mktemp`
42if [ `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
45fi
46
47echo 'copying ' $gtmprofcmd ' to profile...'
48echo $gtmprofcmd >> ~/.profile
49
50rm $tmpfile
51unset tmpfile gtmprofcmd gtmprof gtmcurrent gtmroot
52
53echo 'YottaDB has been installed and configured, ready for use'
54
55# Node.js
56
57echo 'Installing Node.js'
58
59cd ~
60
61curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
62export NVM_DIR="$HOME/.nvm"
63[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
64nvm install 6
65
66#make Node.js available to sudo
67
68sudo ln -s /usr/local/bin/node /usr/bin/node
69sudo ln -s /usr/local/lib/node /usr/lib/node
70sudo ln -s /usr/local/bin/npm /usr/bin/npm
71sudo ln -s /usr/local/bin/node-waf /usr/bin/node-waf
72n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local
73
74# QEWD
75
76echo 'Installing NodeM'
77
78cd ~
79mkdir qewd
80cd qewd
81
82# NodeM
83
84echo 'Installing NodeM'
85
86npm install nodem
87sudo ln -sf $gtm_dist/libgtmshr.so /usr/local/lib/
88sudo ldconfig
89base=~/qewd
90[ -f "$GTMCI" ] || export GTMCI="$(find $base -iname nodem.ci)"
91nodemgtmr="$(find $base -iname v4wnode.m | tail -n1 | xargs dirname)"
92echo "$gtmroutines" | fgrep "$nodemgtmr" || export gtmroutines="$nodemgtmr $gtmroutines"
93
94echo 'base=~/qewd' >> ~/.profile
95echo '[ -f "$GTMCI" ] || export GTMCI="$(find $base -iname nodem.ci)"' >> ~/.profile
96echo 'nodemgtmr="$(find $base -iname v4wnode.m | tail -n1 | xargs dirname)"' >> ~/.profile
97echo 'echo "$gtmroutines" | fgrep "$nodemgtmr" || export gtmroutines="$nodemgtmr $gtmroutines"' >> ~/.profile
98
99
100# Install qewd-ripple (and its dependencies)
101
102cd ~/qewd
103npm install qewd-ripple ewd-client
104sudo npm install -g pm2
105
106
107echo 'Moving qewd-ripple and QEWD files into place'
108
109mv ~/qewd/node_modules/qewd-ripple/example/ripple-demo.js ~/qewd/ripple-demo.js
110mv ~/qewd/node_modules/qewd-ripple/example/ripple-secure.js ~/qewd/ripple-secure.js
111
112cd ~/qewd
113mkdir www
114cd www
115mkdir qewd-monitor
116mkdir qewd-content-store
117
118cp ~/qewd/node_modules/qewd-monitor/www/bundle.js ~/qewd/www/qewd-monitor
119cp ~/qewd/node_modules/qewd-monitor/www/*.html ~/qewd/www/qewd-monitor
120cp ~/qewd/node_modules/qewd-monitor/www/*.css ~/qewd/www/qewd-monitor
121
122cp ~/qewd/node_modules/qewd-content-store/www/bundle.js ~/qewd/www/qewd-content-store
123cp ~/qewd/node_modules/qewd-content-store/www/*.html ~/qewd/www/qewd-content-store
124
125cp ~/qewd/node_modules/ewd-client/lib/proto/ewd-client.js ~/qewd/www/ewd-client.js
126
127# ============ WebRTC installation ========
128
129# Server
130
131cp -r ~/qewd/node_modules/qewd-ripple/webrtc/server/ ~/videochat-socket-server/
132cp -r ~/qewd/node_modules/qewd-ripple/webrtc/ssl/ ~/qewd/ssl/
133cd ~/videochat-socket-server
134npm install
135pm2 start pm2.json
136pm2 save
137
138# Client
139
140# cp -r ~/qewd/node_modules/qewd-ripple/webrtc/client/ ~/qewd/www/videochat/
141# this is copied from the client s/w repository later
142
143# TURN Server
144
145# Optional - uncomment if needed
146# You'll also need to change the turnServer definition
147# at the top of ~/qewd/www/videochat/videochat.js
148
149# cd ~/qewd/node_modules/qewd-ripple/webrtc/turn
150# echo 'deb http://http.us.debian.org/debian jessie main' | sudo tee /etc/apt/sources.list.d/coturn.list
151# gpg --keyserver pgpkeys.mit.edu --recv-key 8B48AD6246925553
152# gpg -a --export 8B48AD6246925553 | sudo apt-key add -
153# gpg --keyserver pgpkeys.mit.edu --recv-key 7638D0442B90D010
154# gpg -a --export 7638D0442B90D010 | sudo apt-key add -
155# gpg --keyserver pgpkeys.mit.edu --recv-key CBF8D6FD518E17E1
156# gpg -a --export CBF8D6FD518E17E1 | sudo apt-key add -
157# sudo apt-get update
158# sudo apt-get install coturn=4.2.1.2-1 -y
159# sudo cp -f ./turnserver.conf /etc/
160# sudo cp -f ./turnuserdb.conf /etc/
161# sudo cp -f ./coturn /etc/default
162# sudo service coturn start
163
164# ============ WebRTC installed ==========
165
166
167echo "QEWD / Node.js middle tier is now installed"
168
169cd ~/qewd
170
171
172echo "-----------------------------------------------------------------------"
173echo " Installing MySQL Server..."
174echo "-----------------------------------------------------------------------"
175
176# Set default MySQL password to get rid of the prompt during install
177sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password password'
178sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password password'
179
180# Install MySQL packages
181sudo apt-get install -y mysql-server
182sudo service mysql start
183
184# Run the database scripts
185
186cd ~
187mysql -u root -ppassword < ~/qewd/node_modules/qewd-ripple/data/create_database_and_tables.sql
188mysql -u root -ppassword < ~/qewd/node_modules/qewd-ripple/data/populate_general_practitioners_table.sql
189mysql -u root -ppassword < ~/qewd/node_modules/qewd-ripple/data/populate_medical_departments_table.sql
190mysql -u root -ppassword < ~/qewd/node_modules/qewd-ripple/data/populate_patients_table.sql
191
192echo "-----------------------------------------------------------------------"
193echo " MySQL environment and data set up"
194echo "-----------------------------------------------------------------------"
195
196
197echo "-----------------------------------------------------------------------"
198echo " Initialising deployment environment..."
199echo "-----------------------------------------------------------------------"
200
201# Retrieve the UI code
202
203# To download the version of the UI that contains only core headings, please use the following link:
204
205# https://github.com/PulseTile/PulseTile/blob/master/build/PulseTile-core-1.0.0.zip;
206
207# In case you need a previous UI build - you'll see the builds available for downloading at:
208
209# https://github.com/PulseTile/PulseTile/blob/master/build/"
210
211cd ~
212#
213# If you want the latest development version:
214# wget -O ripple_ui.zip https://github.com/PulseTile/PulseTile/blob/develop/build/PulseTile-latest.zip?raw=true
215#
216
217wget -O ripple_ui.zip https://github.com/PulseTile/PulseTile/blob/master/build/PulseTile-latest.zip?raw=true
218
219# Unpack the UI
220
221unzip ripple_ui.zip
222
223# move it into place
224
225mv -v ~/dist/* ~/qewd/www/
226
227
228# Install Swagger UI and specification
229
230cd ~/qewd/www
231mkdir swagger
232git clone https://github.com/swagger-api/swagger-ui.git
233cp ~/qewd/node_modules/qewd-ripple/swagger/index.html ~/qewd/www/swagger-ui/dist
234cp ~/qewd/node_modules/qewd-ripple/swagger/*.json ~/qewd/www/swagger
235cp ~/qewd/node_modules/qewd-ripple/swagger/createSwaggerSpec.js ~/qewd
236
237
238# Map port 80 to port 3000
239# sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
240
241# echo "----------------------------------------------------------------------------------"
242# echo " Port 80 will be permanently mapped to port 3000"
243# echo " Answer Yes to all questions that follow to make this happen... "
244# echo "----------------------------------------------------------------------------------"
245
246# sudo apt-get install iptables-persistent
247
248# ========== Install nginx Proxy, listening on ports 80 and 443 =================
249# ========== to ripple-demo and ripple-secure respectively =================
250
251# alias /var/www to the QEWD www directory
252
253sudo ln -s ~/qewd/www/ /var/www
254sudo ln -s ~/qewd/ssl/ /var/ssl
255sudo apt-get install -y nginx
256sudo cp ~/qewd/node_modules/qewd-ripple/nginx/sites-available/default /etc/nginx/sites-available/default
257sudo systemctl restart nginx
258
259cd ~/qewd
260pm2 start ripple-demo.js
261pm2 start ripple-secure.js
262
263echo "----------------------------------------------------------------------------------"
264echo " The set up of the QEWD Ripple Middle Tier on your Ubuntu server is now complete! "
265echo " Startup template files (ripple-demo.js and ripple-secure.js "
266echo " are in the ~/qewd directory. Add the appropriate Auth0 credentials "
267echo " "
268echo " ripple-demo and ripple-secure have been started in PM2 for you "
269echo "----------------------------------------------------------------------------------"
270