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