-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
387 lines (221 loc) · 10.3 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
#!/bin/bash
# Parameter support to specify version of the CLI to install.
export HOLLAEX_INSTALLER_VERSION_TARGET=${1:-"master"}
echo "Pulling HollaEx CLI from Github..."
curl -s https://raw.githubusercontent.com/bitholla/hollaex-cli/master/install.sh > cli_installer.sh && \
bash cli_installer.sh ${HOLLAEX_INSTALLER_VERSION_TARGET} \
rm cli_installer.sh
# Dependencies installer for Debian (Ubuntu) based Linux.
if command apt-get -v > /dev/null 2>&1; then
if ! command docker -v > /dev/null 2>&1; then
printf "\n\033[93mHollaEx CLI requires Docker to operate. Installing it now...\033[39m\n"
echo "Updating APT list"
sudo apt-get update
IS_APT_UPDATED=true
echo "Installing Docker"
if command sudo apt-get install -y docker.io; then
printf "\n\033[92mDocker has been successfully installed!\033[39m\n"
echo "Info: $(docker -v)"
echo -e "\nAdding current user to Docker usergroup"
if command sudo gpasswd -a $USER docker; then
DOCKER_USERGROUP_ADDED=true
fi
else
printf "\n\033[91mFailed to install Docker.\033[39m\n"
echo "Please review the logs and try to manually install it. - 'sudo apt-get install -y docker.io'."
exit 1;
fi
fi
if ! command docker-compose -v > /dev/null 2>&1; then
printf "\n\033[93mHollaEx CLI requires Docker-Compose to operate. Installing it now...\033[39m\n"
if [[ ! $IS_APT_UPDATED ]]; then
echo "Updating APT list"
sudo apt-get update
fi
if command sudo apt-get install -y docker-compose; then
printf "\n\033[92mDocker-Compose has been successfully installed!\033[39m\n"
echo "Info: $(docker-compose -v)"
else
printf "\n\033[91mFailed to install Docker-Compose.\033[39m\n"
echo "Please review the logs and try to manually install it. - 'sudo apt-get install -y docker-compose'."
exit 1;
fi
fi
if ! command jq --version > /dev/null 2>&1; then
printf "\n\033[93mHollaEx CLI requires jq to operate. Installing it now...\033[39m\n"
if [[ ! $IS_APT_UPDATED ]]; then
echo "Updating APT list"
sudo apt-get update
fi
if command sudo apt-get install -y jq; then
printf "\n\033[92mjq has been successfully installed!\033[39m\n"
echo "Info: $(jq --version)"
else
printf "\n\033[91mFailed to install jq.\033[39m\n"
echo "Please review the logs and try to manually install it. - 'sudo apt-get install -y jq'."
fi
fi
if ! command nslookup -version > /dev/null 2>&1; then
printf "\n\033[93mHollaEx CLI requires nslookup to operate. Installing it now...\033[39m\n"
if [[ ! $IS_APT_UPDATED ]]; then
echo "Updating APT list"
sudo apt-get update
fi
if command sudo apt-get install -y dnsutils; then
printf "\n\033[92mnslookup(dnsutils) has been successfully installed!\033[39m\n"
echo "Info: "
nslookup -version
else
printf "\n\033[91mFailed to install nslookup.\033[39m\n"
echo "Please review the logs and try to manually install it. - 'sudo apt-get install -y dnsutils'."
fi
fi
# Dependencies installer for macOS with Homebrew.
elif command brew -v > /dev/null 2>&1; then
if ! command docker -v > /dev/null 2>&1; then
echo "Updating Homebrew list"
if command brew update; then
IS_BREW_UPDATED=true
fi
echo "Automated installation for Docker on macOS is not supported."
echo "Please download 'Docker for Mac' on Official Docker website and proceed to install."
echo "Official Installation Page: (docs.docker.com/docker-for-mac/install)."
fi
if ! command docker-compose -v > /dev/null 2>&1; then
printf "\n\033[93mHollaEx CLI requires Docker-Compose to operate. Installing it now...\033[39m\n"
if [[ ! $IS_BREW_UPDATED ]]; then
echo "Updating Homebrew list"
brew update
fi
if command brew install docker-compose; then
printf "\n\033[92mDocker-Compose has been successfully installed!\033[39m\n"
echo "Info: $(docker-compose -v)"
else
printf "\n\033[91mFailed to install Docker-Compose.\033[39m\n"
echo "Please review the logs and try to manually install it. - 'brew install docker-compose'."
exit 1;
fi
fi
if ! command jq --version > /dev/null 2>&1; then
printf "\n\033[93mHollaEx CLI requires jq to operate. Installing it now...\033[39m\n"
if [[ ! $IS_BREW_UPDATED ]]; then
echo "Updating Homebrew list"
brew update
fi
if command brew install jq; then
printf "\n\033[92mjq has been successfully installed!\033[39m\n"
echo "Info: $(jq --version)"
else
printf "\n\033[91mFailed to install jq.\033[39m\n"
echo "Please review the logs and try to manually install it. - 'brew install jq'."
fi
fi
# Dependencies installer for CentOS (RHEL) with Yum.
elif command yum --version > /dev/null 2>&1; then
if ! command docker -v > /dev/null 2>&1; then
printf "\n\033[93mHollaEx CLI requires Docker to operate. Installing it now...\033[39m\n"
echo "Adding Docker-CE repository on Yum..."
sudo yum install -y yum-utils
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
echo "Installing Docker"
if command sudo yum install docker-ce docker-ce-cli containerd.io -y --nobest; then
printf "\n\033[92mDocker has been successfully installed!\033[39m\n"
echo "Info: $(docker -v)"
echo -e "\nAdding current user to Docker usergroup"
if command sudo gpasswd -a $USER docker; then
DOCKER_USERGROUP_ADDED=true
fi
systemctl start docker
systemctl enable docker
else
printf "\n\033[91mFailed to install Docker.\033[39m\n"
echo "Please review the logs and try to manually install it. - 'sudo yum install -y docker-ce docker-ce-cli containerd.io'."
exit 1;
fi
fi
if ! command docker-compose -v > /dev/null 2>&1; then
printf "\n\033[93mHollaEx CLI requires Docker-Compose to operate. Installing it now...\033[39m\n"
if command curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose; then
sudo chmod +x /usr/local/bin/docker-compose
printf "\n\033[92mDocker-Compose has been successfully installed!\033[39m\n"
echo "Info: $(docker-compose -v)"
else
printf "\n\033[91mFailed to install Docker-Compose.\033[39m\n"
echo "Please review the logs and try to manually install it. - 'https://github.com/docker/compose/releases'."
exit 1;
fi
fi
if ! command jq --version > /dev/null 2>&1; then
printf "\n\033[93mHollaEx CLI requires jq to operate. Installing it now...\033[39m\n"
if command sudo yum install -y jq; then
printf "\n\033[92mjq has been successfully installed!\033[39m\n"
echo "Info: $(jq --version)"
else
printf "\n\033[91mFailed to install jq.\033[39m\n"
echo "Please review the logs and try to manually install it. - 'sudo yum install -y jq'."
fi
fi
if ! command nslookup -version > /dev/null 2>&1; then
printf "\n\033[93mHollaEx CLI requires nslookup to operate. Installing it now...\033[39m\n"
if command sudo yum install -y bind-utils; then
printf "\n\033[92mnslookup(bind-utils) has been successfully installed!\033[39m\n"
echo "Info: "
nslookup -version
else
printf "\n\033[91mFailed to install nslookup.\033[39m\n"
echo "Please review the logs and try to manually install it. - 'sudo yum install -y bind-utils'."
fi
fi
fi
if ! command docker -v > /dev/null 2>&1 || ! command docker-compose -v > /dev/null 2>&1 || ! command jq --version > /dev/null 2>&1 || ! command nslookup -version > /dev/null 2>&1; then
if command docker -v > /dev/null 2>&1; then
IS_DOCKER_INSTALLED=true
fi
if command docker-compose -v > /dev/null 2>&1; then
IS_DOCKER_COMPOSE_INSTALLED=true
fi
if command jq --version > /dev/null 2>&1; then
IS_JQ_INSTALLED=true
fi
if command nslookup -version > /dev/null 2>&1; then
IS_NSLOOKUP_INSTALLED=true
fi
printf "\n\033[93mNote: HollaEx CLI requires Docker, Docker-Compose, and jq to operate.\033[39m\n\n"
# Docker installation status chekc
if [[ "$IS_DOCKER_INSTALLED" ]]; then
printf "\033[92mDocker: Installed\033[39m\n"
else
printf "\033[91mDocker: Not Installed\033[39m\n"
fi
# Docker-compose installation status check
if [[ "$IS_DOCKER_COMPOSE_INSTALLED" ]]; then
printf "\033[92mDocker-Compose: Installed\033[39m\n"
else
printf "\033[91mDocker-Compose: Not Installed\033[39m\n"
fi
# jq installation status check
if [[ "$IS_JQ_INSTALLED" ]]; then
printf "\033[92mjq: Installed\033[39m\n"
else
printf "\033[91mjq: Not Installed\033[39m\n"
fi
# nslookup installation status check
if [[ "$IS_NSLOOKUP_INSTALLED" ]]; then
printf "\033[92mnslookup: Installed\033[39m\n"
else
printf "\033[91mnslookup: Not Installed\033[39m\n"
fi
printf "\n\033[93mPlease install the missing one before you proceed to run exchange.\033[39m\n"
else
printf "\nYou are good to go!\n\n"
if [[ "$IS_APT_UPDATED" ]] || [[ "$IS_BREW_UPDATED" ]]; then
echo "Start configuring your exchange with the command: 'hollaex server --setup'."
printf "\nTo see the full list of commands, use 'hollaex help'.\n\n"
fi
if [[ "$DOCKER_USERGROUP_ADDED" ]]; then
newgrp docker
fi
fi
exit 0;