UNPKG

6.31 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# Node.js
20
21echo 'Installing Node.js'
22
23cd ~
24
25curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
26export NVM_DIR="$HOME/.nvm"
27[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
28nvm install 6
29
30#make Node.js available to sudo
31
32sudo ln -s /usr/local/bin/node /usr/bin/node
33sudo ln -s /usr/local/lib/node /usr/lib/node
34sudo ln -s /usr/local/bin/npm /usr/bin/npm
35sudo ln -s /usr/local/bin/node-waf /usr/bin/node-waf
36n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local
37
38# QEWD
39
40cd ~
41mkdir qewd
42cd qewd
43
44# Install qewd-ripple (and its dependencies)
45
46cd ~/qewd
47npm install qewd-ripple ewd-client
48npm install tcp-netx
49npm install ewd-redis-globals
50sudo npm install -g pm2
51
52
53echo 'Moving qewd-ripple and QEWD files into place'
54
55mv ~/qewd/node_modules/qewd-ripple/example/ripple-demo-redis.js ~/qewd/ripple-demo.js
56mv ~/qewd/node_modules/qewd-ripple/example/ripple-secure-redis.js ~/qewd/ripple-secure.js
57
58cd ~/qewd
59mkdir www
60cd www
61mkdir qewd-monitor
62mkdir qewd-content-store
63
64cp ~/qewd/node_modules/qewd-monitor/www/bundle.js ~/qewd/www/qewd-monitor
65cp ~/qewd/node_modules/qewd-monitor/www/*.html ~/qewd/www/qewd-monitor
66cp ~/qewd/node_modules/qewd-monitor/www/*.css ~/qewd/www/qewd-monitor
67
68cp ~/qewd/node_modules/qewd-content-store/www/bundle.js ~/qewd/www/qewd-content-store
69cp ~/qewd/node_modules/qewd-content-store/www/*.html ~/qewd/www/qewd-content-store
70
71cp ~/qewd/node_modules/ewd-client/lib/proto/ewd-client.js ~/qewd/www/ewd-client.js
72
73echo "QEWD / Node.js middle tier is now installed"
74
75echo "-----------------------------------------------------------------------"
76echo " Installing Redis..."
77echo "-----------------------------------------------------------------------"
78
79cd ~
80wget http://download.redis.io/redis-stable.tar.gz
81tar xvzf redis-stable.tar.gz
82
83# rename the created redis directory to just redis
84
85mv redis-stable redis
86cd redis
87
88# build Redis
89
90echo "Building Redis - be patient, this will take a few minutes"
91
92make
93sudo make install
94
95echo "----------------------------------------------------------------------------------"
96echo " Redis Server now being started"
97echo " Hit Enter to accept the default settings in the questions that follow... "
98echo "----------------------------------------------------------------------------------"
99
100cd utils
101sudo ./install_server.sh
102
103echo "Redis is now installed and running, listening on port 6379"
104
105cd ~/qewd
106
107echo "-----------------------------------------------------------------------"
108echo " Installing MySQL Server..."
109echo "-----------------------------------------------------------------------"
110
111# Set default MySQL password to get rid of the prompt during install
112sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password password'
113sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password password'
114
115# Install MySQL packages
116sudo apt-get install -y mysql-server
117sudo service mysql start
118
119# Get the database scripts
120cd ~
121
122wget https://raw.githubusercontent.com/RippleOSI/Org-Ripple-Middleware/develop/ripple-database/src/main/resources/sql/legacy/create_database_and_tables.sql
123wget https://raw.githubusercontent.com/RippleOSI/Org-Ripple-Middleware/develop/ripple-database/src/main/resources/sql/legacy/populate_general_practitioners_table.sql
124wget https://raw.githubusercontent.com/RippleOSI/Org-Ripple-Middleware/develop/ripple-database/src/main/resources/sql/legacy/populate_medical_departments_table.sql
125wget https://raw.githubusercontent.com/RippleOSI/Org-Ripple-Middleware/develop/ripple-database/src/main/resources/sql/legacy/populate_patients_table.sql
126
127# Run the scripts
128mysql -u root -ppassword < ~/create_database_and_tables.sql
129mysql -u root -ppassword < ~/populate_general_practitioners_table.sql
130mysql -u root -ppassword < ~/populate_medical_departments_table.sql
131mysql -u root -ppassword < ~/populate_patients_table.sql
132
133# Delete scripts
134sudo rm ~/create_database_and_tables.sql
135sudo rm ~/populate_general_practitioners_table.sql
136sudo rm ~/populate_medical_departments_table.sql
137sudo rm ~/populate_patients_table.sql
138
139echo "-----------------------------------------------------------------------"
140echo " MySQL environment and data set up"
141echo "-----------------------------------------------------------------------"
142
143
144echo "-----------------------------------------------------------------------"
145echo " Initialising deployment environment..."
146echo "-----------------------------------------------------------------------"
147
148# Retrieve the UI code
149cd ~
150
151wget -O ripple_ui.zip https://github.com/PulseTile/PulseTile/blob/master/build/ripple-latest.zip?raw=true
152
153# Unpack the UI
154
155unzip ripple_ui.zip
156
157# move it into place
158
159mv -v ~/dist/* ~/qewd/www/
160
161# Map port 80 to port 3000
162
163sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
164
165echo "----------------------------------------------------------------------------------"
166echo " Port 80 will be permanently mapped to port 3000"
167echo " Answer Yes to all questions that follow to make this happen... "
168echo "----------------------------------------------------------------------------------"
169
170sudo apt-get install iptables-persistent
171
172echo "----------------------------------------------------------------------------------"
173echo " The set up of the QEWD Ripple Middle Tier on your Ubuntu server is now complete!"
174echo " Startup template files (ripple-demo.js and ripple-secure.js "
175echo " are in the ~/qewd directory. Add the appropriate Auth0 credentials "
176echo "----------------------------------------------------------------------------------"
177
178cd ~/qewd
179