UNPKG

7.96 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
144echo "QEWD / Node.js middle tier is now installed"
145
146cd ~/qewd
147
148
149echo "-----------------------------------------------------------------------"
150echo " Installing MySQL Server..."
151echo "-----------------------------------------------------------------------"
152
153# Set default MySQL password to get rid of the prompt during install
154sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password password'
155sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password password'
156
157# Install MySQL packages
158sudo apt-get install -y mysql-server
159sudo service mysql start
160
161# Get the database scripts
162cd ~
163
164wget https://raw.githubusercontent.com/RippleOSI/Org-Ripple-Middleware/develop/ripple-database/src/main/resources/sql/legacy/create_database_and_tables.sql
165wget https://raw.githubusercontent.com/RippleOSI/Org-Ripple-Middleware/develop/ripple-database/src/main/resources/sql/legacy/populate_general_practitioners_table.sql
166wget https://raw.githubusercontent.com/RippleOSI/Org-Ripple-Middleware/develop/ripple-database/src/main/resources/sql/legacy/populate_medical_departments_table.sql
167wget https://raw.githubusercontent.com/RippleOSI/Org-Ripple-Middleware/develop/ripple-database/src/main/resources/sql/legacy/populate_patients_table.sql
168
169# Run the scripts
170mysql -u root -ppassword < ~/create_database_and_tables.sql
171mysql -u root -ppassword < ~/populate_general_practitioners_table.sql
172mysql -u root -ppassword < ~/populate_medical_departments_table.sql
173mysql -u root -ppassword < ~/populate_patients_table.sql
174
175# Delete scripts
176sudo rm ~/create_database_and_tables.sql
177sudo rm ~/populate_general_practitioners_table.sql
178sudo rm ~/populate_medical_departments_table.sql
179sudo rm ~/populate_patients_table.sql
180
181echo "-----------------------------------------------------------------------"
182echo " MySQL environment and data set up"
183echo "-----------------------------------------------------------------------"
184
185
186echo "-----------------------------------------------------------------------"
187echo " Initialising deployment environment..."
188echo "-----------------------------------------------------------------------"
189
190# Retrieve the UI code
191cd ~
192
193wget -O ripple_ui.zip https://github.com/PulseTile/PulseTile/blob/master/build/ripple-latest.zip?raw=true
194
195# Unpack the UI
196
197unzip ripple_ui.zip
198
199# move it into place
200
201mv -v ~/dist/* ~/qewd/www/
202
203# Map port 80 to port 3000
204
205sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
206
207echo "----------------------------------------------------------------------------------"
208echo " Port 80 will be permanently mapped to port 3000"
209echo " Answer Yes to all questions that follow to make this happen... "
210echo "----------------------------------------------------------------------------------"
211
212sudo apt-get install iptables-persistent
213
214echo "----------------------------------------------------------------------------------"
215echo " The set up of the QEWD Ripple Middle Tier on your Ubuntu server is now complete!"
216echo " Startup template files (ripple-demo.js and ripple-secure.js "
217echo " are in the ~/qewd directory. Add the appropriate Auth0 credentials "
218echo "----------------------------------------------------------------------------------"
219
220cd ~/qewd
221