UNPKG

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