-
Notifications
You must be signed in to change notification settings - Fork 6
/
run.sh
executable file
·1391 lines (1294 loc) · 46 KB
/
run.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
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
#
# EOS Docker node manager
# Released under MIT by @netuoso
#
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BOLD="$(tput bold)"
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
BLUE="$(tput setaf 4)"
MAGENTA="$(tput setaf 5)"
CYAN="$(tput setaf 6)"
WHITE="$(tput setaf 7)"
RESET="$(tput sgr0)"
# Placeholder for custom tag var CUST_TAG (shared between functions)
CUST_TAG="eosio"
# Placeholder for BUILD_VER shared between functions
BUILD_VER=""
: ${DOCKER_DIR="$DIR/Dockerfiles"}
# EOS Blockchain
: ${EOS_DATADIR="$DIR/networks/eos"}
: ${EOS_DK_TAG="eostitan/eosio:latest"}
: ${EOS_BC_FOLDER="$EOS_DATADIR/data"}
: ${EOS_EXAMPLE_CONF="$EOS_DATADIR/configs/config.ini.example"}
: ${EOS_EXAMPLE_GENESIS="$EOS_DATADIR/configs/genesis.json.example"}
: ${EOS_EXAMPLE_LOGGING="$EOS_DATADIR/configs/logging.json.example"}
: ${EOS_CONF_FILE="$EOS_DATADIR/data/config.ini"}
: ${EOS_GENESIS_FILE="$EOS_DATADIR/data/genesis.json"}
: ${EOS_LOGGING_FILE="$EOS_DATADIR/data/logging.json"}
# Git repository to use when building EOS - containing EOSIO code
: ${EOS_SOURCE="https://github.com/eosio/eos.git"}
: ${EOS_CONTRACTS_SOURCE="https://github.com/eosio/eosio.contracts.git"}
# EOS2 Blockchain
: ${EOS2_DATADIR="$DIR/networks/eos"}
: ${EOS2_DK_TAG="eostitan/eosio:latest"}
: ${EOS2_BC_FOLDER="$EOS2_DATADIR/data2"}
: ${EOS2_EXAMPLE_CONF="$EOS2_DATADIR/configs/config.ini.example"}
: ${EOS2_EXAMPLE_GENESIS="$EOS2_DATADIR/configs/genesis2.json.example"}
: ${EOS2_EXAMPLE_LOGGING="$EOS2_DATADIR/configs/logging.json.example"}
: ${EOS2_CONF_FILE="$EOS2_DATADIR/data2/config.ini"}
: ${EOS2_GENESIS_FILE="$EOS2_DATADIR/data2/genesis.json"}
: ${EOS2_LOGGING_FILE="$EOS2_DATADIR/data2/logging.json"}
# Git repository to use when building EOS2 - containing EOSIO code
: ${EOS2_SOURCE="https://github.com/eosio/eos.git"}
: ${EOS2_CONTRACTS_SOURCE="https://github.com/eosio/eosio.contracts.git"}
# UX Blockchain
: ${UX_DATADIR="$DIR/networks/ux"}
: ${UX_DK_TAG="eostitan/eosio:latest"}
: ${UX_BC_FOLDER="$UX_DATADIR/data"}
: ${UX_EXAMPLE_CONF="$UX_DATADIR/configs/config.ini.example"}
: ${UX_EXAMPLE_GENESIS="$UX_DATADIR/configs/genesis.json.example"}
: ${UX_EXAMPLE_LOGGING="$UX_DATADIR/configs/logging.json.example"}
: ${UX_CONF_FILE="$UX_DATADIR/data/config.ini"}
: ${UX_GENESIS_FILE="$UX_DATADIR/data/genesis.json"}
: ${UX_LOGGING_FILE="$UX_DATADIR/data/logging.json"}
# Git repository to use when building UX - containing EOSIO code
: ${UX_SOURCE="https://github.com/eosio/eos.git"}
: ${UX_CONTRACTS_SOURCE="https://github.com/eosio/eosio.contracts.git"}
# ORE Blockchain
: ${ORE_DATADIR="$DIR/networks/ore"}
: ${ORE_DK_TAG="eostitan/ore:latest"}
: ${ORE_BC_FOLDER="$ORE_DATADIR/data"}
: ${ORE_EXAMPLE_CONF="$ORE_DATADIR/configs/config.ini.example"}
: ${ORE_EXAMPLE_GENESIS="$ORE_DATADIR/configs/genesis.json.example"}
: ${ORE_EXAMPLE_LOGGING="$ORE_DATADIR/configs/logging.json.example"}
: ${ORE_CONF_FILE="$ORE_DATADIR/data/config.ini"}
: ${ORE_GENESIS_FILE="$ORE_DATADIR/data/genesis.json"}
: ${ORE_LOGGING_FILE="$ORE_DATADIR/data/logging.json"}
# Git repository to use when building ORE - containing ORE code
: ${ORE_SOURCE="https://github.com/API-market/ore-protocol.git"}
: ${ORE_CONTRACTS_SOURCE="https://github.com/API-market/eosio.contracts.git"}
# Steem Blockchain
: ${STEEM_DATADIR="$DIR/networks/steem"}
: ${STEEM_DK_TAG="steemit/steem:latest"}
: ${STEEM_BC_FOLDER="$STEEM_DATADIR/data"}
: ${STEEM_EXAMPLE_CONF="$STEEM_DATADIR/configs/config.ini.example"}
: ${STEEM_EXAMPLE_WALLET="$STEEM_DATADIR/configs/wallet.json.example"}
: ${STEEM_CONF_FILE="$STEEM_DATADIR/data/config.ini"}
: ${STEEM_WALLET_FILE="$STEEM_DATADIR/data/wallet.json"}
# Git repository to use when building Steem - containing steemd code
: ${STEEM_SOURCE="https://github.com/steemit/steem.git"}
# WORBLI Blockchain
: ${WORBLI_DATADIR="$DIR/networks/worbli"}
: ${WORBLI_DK_TAG="worbli/worbli:latest"}
: ${WORBLI_BC_FOLDER="$WORBLI_DATADIR/data"}
: ${WORBLI_EXAMPLE_CONF="$WORBLI_DATADIR/configs/config.ini.example"}
: ${WORBLI_EXAMPLE_GENESIS="$WORBLI_DATADIR/configs/genesis.json.example"}
: ${WORBLI_EXAMPLE_LOGGING="$WORBLI_DATADIR/configs/logging.json.example"}
: ${WORBLI_CONF_FILE="$WORBLI_DATADIR/data/config.ini"}
: ${WORBLI_GENESIS_FILE="$WORBLI_DATADIR/data/genesis.json"}
: ${WORBLI_LOGGING_FILE="$WORBLI_DATADIR/data/logging.json"}
# Git repository to use when building WORBLI - containing WORBLI code
: ${WORBLI_SOURCE="https://github.com/worbli/worbli.git"}
: ${WORBLI_CONTRACTS_SOURCE="https://github.com/worbli/worbli.contracts.git"}
# if the eos config file doesn't exist, try copying the example config
if [[ ! -f "$EOS_CONF_FILE" ]]; then
if [[ -f "$EOS_EXAMPLE_CONF" ]]; then
echo "${YELLOW}EOS: File config.ini not found. copying example${RESET}"
cp -vi "$EOS_EXAMPLE_CONF" "$EOS_CONF_FILE"
echo "${GREEN} > Successfully installed example config for eos node.${RESET}"
echo " > You may want to adjust this if you're running a witness"
else
echo "${YELLOW}WARNING: You don't seem to have a config file and the example config couldn't be found...${RESET}"
echo "Example Config: $EOS_EXAMPLE_CONF"
echo "Main Config: $EOS_CONF_FILE"
fi
fi
# if the eos genesis file doesn't exist, try copying the example genesis file
if [[ ! -f "$EOS_GENESIS_FILE" ]]; then
if [[ -f "$EOS_EXAMPLE_GENESIS" ]]; then
echo "${YELLOW}EOS: File genesis.json not found. copying example${RESET}"
cp -vi "$EOS_EXAMPLE_GENESIS" "$EOS_GENESIS_FILE"
echo "${GREEN} > Successfully installed example genesis file for eos node.${RESET}"
else
echo "${YELLOW}WARNING: You don't seem to have a genesis file and the example genesis couldn't be found...${RESET}"
echo "Example Config: $EOS_EXAMPLE_GENESIS"
echo "Main Config: $EOS_GENESIS_FILE"
fi
fi
# if the eos logging file doesn't exist, try copying the example logging config
if [[ ! -f "$EOS_LOGGING_FILE" ]]; then
if [[ -f "$EOS_EXAMPLE_LOGGING" ]]; then
echo "${YELLOW}EOS: File logging.json not found. copying example${RESET}"
cp -vi "$EOS_EXAMPLE_LOGGING" "$EOS_LOGGING_FILE"
echo "${GREEN} > Successfully installed example logging config for eos node.${RESET}"
else
echo "${YELLOW}WARNING: You don't seem to have a logging config file and the example config couldn't be found...${RESET}"
echo "Example Config: $EOS_EXAMPLE_LOGGING"
echo "Main Config: $EOS_LOGGING_FILE"
fi
fi
# if the eos2 config file doesn't exist, try copying the example config
if [[ ! -f "$EOS2_CONF_FILE" ]]; then
if [[ -f "$EOS2_EXAMPLE_CONF" ]]; then
echo "${YELLOW}EOS: File config.ini not found. copying example${RESET}"
cp -vi "$EOS2_EXAMPLE_CONF" "$EOS2_CONF_FILE"
echo "${GREEN} > Successfully installed example config for eos2 node.${RESET}"
echo " > You may want to adjust this if you're running a witness"
else
echo "${YELLOW}WARNING: You don't seem to have a config file and the example config couldn't be found...${RESET}"
echo "Example Config: $EOS2_EXAMPLE_CONF"
echo "Main Config: $EOS2_CONF_FILE"
fi
fi
# if the eos2 genesis file doesn't exist, try copying the example genesis file
if [[ ! -f "$EOS2_GENESIS_FILE" ]]; then
if [[ -f "$EOS2_EXAMPLE_GENESIS" ]]; then
echo "${YELLOW}EOS: File genesis.json not found. copying example${RESET}"
cp -vi "$EOS2_EXAMPLE_GENESIS" "$EOS2_GENESIS_FILE"
echo "${GREEN} > Successfully installed example genesis file for eos2 node.${RESET}"
else
echo "${YELLOW}WARNING: You don't seem to have a genesis file and the example genesis couldn't be found...${RESET}"
echo "Example Config: $EOS2_EXAMPLE_GENESIS"
echo "Main Config: $EOS2_GENESIS_FILE"
fi
fi
# if the eos2 logging file doesn't exist, try copying the example logging config
if [[ ! -f "$EOS2_LOGGING_FILE" ]]; then
if [[ -f "$EOS2_EXAMPLE_LOGGING" ]]; then
echo "${YELLOW}EOS: File logging.json not found. copying example${RESET}"
cp -vi "$EOS2_EXAMPLE_LOGGING" "$EOS2_LOGGING_FILE"
echo "${GREEN} > Successfully installed example logging config for eos2 node.${RESET}"
else
echo "${YELLOW}WARNING: You don't seem to have a logging config file and the example config couldn't be found...${RESET}"
echo "Example Config: $EOS2_EXAMPLE_LOGGING"
echo "Main Config: $EOS2_LOGGING_FILE"
fi
fi
# if the ux config file doesn't exist, try copying the example config
if [[ ! -f "$UX_CONF_FILE" ]]; then
if [[ -f "$UX_EXAMPLE_CONF" ]]; then
echo "${YELLOW}UX: File config.ini not found. copying example${RESET}"
cp -vi "$UX_EXAMPLE_CONF" "$UX_CONF_FILE"
echo "${GREEN} > Successfully installed example config for ux node.${RESET}"
echo " > You may want to adjust this if you're running a witness"
else
echo "${YELLOW}WARNING: You don't seem to have a config file and the example config couldn't be found...${RESET}"
echo "Example Config: $UX_EXAMPLE_CONF"
echo "Main Config: $UX_CONF_FILE"
fi
fi
# if the ux genesis file doesn't exist, try copying the example genesis file
if [[ ! -f "$UX_GENESIS_FILE" ]]; then
if [[ -f "$UX_EXAMPLE_GENESIS" ]]; then
echo "${YELLOW}UX: File genesis.json not found. copying example${RESET}"
cp -vi "$UX_EXAMPLE_GENESIS" "$UX_GENESIS_FILE"
echo "${GREEN} > Successfully installed example genesis file for ux node.${RESET}"
else
echo "${YELLOW}WARNING: You don't seem to have a genesis file and the example genesis couldn't be found...${RESET}"
echo "Example Config: $UX_EXAMPLE_GENESIS"
echo "Main Config: $UX_GENESIS_FILE"
fi
fi
# if the ux logging file doesn't exist, try copying the example logging config
if [[ ! -f "$UX_LOGGING_FILE" ]]; then
if [[ -f "$UX_EXAMPLE_LOGGING" ]]; then
echo "${YELLOW}UX: File logging.json not found. copying example${RESET}"
cp -vi "$UX_EXAMPLE_LOGGING" "$UX_LOGGING_FILE"
echo "${GREEN} > Successfully installed example logging config for ux node.${RESET}"
else
echo "${YELLOW}WARNING: You don't seem to have a logging config file and the example config couldn't be found...${RESET}"
echo "Example Config: $UX_EXAMPLE_LOGGING"
echo "Main Config: $UX_LOGGING_FILE"
fi
fi
# if the worbli config file doesn't exist, try copying the example config
if [[ ! -f "$WORBLI_CONF_FILE" ]]; then
if [[ -f "$WORBLI_EXAMPLE_CONF" ]]; then
echo "${YELLOW}EOS: File config.ini not found. copying example${RESET}"
cp -vi "$WORBLI_EXAMPLE_CONF" "$WORBLI_CONF_FILE"
echo "${GREEN} > Successfully installed example config for worbli node.${RESET}"
echo " > You may want to adjust this if you're running a witness"
else
echo "${YELLOW}WARNING: You don't seem to have a config file and the example config couldn't be found...${RESET}"
echo "Example Config: $WORBLI_EXAMPLE_CONF"
echo "Main Config: $WORBLI_CONF_FILE"
fi
fi
# if the worbli genesis file doesn't exist, try copying the example genesis file
if [[ ! -f "$WORBLI_GENESIS_FILE" ]]; then
if [[ -f "$WORBLI_EXAMPLE_GENESIS" ]]; then
echo "${YELLOW}EOS: File genesis.json not found. copying example${RESET}"
cp -vi "$WORBLI_EXAMPLE_GENESIS" "$WORBLI_GENESIS_FILE"
echo "${GREEN} > Successfully installed example genesis file for worbli node.${RESET}"
else
echo "${YELLOW}WARNING: You don't seem to have a genesis file and the example genesis couldn't be found...${RESET}"
echo "Example Config: $WORBLI_EXAMPLE_GENESIS"
echo "Main Config: $WORBLI_GENESIS_FILE"
fi
fi
# if the worbli logging file doesn't exist, try copying the example logging config
if [[ ! -f "$WORBLI_LOGGING_FILE" ]]; then
if [[ -f "$WORBLI_EXAMPLE_LOGGING" ]]; then
echo "${YELLOW}EOS: File logging.json not found. copying example${RESET}"
cp -vi "$WORBLI_EXAMPLE_LOGGING" "$WORBLI_LOGGING_FILE"
echo "${GREEN} > Successfully installed example logging config for worbli node.${RESET}"
else
echo "${YELLOW}WARNING: You don't seem to have a logging config file and the example config couldn't be found...${RESET}"
echo "Example Config: $WORBLI_EXAMPLE_LOGGING"
echo "Main Config: $WORBLI_LOGGING_FILE"
fi
fi
# if the ore config file doesn't exist, try copying the example config
if [[ ! -f "$ORE_CONF_FILE" ]]; then
if [[ -f "$ORE_EXAMPLE_CONF" ]]; then
echo "${YELLOW}ORE: File config.ini not found. copying example${RESET}"
cp -vi "$ORE_EXAMPLE_CONF" "$ORE_CONF_FILE"
echo "${GREEN} > Successfully installed example config for ore node.${RESET}"
echo " > You may want to adjust this if you're running a witness"
else
echo "${YELLOW}WARNING: You don't seem to have a config file and the example config couldn't be found...${RESET}"
echo "Example Config: $ORE_EXAMPLE_CONF"
echo "Main Config: $ORE_CONF_FILE"
fi
fi
# if the ore genesis file doesn't exist, try copying the example genesis file
if [[ ! -f "$ORE_GENESIS_FILE" ]]; then
if [[ -f "$ORE_EXAMPLE_GENESIS" ]]; then
echo "${YELLOW}ORE: File genesis.json not found. copying example${RESET}"
cp -vi "$ORE_EXAMPLE_GENESIS" "$ORE_GENESIS_FILE"
echo "${GREEN} > Successfully installed example genesis file for ore node.${RESET}"
else
echo "${YELLOW}WARNING: You don't seem to have a genesis file and the example genesis couldn't be found...${RESET}"
echo "Example Config: $ORE_EXAMPLE_GENESIS"
echo "Main Config: $ORE_GENESIS_FILE"
fi
fi
# if the ore logging file doesn't exist, try copying the example logging config
if [[ ! -f "$ORE_LOGGING_FILE" ]]; then
if [[ -f "$ORE_EXAMPLE_LOGGING" ]]; then
echo "${YELLOW}ORE: File logging.json not found. copying example${RESET}"
cp -vi "$ORE_EXAMPLE_LOGGING" "$ORE_LOGGING_FILE"
echo "${GREEN} > Successfully installed example logging config for ore node.${RESET}"
else
echo "${YELLOW}WARNING: You don't seem to have a logging config file and the example config couldn't be found...${RESET}"
echo "Example Config: $ORE_EXAMPLE_LOGGING"
echo "Main Config: $ORE_LOGGING_FILE"
fi
fi
# if the steem config file doesn't exist, try copying the example config
if [[ ! -f "$STEEM_CONF_FILE" ]]; then
if [[ -f "$STEEM_EXAMPLE_CONF" ]]; then
echo "${YELLOW}STEEM: File config.ini not found. copying example${RESET}"
cp -vi "$STEEM_EXAMPLE_CONF" "$STEEM_CONF_FILE"
echo "${GREEN} > Successfully installed example config for steem node.${RESET}"
echo " > You may want to adjust this if you're running a witness"
else
echo "${YELLOW}WARNING: You don't seem to have a config file and the example config couldn't be found...${RESET}"
echo "${YELLOW}${BOLD}You may want to check these files exist, or you won't be able to launch Steem${RESET}"
echo "Example Config: $STEEM_EXAMPLE_CONF"
echo "Main Config: $STEEM_CONF_FILE"
fi
fi
# if the steem wallet file doesn't exist, try copying the example wallet
if [[ ! -f "$STEEM_WALLET_FILE" ]]; then
if [[ -f "$STEEM_EXAMPLE_WALLET" ]]; then
echo "${YELLOW}STEEM: File wallet.json not found. copying example${RESET}"
cp -vi "$STEEM_EXAMPLE_WALLET" "$STEEM_WALLET_FILE"
echo "${GREEN} > Successfully installed example wallet for steem node.${RESET}"
else
echo "${YELLOW}WARNING: You don't seem to have a wallet file and the example wallet couldn't be found...${RESET}"
echo "Example Wallet: $STEEM_EXAMPLE_WALLET"
echo "Main Wallet: $STEEM_WALLET_FILE"
fi
fi
# Array of additional arguments to be passed to Docker during builds
# Generally populated using arguments passed to build
# But you can specify custom additional build parameters by setting CUSTOM_ARGS
# as an array in .env
# e.g.
#
# CUSTOM_ARGS=('--rm' '-q' '--compress')
#
CUSTOM_ARGS=()
function msg () {
# usage: msg [color] message
if [[ "$#" -eq 0 ]]; then echo ""; return; fi;
if [[ "$#" -eq 1 ]]; then
echo -e "$1"
return
fi
if [[ "$#" -gt 2 ]] && [[ "$1" == "bold" ]]; then
echo -n "${BOLD}"
shift
fi
_msg="[$(date +'%Y-%m-%d %H:%M:%S %Z')] ${@:2}"
case "$1" in
bold) echo -e "${BOLD}${_msg}${RESET}";;
[Bb]*) echo -e "${BLUE}${_msg}${RESET}";;
[Yy]*) echo -e "${YELLOW}${_msg}${RESET}";;
[Rr]*) echo -e "${RED}${_msg}${RESET}";;
[Gg]*) echo -e "${GREEN}${_msg}${RESET}";;
* ) echo -e "${_msg}";;
esac
}
export -f msg
export RED GREEN YELLOW BLUE BOLD NORMAL RESET
if [[ -f .env ]]; then
source .env
fi
help() {
echo "Usage: $0 COMMAND [DATA]"
echo
echo "Commands:
start - starts network|container(s) - [eos|ux|ore|steem|worbli]
clean - Remove testnet files - [eos|ux|ore|steem|worbli]
stop - stops container(s) - [eos|ux|ore|steem|worbli]
status - show status of eos container - [eos|ux|ore|steem|worbli]
restart - restarts container(s) - [eos|ux|ore|steem|worbli]
install_docker - install docker
rebuild - builds eos container(s), and then restarts it - [eos|ux|ore|steem|worbli]
build - build docker container(s) - [eos|ux|ore|steem|worbli]
buildcontact - build specific contact inside main container - [eos|ux|ore|worbli]
cleos - access cleos command line in container - [eos|ux|ore|worbli]
setcdt - set eosio.cdt version in container - [eos|ux|ore|worbli]
logs - show log stream - [eos|ux|ore|steem|worbli]
wallet - open wallet in the container - [eos|ux|ore|steem|worbli]
enter - enter a bash session in the currently running container - [eos|ux|ore|steem|worbli]
shell - launch the eos container with appropriate mounts, then open bash for inspection - [eos|ux|ore|steem|worbli]
"
echo
exit
}
# Usage: ./run.sh build [network]
# Build the docker images for specified network
#
# network - specify which network to build network for [eos|ux|ore|steem|worbli]
#
build() {
fmm="EOS Testnet"
BUILD_MSG=" >> Building docker container [[ ${fmm} ]]"
msg bold green "$BUILD_MSG"
cd "$DOCKER_DIR"
case $1 in
eos)
docker-compose -f Dockerfiles/build eos-wallet eos-main eos-main2 pricefeed writehash
;;
ux)
docker-compose -f Dockerfiles/build ux-wallet ux-main
;;
worbli)
docker-compose -f Dockerfiles/build worbli-wallet worbli-main
;;
ore)
docker-compose -f Dockerfiles/build ore-wallet ore-main
;;
steem)
docker-compose -f Dockerfiles/build steem-wallet steem
;;
esac
ret=$?
if (( $ret == 0 )); then
msg bold green " +++ Successfully built EOS Testnet images"
msg green " +++ Docker tag: $1"
else
msg bold red " !!! ERROR: Something went wrong during the build process."
msg red " !!! Please scroll up and check for any error output during the build."
fi
}
# Usage: ./run.sh install_docker
# Downloads and installs the latest version of Docker using the Get Docker site
# If Docker is already installed, it should update it.
install_docker() {
sudo apt update
# curl/git used by docker, xz/lz4 used by dlblocks, jq used by tslogs/pclogs
sudo apt install curl git xz-utils liblz4-tool jq
curl https://get.docker.com | sh
if [ "$EUID" -ne 0 ]; then
echo "Adding user $(whoami) to docker group"
sudo usermod -aG docker $(whoami)
echo "IMPORTANT: Please re-login (or close and re-connect SSH) for docker to function correctly"
fi
}
# Usage: ./run.sh bootstrap [network]
# Bootstraps the testnet
#
# network - specify which network to build container for [eos|ux|ore|steem|worbli]
#
bootstrap() {
cd "$DIR"
msg yellow bootstrap $1
case $1 in
eos|ux|ore|steem)
bash -c "./networks/$1/scripts/bootstrap.sh"
;;
eos2)
bash -c "./networks/eos/scripts/bootstrap.sh 2"
;;
worbli)
bash -c "./networks/worbli/scripts/bootstrap.sh"
;;
*)
msg bold red "Unknown docker image use [eos|ux|ore|steem|worbli]"
;;
esac
}
### EOS|ORE Only
# Usage: ./run.sh deploy [contract]
# Deploy specified contract to network
#
# contract - specify which contract to deploy
#
deploy() {
cd "$DIR"
msg yellow Deploy contract $2
case $1 in
eos)
case $2 in
ict)
docker exec -it "eos-main" cleos --wallet-url http://eos-wallet:8901 set contract ict /root/contracts/ict/contract/ict/src/ ict.wasm ict.abi -p ict@active
;;
vpow.token)
docker exec -it "eos-main" cleos --wallet-url http://eos-wallet:8901 set contract vpow.token /root/contracts/vpow-contract/build/vpowtoken/ vpowtoken.wasm vpowtoken.abi -p vpow.token@active
;;
delphioracle)
bash -c "$EOS_DATADIR/scripts/delphi-deploy.sh clone build deploy configure"
;;
eosio.system)
docker exec -it "eos-main" cleos --wallet-url http://eos-wallet:8901 set contract eosio /eosio.contracts/build/contracts/eosio.system/ eosio.system.wasm eosio.system.abi -p eosio@active
;;
*)
msg red "Contract not recognized: [ict|delphioracle|eosio.system]"
;;
esac
;;
eos2)
case $2 in
ict)
docker exec -it "eos-main2" cleos --wallet-url http://eos-wallet:8901 set contract ict /root/contracts/ict/contract/ict/src/ ict.wasm ict.abi -p ict@active
;;
vpow.token)
docker exec -it "eos-main2" cleos --wallet-url http://eos-wallet:8901 set contract vpow.token /root/contracts/vpow-contract/build/vpowtoken/ vpowtoken.wasm vpowtoken.abi -p vpow.token@active
;;
delphioracle)
bash -c "$EOS_DATADIR/scripts/delphi-deploy.sh clone build deploy configure"
;;
eosio.system)
docker exec -it "eos-main2" cleos --wallet-url http://eos-wallet:8901 set contract eosio /eosio.contracts/build/contracts/eosio.system/ eosio.system.wasm eosio.system.abi -p eosio@active
;;
*)
msg red "Contract not recognized: [ict|delphioracle|eosio.system]"
;;
esac
;;
ux)
case $2 in
eosio.system)
docker exec -it "ore-main" cleos --wallet-url http://ore-wallet:8901 set contract eosio /root/contracts/aikon-system-contract/build/contracts/eosio.system/ eosio.system.wasm eosio.system.abi -p eosio@active
;;
*)
msg red "Contract not recognized: [eosio.system]"
;;
esac
;;
ore)
case $2 in
delphioracle)
bash -c "$ORE_DATADIR/scripts/delphi-deploy.sh clone build deploy configure"
;;
eosio.system)
docker exec -it "ore-main" cleos --wallet-url http://ore-wallet:8901 set contract eosio /root/contracts/aikon-system-contract/build/contracts/eosio.system/ eosio.system.wasm eosio.system.abi -p eosio@active
;;
*)
msg red "Contract not recognized: [ict|delphioracle|eosio.system]"
;;
esac
;;
*)
msg bold red "Unsupported network. Use [eos|ux|ore|worbli]"
;;
esac
}
### EOS|ORE Only
# Usage: ./run.sh initcontract [contract]
# Initalize specified contract
#
# contract - specify which contract to initcontract
#
initcontract() {
if (( $# >= 1 )); then
cd "$DIR"
msg yellow Init contract $1
case $1 in
eos)
case $2 in
ict)
docker exec -it "eos-main" cleos --wallet-url http://eos-wallet:8901 push action ict create '{"issuer":"ict","maximum_supply":"10000000.0000 EOS"}' -p ict@active
docker exec -it "eos-main" cleos --wallet-url http://eos-wallet:8901 push action ict open '{"owner":"producer1", "symbol":"4,EOS", "ram_payer":"producer1"}' -p producer1@active
;;
*)
msg red "Contract not recognized: [ict]"
;;
esac
;;
eos2)
case $2 in
ict)
docker exec -it "eos-main2" cleos --wallet-url http://eos-wallet:8901 push action ict create '{"issuer":"ict","maximum_supply":"10000000.0000 EOS"}' -p ict@active
docker exec -it "eos-main2" cleos --wallet-url http://eos-wallet:8901 push action ict open '{"owner":"producer1", "symbol":"4,EOS", "ram_payer":"producer1"}' -p producer1@active
;;
*)
msg red "Contract not recognized: [ict]"
;;
esac
;;
*)
msg red "Network not supported: [eos/eos2]"
;;
esac
fi
}
### EOS|ORE Only
# Usage: ./run.sh build [contract]
# Deploy specified contract to network
#
# contract - specify which contract to build
#
buildcontract() {
if (( $# >= 1 )); then
cd "$DIR"
msg yellow Build contract $1
case $1 in
ict)
docker exec -it "eos-main" bash -c "mkdir -p /root/contracts/ict/contract/ict/build/ && cd /root/contracts/ict/contract/ict/build/ && cmake .. && make"
;;
delphioracle)
bash -c "$EOS_DATADIR/scripts/delphi-deploy.sh clone build deploy configure"
;;
eosio.system)
docker exec -it "eos-main" cleos --wallet-url http://eos-wallet:8901 set contract eosio /eosio.contracts/build/contracts/eosio.system/ eosio.system.wasm eosio.system.abi -p eosio@active
;;
worbli)
docker exec -it "worbli-main" bash -c "cd /root/contracts/ && git clone https://github.com/eostitan/eosio.contracts" &&
docker exec -it "worbli-main" bash -c "cd /root/contracts/eosio.contracts && git checkout worbli-dev "
docker exec -it "worbli-main" bash -c "mkdir -p /root/contracts/eosio.contracts/build && cd /root/contracts/eosio.contracts/build && cmake .. && make contracts_project"
;;
ore)
msg red "ORE: buildcontract not yet implemented"
;;
*)
msg red "Contract not recognized: [ict|delphioracle|eosio.system|worbli]"
;;
esac
fi
}
### EOS|ORE Only
# Usage: ./run.sh cleos [command]
# Run a cleos command
#
# command - specify which contract to build and cleos
#
cleos() {
case $1 in
eos|ux|ore|worbli)
docker exec -it "$1"-main cleos --wallet-url http://"$1"-wallet:8901 "${@:2}"
;;
eos2)
docker exec -it eos-main2 cleos --wallet-url http://eos-wallet:8901 "${@:2}"
;;
*)
msg red "Unrecognized network. Use: [eos|ux|ore|worbli]"
;;
esac
}
### EOS|ORE Only
# Usage: ./run.sh setcdt [version]
# Run a cleos command
#
# version - specify which version of Eosio.CDT to activate inside main container
#
setcdt() {
case $1 in
eos|ux|ore|worbli)
case $2 in
v1.5.0|v1.6.3|v1.7.0)
msg yellow "$1: Activating EOSIO.CDT Version $2"
current=$(docker exec $1-main eosio-cpp --version)
if [[ "$current" == *"${2:1:5}"* ]]; then
msg green "$1: EOSIO.CDT version already set"
return
fi
docker exec "$1"-main bash -c "cp -rf /eosio.cdt/$2/usr/* /usr/"
msg yellow "$1: Done"
;;
*)
msg red bold "$1: Unknown CDT version. Select from [v1.4.1|v1.6.3]"
;;
esac
;;
esac
}
# Internal Use Only
# Checks if the container main container exists. Returns 0 if it does, -1 if not.
#
eos_main_exists() {
ret=$(docker ps -a -f name="eos-main" | wc -l)
if [[ $ret -eq 2 ]]; then
return 0
else
return -1
fi
}
# Internal Use Only
# Checks if the container wallet container exists. Returns 0 if it does, -1 if not.
#
eos_wallet_exists() {
ret=$(docker ps -a -f name="eos-wallet" | wc -l)
if [[ $ret -eq 2 ]]; then
return 0
else
return -1
fi
}
# Internal Use Only
# Checks if the container main container exists. Returns 0 if it does, -1 if not.
#
ux_main_exists() {
ret=$(docker ps -a -f name="ux-main" | wc -l)
if [[ $ret -eq 2 ]]; then
return 0
else
return -1
fi
}
# Internal Use Only
# Checks if the container wallet container exists. Returns 0 if it does, -1 if not.
#
ux_wallet_exists() {
ret=$(docker ps -a -f name="ux-wallet" | wc -l)
if [[ $ret -eq 2 ]]; then
return 0
else
return -1
fi
}
# Internal Use Only
# Checks if the container main container exists. Returns 0 if it does, -1 if not.
#
worbli_main_exists() {
ret=$(docker ps -a -f name="worbli-main" | wc -l)
if [[ $ret -eq 2 ]]; then
return 0
else
return -1
fi
}
# Internal Use Only
# Checks if the container wallet container exists. Returns 0 if it does, -1 if not.
#
worbli_wallet_exists() {
ret=$(docker ps -a -f name="worbli-wallet" | wc -l)
if [[ $ret -eq 2 ]]; then
return 0
else
return -1
fi
}
# Internal Use Only
# Checks if the container main container exists. Returns 0 if it does, -1 if not.
#
ore_main_exists() {
ret=$(docker ps -a -f name="ore-main" | wc -l)
if [[ $ret -eq 2 ]]; then
return 0
else
return -1
fi
}
# Internal Use Only
# Checks if the container wallet container exists. Returns 0 if it does, -1 if not.
#
ore_wallet_exists() {
ret=$(docker ps -a -f name="ore-wallet" | wc -l)
if [[ $ret -eq 2 ]]; then
return 0
else
return -1
fi
}
# Internal Use Only
# Checks if the container main container exists and is running. Returns 0 if it does, -1 if not.
#
ux_main_running() {
ret=$(docker ps -f 'status=running' -f name="ux-main" | wc -l)
if [[ $ret -eq 2 ]]; then
return 0
else
return -1
fi
}
# Internal Use Only
# Checks if the container wallet container exists and is running. Returns 0 if it does, -1 if not.
#
ux_wallet_running() {
ret=$(docker ps -f 'status=running' -f name="ux-wallet" | wc -l)
if [[ $ret -eq 2 ]]; then
return 0
else
return -1
fi
}
# Internal Use Only
# Checks if the container main container exists and is running. Returns 0 if it does, -1 if not.
#
eos_main_running() {
ret=$(docker ps -f 'status=running' -f name="eos-main" | wc -l)
if [[ $ret -eq 2 ]]; then
return 0
else
return -1
fi
}
# Internal Use Only
# Checks if the container wallet container exists and is running. Returns 0 if it does, -1 if not.
#
eos_wallet_running() {
ret=$(docker ps -f 'status=running' -f name="eos-wallet" | wc -l)
if [[ $ret -eq 2 ]]; then
return 0
else
return -1
fi
}
# Internal Use Only
# Checks if the container main container exists and is running. Returns 0 if it does, -1 if not.
#
worbli_main_running() {
ret=$(docker ps -f 'status=running' -f name="worbli-main" | wc -l)
if [[ $ret -eq 2 ]]; then
return 0
else
return -1
fi
}
# Internal Use Only
# Checks if the container wallet container exists and is running. Returns 0 if it does, -1 if not.
#
worbli_wallet_running() {
ret=$(docker ps -f 'status=running' -f name="worbli-wallet" | wc -l)
if [[ $ret -eq 2 ]]; then
return 0
else
return -1
fi
}
# Internal Use Only
# Checks if the container main container exists and is running. Returns 0 if it does, -1 if not.
#
ore_main_running() {
ret=$(docker ps -f 'status=running' -f name="ore-main" | wc -l)
if [[ $ret -eq 2 ]]; then
return 0
else
return -1
fi
}
# Internal Use Only
# Checks if the container wallet container exists and is running. Returns 0 if it does, -1 if not.
#
ore_wallet_running() {
ret=$(docker ps -f 'status=running' -f name="ore-wallet" | wc -l)
if [[ $ret -eq 2 ]]; then
return 0
else
return -1
fi
}
# Usage: ./run.sh start
# Creates and/or starts the Steem docker container
start() {
msg bold green " -> Starting container(s) ${1}..."
cd "$DOCKER_DIR"
case $1 in
eos|ux|ore|steem|worbli)
if [[ ${@:2} =~ "pull" ]]; then
services=$(echo ${@:2} | sed "s/pull//")
docker-compose -f docker-compose-"$1".yml -p $1 pull $services && docker-compose -f docker-compose-"$1".yml -p $1 up -d $services
else
docker-compose -f docker-compose-"$1".yml -p $1 up -d $2
fi
;;
*)
msg red "Network not recognized: [eos|ux|ore|steem|worbli]"
;;
esac
}
# Usage: ./run.sh stop
# Stops the Steem container, and removes the container to avoid any leftover
#
stop() {
msg "If you don't care about a clean stop, you can force stop the container with ${BOLD}./run.sh kill"
msg red "Stopping network ..."
cd "$DOCKER_DIR"
case $1 in
eos|ux|ore|steem|worbli)
docker-compose -f docker-compose-"$1".yml -p $1 rm -sf $2
;;
*)
msg red "Network not recognized: [eos|ux|ore|steem|worbli]"
;;
esac
}
sbkill() {
msg bold red "Killing network '${1}'..."
cd "$DOCKER_DIR"
docker-compose down -t 1 $1
}
# Usage: ./run.sh enter
# Enters the running docker container and opens a bash shell for debugging
#
enter() {
docker exec -it "$1" bash
}
# Usage: ./run.sh shell
# Runs the container similar to `run` with mounted directories,
# then opens a BASH shell for debugging
# To avoid leftover containers, it uses `--rm` to remove the container once you exit.
#
shell() {
case $1 in
eos)
docker run -v "$EOS_DATADIR/data:/eosio-data" --rm -it "eosio-testnet" bash
;;
ore)
docker run -v "$ORE_DATADIR/data:/ore-data" --rm -it "ore-testnet" bash
;;
steem)
docker run -v "$STEEM_DATADIR/data:/steemd-data" --rm -it "steemit/steem:latest" bash
;;
*)
msg bold red "Unrecognized network name. Use [eos|ux|ore|steem|worbli]"
;;
esac
}
# Usage: ./run.sh wallet
# Opens cli_wallet inside of the running Steem container and
# connects to the local steemd over websockets on port 8090
#
wallet() {
case $1 in
eos)
docker exec -it "eos-wallet" cleos -u http://eos-main:8888 wallet "${@:2}"
;;
ore)
docker exec -it "ore-wallet" cleos -u http://ore-main:8888 wallet "${@:2}"
;;
steem)
docker exec -it "steem" /usr/local/steemd-testnet/bin/cli_wallet -w /steemd-data/wallet.json "${@:2}"
;;
true) # used with wallet_cmd for Steem only
docker exec "steem" /usr/local/steemd-testnet/bin/cli_wallet -w /steemd-data/wallet.json "${@:2}"
;;
*)
msg bold red "Unrecognized network name. Use [eos|ux|ore|steem|worbli]"
;;
esac
}
# Usage: ./run.sh logs
# Shows the last 30 log lines of the running steem container, and follows the log until you press ctrl-c
#
logs() {
msg blue "DOCKER LOGS: (press ctrl-c to exit) "
cd "$DOCKER_DIR"
case $1 in
eos|ux|ore|steem|worbli)
docker-compose -f docker-compose-"$1".yml -p $1 logs -f --tail 30 $2
;;
*)
msg red "Network not recognized: [eos|ux|ore|steem|worbli]"
;;
esac
}
# Usage: ./run.sh status
# Very simple status display, letting you know if the container exists, and if it's running.
status() {
echo "${BOLD}${BLUE}========= EOS =========${RESET}"
if eos_main_exists; then
echo "eos-main exists?: "$GREEN"YES"$RESET
if eos_main_running; then
echo "eos-main running?: "$GREEN"YES"$RESET
else
echo "eos-main running?: "$RED"NO (!)"$RESET
echo "eos-main isn't running. Start it with '$0 start eos-main'"$RESET
fi
else
echo "eos-main exists?: "$RED"NO (!)"$RESET
echo "eos-main doesn't exist, thus it is NOT running. Run '$0 start eos-main'"$RESET
fi
if eos_wallet_exists; then
echo "eos-wallet exists?: "$GREEN"YES"$RESET