1 | #!/usr/bin/env bash
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | echo 'Preparing environment'
|
14 |
|
15 | sudo apt-get update
|
16 | sudo apt-get install -y build-essential libssl-dev
|
17 | sudo apt-get install -y wget gzip openssh-server curl python-minimal unzip
|
18 |
|
19 |
|
20 |
|
21 | echo 'Installing GT.M'
|
22 |
|
23 | mkdir /tmp/tmp
|
24 | cd /tmp/tmp
|
25 | wget https://sourceforge.net/projects/fis-gtm/files/GT.M%20Installer/v0.13/gtminstall
|
26 | chmod +x gtminstall
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | gtmroot=/usr/lib/fis-gtm
|
33 | gtmcurrent=$gtmroot/current
|
34 | if [ -e "$gtmcurrent"] ; then
|
35 | mv -v $gtmcurrent $gtmroot/previous_`date -u +%Y-%m-%d:%H:%M:%S`
|
36 | fi
|
37 | sudo mkdir -p $gtmcurrent
|
38 | sudo -E ./gtminstall --utf8 default --verbose --linkenv $gtmcurrent --linkexec $gtmcurrent
|
39 |
|
40 |
|
41 | echo 'Configuring GT.M'
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | gtmprof=$gtmcurrent/gtmprofile
|
47 | gtmprofcmd="source $gtmprof"
|
48 | $gtmprofcmd
|
49 | tmpfile=`mktemp`
|
50 | if [ `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
|
53 | fi
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | echo 'copying ' $gtmprofcmd ' to profile...'
|
60 | echo $gtmprofcmd >> ~/.profile
|
61 |
|
62 |
|
63 |
|
64 | rm $tmpfile
|
65 | unset tmpfile gtmprofcmd gtmprof gtmcurrent gtmroot
|
66 |
|
67 | echo 'GT.M has been installed and configured, ready for use'
|
68 | echo 'Enter the GT.M shell by typing the command: gtm Exit it by typing the command H'
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 | echo 'Installing Node.js'
|
75 |
|
76 | cd ~
|
77 |
|
78 | curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
|
79 | export NVM_DIR="$HOME/.nvm"
|
80 | [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
81 | nvm install 6
|
82 |
|
83 |
|
84 |
|
85 | sudo ln -s /usr/local/bin/node /usr/bin/node
|
86 | sudo ln -s /usr/local/lib/node /usr/lib/node
|
87 | sudo ln -s /usr/local/bin/npm /usr/bin/npm
|
88 | sudo ln -s /usr/local/bin/node-waf /usr/bin/node-waf
|
89 | n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local
|
90 |
|
91 |
|
92 |
|
93 | echo 'Installing NodeM'
|
94 |
|
95 | cd ~
|
96 | mkdir qewd
|
97 | cd qewd
|
98 |
|
99 |
|
100 |
|
101 | echo 'Installing NodeM'
|
102 |
|
103 | npm install nodem
|
104 | sudo ln -sf $gtm_dist/libgtmshr.so /usr/local/lib/
|
105 | sudo ldconfig
|
106 | base=~/qewd
|
107 | [ -f "$GTMCI" ] || export GTMCI="$(find $base -iname nodem.ci)"
|
108 | nodemgtmr="$(find $base -iname v4wnode.m | tail -n1 | xargs dirname)"
|
109 | echo "$gtmroutines" | fgrep "$nodemgtmr" || export gtmroutines="$nodemgtmr $gtmroutines"
|
110 |
|
111 | echo 'base=~/qewd' >> ~/.profile
|
112 | echo '[ -f "$GTMCI" ] || export GTMCI="$(find $base -iname nodem.ci)"' >> ~/.profile
|
113 | echo 'nodemgtmr="$(find $base -iname v4wnode.m | tail -n1 | xargs dirname)"' >> ~/.profile
|
114 | echo 'echo "$gtmroutines" | fgrep "$nodemgtmr" || export gtmroutines="$nodemgtmr $gtmroutines"' >> ~/.profile
|
115 |
|
116 |
|
117 |
|
118 |
|
119 | cd ~/qewd
|
120 | npm install qewd-ripple ewd-client
|
121 | sudo npm install -g pm2
|
122 |
|
123 |
|
124 | echo 'Moving qewd-ripple and QEWD files into place'
|
125 |
|
126 | mv ~/qewd/node_modules/qewd-ripple/example/ripple-demo.js ~/qewd/ripple-demo.js
|
127 | mv ~/qewd/node_modules/qewd-ripple/example/ripple-secure.js ~/qewd/ripple-secure.js
|
128 |
|
129 | cd ~/qewd
|
130 | mkdir www
|
131 | cd www
|
132 | mkdir qewd-monitor
|
133 | mkdir qewd-content-store
|
134 |
|
135 | cp ~/qewd/node_modules/qewd-monitor/www/bundle.js ~/qewd/www/qewd-monitor
|
136 | cp ~/qewd/node_modules/qewd-monitor/www/*.html ~/qewd/www/qewd-monitor
|
137 | cp ~/qewd/node_modules/qewd-monitor/www/*.css ~/qewd/www/qewd-monitor
|
138 |
|
139 | cp ~/qewd/node_modules/qewd-content-store/www/bundle.js ~/qewd/www/qewd-content-store
|
140 | cp ~/qewd/node_modules/qewd-content-store/www/*.html ~/qewd/www/qewd-content-store
|
141 |
|
142 | cp ~/qewd/node_modules/ewd-client/lib/proto/ewd-client.js ~/qewd/www/ewd-client.js
|
143 |
|
144 | echo "QEWD / Node.js middle tier is now installed"
|
145 |
|
146 | cd ~/qewd
|
147 |
|
148 |
|
149 | echo "-----------------------------------------------------------------------"
|
150 | echo " Installing MySQL Server..."
|
151 | echo "-----------------------------------------------------------------------"
|
152 |
|
153 |
|
154 | sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password password'
|
155 | sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password password'
|
156 |
|
157 |
|
158 | sudo apt-get install -y mysql-server
|
159 | sudo service mysql start
|
160 |
|
161 |
|
162 | cd ~
|
163 |
|
164 | wget https://raw.githubusercontent.com/RippleOSI/Org-Ripple-Middleware/develop/ripple-database/src/main/resources/sql/legacy/create_database_and_tables.sql
|
165 | wget https://raw.githubusercontent.com/RippleOSI/Org-Ripple-Middleware/develop/ripple-database/src/main/resources/sql/legacy/populate_general_practitioners_table.sql
|
166 | wget https://raw.githubusercontent.com/RippleOSI/Org-Ripple-Middleware/develop/ripple-database/src/main/resources/sql/legacy/populate_medical_departments_table.sql
|
167 | wget https://raw.githubusercontent.com/RippleOSI/Org-Ripple-Middleware/develop/ripple-database/src/main/resources/sql/legacy/populate_patients_table.sql
|
168 |
|
169 |
|
170 | mysql -u root -ppassword < ~/create_database_and_tables.sql
|
171 | mysql -u root -ppassword < ~/populate_general_practitioners_table.sql
|
172 | mysql -u root -ppassword < ~/populate_medical_departments_table.sql
|
173 | mysql -u root -ppassword < ~/populate_patients_table.sql
|
174 |
|
175 |
|
176 | sudo rm ~/create_database_and_tables.sql
|
177 | sudo rm ~/populate_general_practitioners_table.sql
|
178 | sudo rm ~/populate_medical_departments_table.sql
|
179 | sudo rm ~/populate_patients_table.sql
|
180 |
|
181 | echo "-----------------------------------------------------------------------"
|
182 | echo " MySQL environment and data set up"
|
183 | echo "-----------------------------------------------------------------------"
|
184 |
|
185 |
|
186 | echo "-----------------------------------------------------------------------"
|
187 | echo " Initialising deployment environment..."
|
188 | echo "-----------------------------------------------------------------------"
|
189 |
|
190 |
|
191 | cd ~
|
192 |
|
193 | wget -O ripple_ui.zip https://github.com/PulseTile/PulseTile/blob/master/build/ripple-latest.zip?raw=true
|
194 |
|
195 |
|
196 |
|
197 | unzip ripple_ui.zip
|
198 |
|
199 |
|
200 |
|
201 | mv -v ~/dist/* ~/qewd/www/
|
202 |
|
203 |
|
204 |
|
205 | sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
|
206 |
|
207 | echo "----------------------------------------------------------------------------------"
|
208 | echo " Port 80 will be permanently mapped to port 3000"
|
209 | echo " Answer Yes to all questions that follow to make this happen... "
|
210 | echo "----------------------------------------------------------------------------------"
|
211 |
|
212 | sudo apt-get install iptables-persistent
|
213 |
|
214 | echo "----------------------------------------------------------------------------------"
|
215 | echo " The set up of the QEWD Ripple Middle Tier on your Ubuntu server is now complete!"
|
216 | echo " Startup template files (ripple-demo.js and ripple-secure.js "
|
217 | echo " are in the ~/qewd directory. Add the appropriate Auth0 credentials "
|
218 | echo "----------------------------------------------------------------------------------"
|
219 |
|
220 | cd ~/qewd
|
221 |
|