1 | #!/usr/bin/env bash
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | echo "-----------------------------------------------------------------------"
|
8 | echo 'Preparing environment'
|
9 | echo "-----------------------------------------------------------------------"
|
10 |
|
11 | sudo apt-get update
|
12 | sudo apt-get install -y build-essential libssl-dev
|
13 | sudo apt-get install -y wget gzip openssh-server curl python-minimal unzip
|
14 |
|
15 |
|
16 |
|
17 | echo "-----------------------------------------------------------------------"
|
18 | echo 'Installing NVM'
|
19 | echo "-----------------------------------------------------------------------"
|
20 |
|
21 | curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
|
22 |
|
23 | export NVM_DIR="$HOME/.nvm"
|
24 | [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
25 |
|
26 | command -v nvm
|
27 |
|
28 | echo "NVM installed"
|
29 |
|
30 | echo "-----------------------------------------------------------------------"
|
31 | echo 'Installing Node.js'
|
32 | echo "-----------------------------------------------------------------------"
|
33 |
|
34 | nvm install 6
|
35 |
|
36 | echo "Node.js installed:"
|
37 | node -v
|
38 |
|
39 | echo "-----------------------------------------------------------------------"
|
40 | echo 'Installing QEWD and the Ripple Middle Tier components'
|
41 | echo "-----------------------------------------------------------------------"
|
42 |
|
43 | cd ~
|
44 | mkdir qewd
|
45 | cd qewd
|
46 | npm install qewd-ripple ewd-client
|
47 | npm install tcp-netx
|
48 | npm install ewd-redis-globals
|
49 |
|
50 | echo "-----------------------------------------------------------------------"
|
51 | echo 'Moving qewd-ripple and QEWD files into place'
|
52 | echo "-----------------------------------------------------------------------"
|
53 |
|
54 | mv ~/qewd/node_modules/qewd-ripple/example/ripple-rpi.js ~/qewd/ripple-rpi.js
|
55 |
|
56 | cd ~/qewd
|
57 | mkdir www
|
58 | cd www
|
59 | mkdir qewd-monitor
|
60 | mkdir qewd-content-store
|
61 |
|
62 | cp ~/qewd/node_modules/qewd-monitor/www/bundle.js ~/qewd/www/qewd-monitor
|
63 | cp ~/qewd/node_modules/qewd-monitor/www/*.html ~/qewd/www/qewd-monitor
|
64 | cp ~/qewd/node_modules/qewd-monitor/www/*.css ~/qewd/www/qewd-monitor
|
65 |
|
66 | cp ~/qewd/node_modules/qewd-content-store/www/bundle.js ~/qewd/www/qewd-content-store
|
67 | cp ~/qewd/node_modules/qewd-content-store/www/*.html ~/qewd/www/qewd-content-store
|
68 |
|
69 | cp ~/qewd/node_modules/ewd-client/lib/proto/ewd-client.js ~/qewd/www/ewd-client.js
|
70 |
|
71 | echo "QEWD / Node.js and Ripple middle tier is now installed"
|
72 |
|
73 | echo "-----------------------------------------------------------------------"
|
74 | echo " Installing Redis..."
|
75 | echo "-----------------------------------------------------------------------"
|
76 |
|
77 | cd ~
|
78 | wget http://download.redis.io/redis-stable.tar.gz
|
79 | tar xvzf redis-stable.tar.gz
|
80 |
|
81 |
|
82 |
|
83 | mv redis-stable redis
|
84 | cd redis
|
85 |
|
86 |
|
87 |
|
88 | echo "Building Redis - be patient, this will take some time!"
|
89 |
|
90 | make
|
91 | sudo make install
|
92 | cd utils
|
93 |
|
94 | echo "----------------------------------------------------------------------------------"
|
95 | echo " Redis Server now being started"
|
96 | echo " Hit Enter to accept the default settings in the questions that follow... "
|
97 | echo "----------------------------------------------------------------------------------"
|
98 |
|
99 | sudo ./install_server.sh
|
100 |
|
101 | echo "Redis is now installed and running, listening on port 6379"
|
102 |
|
103 | cd ~/qewd
|
104 |
|
105 |
|
106 | echo "-----------------------------------------------------------------------"
|
107 | echo " Installing MySQL Server..."
|
108 | echo "-----------------------------------------------------------------------"
|
109 |
|
110 |
|
111 | sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password password'
|
112 | sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password password'
|
113 |
|
114 |
|
115 | sudo apt-get install -y mysql-server
|
116 | sudo service mysql start
|
117 |
|
118 |
|
119 | cd ~
|
120 |
|
121 | wget https://raw.githubusercontent.com/RippleOSI/Org-Ripple-Middleware/develop/ripple-database/src/main/resources/sql/legacy/create_database_and_tables.sql
|
122 | wget https://raw.githubusercontent.com/RippleOSI/Org-Ripple-Middleware/develop/ripple-database/src/main/resources/sql/legacy/populate_general_practitioners_table.sql
|
123 | wget https://raw.githubusercontent.com/RippleOSI/Org-Ripple-Middleware/develop/ripple-database/src/main/resources/sql/legacy/populate_medical_departments_table.sql
|
124 | wget https://raw.githubusercontent.com/RippleOSI/Org-Ripple-Middleware/develop/ripple-database/src/main/resources/sql/legacy/populate_patients_table.sql
|
125 |
|
126 |
|
127 | mysql -u root -ppassword < ~/create_database_and_tables.sql
|
128 | mysql -u root -ppassword < ~/populate_general_practitioners_table.sql
|
129 | mysql -u root -ppassword < ~/populate_medical_departments_table.sql
|
130 | mysql -u root -ppassword < ~/populate_patients_table.sql
|
131 |
|
132 |
|
133 | sudo rm ~/create_database_and_tables.sql
|
134 | sudo rm ~/populate_general_practitioners_table.sql
|
135 | sudo rm ~/populate_medical_departments_table.sql
|
136 | sudo rm ~/populate_patients_table.sql
|
137 |
|
138 | echo "-----------------------------------------------------------------------"
|
139 | echo " MySQL environment and data set up"
|
140 | echo "-----------------------------------------------------------------------"
|
141 |
|
142 |
|
143 | echo "-----------------------------------------------------------------------"
|
144 | echo "Fetching and installing the Ripple UI code"
|
145 | echo "-----------------------------------------------------------------------"
|
146 |
|
147 | cd ~
|
148 | wget -O ripple_ui.zip https://github.com/PulseTile/PulseTile/blob/master/build/ripple-latest.zip?raw=true
|
149 | unzip ripple_ui.zip
|
150 |
|
151 |
|
152 |
|
153 | mv -v ~/dist/* ~/qewd/www/
|
154 |
|
155 | echo "----------------------------------------------------------------------------------"
|
156 | echo " The set up of the QEWD Ripple Middle Tier on your Raspberry Pi is now complete! "
|
157 | echo " Start using: node ripple-rpi "
|
158 | echo "----------------------------------------------------------------------------------"
|
159 |
|
160 | cd ~/qewd
|
161 |
|