UNPKG

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