forked from hollaex/hollaex-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
586 lines (333 loc) · 15.4 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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
#!/bin/bash
# Dependencies installer for Debian (Ubuntu) based Linux.
if command apt-get -v > /dev/null 2>&1; then
if ! command curl --version > /dev/null 2>&1; then
printf "\n\033[93mHollaEx CLI requires CURL 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 curl; then
printf "\n\033[92mCURL has been successfully installed!\033[39m\n"
echo "Info: $(curl --version)"
else
printf "\n\033[91mFailed to install CURL.\033[39m\n"
echo "Please review the logs and try to manually install it. - 'sudo apt-get install -y curl'."
exit 1;
fi
fi
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
if ! command psql --version > /dev/null 2>&1; then
printf "\n\033[93mHollaEx CLI requires PSQL Client to operate. Installing it now...\033[39m\n"
if [[ ! $IS_APT_UPDATED ]]; then
echo "Updating APT list"
sudo apt-get update
fi
echo "Installing Docker"
if command sudo apt-get install -y postgresql-client; then
printf "\n\033[92mPSQL Client has been successfully installed!\033[39m\n"
echo "Info: $(psql --version)"
else
printf "\n\033[91mFailed to install PSQL Client.\033[39m\n"
echo "Please review the logs and try to manually install it. - 'sudo apt-get install -y postgresql-client'."
exit 1;
fi
fi
# Dependencies installer for macOS with Homebrew.
elif command brew -v > /dev/null 2>&1; then
echo "Generating /usr/local/bin folder."
if [[ ! -d "/usr/local/bin" ]]; then
sudo mkdir -p -m 775 /usr/local/bin
fi
if ! command curl --version > /dev/null 2>&1; then
printf "\n\033[93mHollaEx CLI requires CURL to operate. Installing it now...\033[39m\n"
if [[ ! $IS_BREW_UPDATED ]]; then
echo "Updating Homebrew list"
brew update
fi
if command brew install curl; then
printf "\n\033[92mCURL has been successfully installed!\033[39m\n"
echo "Info: $(curl --version)"
else
printf "\n\033[91mFailed to install CURL.\033[39m\n"
echo "Please review the logs and try to manually install it. - 'brew install curl'."
exit 1;
fi
fi
if ! command docker -v > /dev/null 2>&1; then
echo "Updating Homebrew list"
if command brew update; then
IS_BREW_UPDATED=true
fi
if command brew install --cask docker; then
printf "\n\033[92mDocker Desktop has been successfully installed!\033[39m\n"
open /Applications/Docker.app
echo "Please go through the Docker Desktop setup on GUI."
# echo "Info: $(docker --version)"
else
printf "\n\033[91mFailed to install Docker Desktop.\033[39m\n"
echo "Please review the logs and try to manually install it. - 'brew install --cask docker'."
echo -e "You can also visit the official installation page: (docs.docker.com/docker-for-mac/install).\n"
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_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
if ! command psql --version > /dev/null 2>&1; then
printf "\n\033[93mHollaEx CLI requires PSQL Client to operate. Installing it now...\033[39m\n"
if [[ ! $IS_BREW_UPDATED ]]; then
echo "Updating Homebrew list"
brew update
fi
if command brew install libpq; then
printf "\n\033[92mjq has been successfully installed!\033[39m\n"
echo "Creating a symlink for the PSQL Client."
sudo ln -s $(brew --prefix)/opt/libpq/bin/psql /usr/local/bin/psql
echo "Info: $(psql --version)"
else
printf "\n\033[91mFailed to install PSQL Client.\033[39m\n"
echo "Please review the logs and try to manually install it. - 'brew install ligpq'."
fi
fi
# Dependencies installer for CentOS (RHEL) with Yum.
elif command yum --version > /dev/null 2>&1; then
if ! command curl --version > /dev/null 2>&1; then
printf "\n\033[93mHollaEx CLI requires CURL to operate. Installing it now...\033[39m\n"
if command sudo yum install -y curl; then
printf "\n\033[92mCURL has been successfully installed!\033[39m\n"
echo "Info: $(curl --version)"
else
printf "\n\033[91mFailed to install CURL.\033[39m\n"
echo "Please review the logs and try to manually install it. - 'sudo yum install -y curl'."
fi
fi
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
sudo systemctl start docker
sudo 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 sudo 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
if ! command psql --version > /dev/null 2>&1; then
printf "\n\033[93mHollaEx CLI requires PSQL CLient to operate. Installing it now...\033[39m\n"
if command sudo yum install -y postgresql; then
printf "\n\033[92mPSQL CLient(postgresql) has been successfully installed!\033[39m\n"
echo "Info: "
postgresql --version
else
printf "\n\033[91mFailed to install PSQL CLient.\033[39m\n"
echo "Please review the logs and try to manually install it. - 'sudo yum install -y postgresql'."
fi
fi
fi
if ! command docker -v > /dev/null 2>&1 || ! command docker-compose -v > /dev/null 2>&1 || ! command curl --version > /dev/null 2>&1 || ! command jq --version > /dev/null 2>&1 || ! command nslookup -version > /dev/null 2>&1 || ! command psql --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 curl --version > /dev/null 2>&1; then
IS_CURL_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
if command psql --version > /dev/null 2>&1; then
IS_PSQL_CLIENT_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
if [[ "$IS_PSQL_CLIENT_INSTALLED" ]]; then
printf "\033[92mpostgresql-client: Installed\033[39m\n"
else
printf "\033[91mpostgresql-client: Not Installed\033[39m\n"
fi
# curl installation status check
if [[ "$IS_CURL_INSTALLED" ]]; then
printf "\033[92mcurl: Installed\033[39m\n"
else
printf "\033[91mcurl: 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 "\nThe dependencies are all set!\n\n"
fi
# 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
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
exit 0;