forked from eth-educators/eth-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ethd
executable file
·2488 lines (2309 loc) · 95.7 KB
/
ethd
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
#set -euo pipefail
set -uo pipefail
__docker_exe="docker"
__compose_exe="docker compose"
__compose_upgraded=0
dodocker() {
$__docker_exe "$@"
}
docompose() {
$__compose_exe "$@"
}
determine_distro() {
# Determine OS platform
__uname=$(uname | tr "[:upper:]" "[:lower:]")
# If Linux, try to determine specific distribution
if [ "$__uname" == "linux" ]; then
# If available, use LSB to identify distribution
if [ -n "$(command -v lsb_release 2>/dev/null)" ]; then
__distro=$(lsb_release -i | cut -d: -f2 | sed s/'^\t'//)
# Otherwise, use release info file
else
#__distro=$(ls -d /etc/[A-Za-z]*[_-][rv]e[lr]* | grep -v "lsb" | cut -d'/' -f3 | cut -d'-' -f1 | cut -d'_' -f1)
__distro=$(find /etc -maxdepth 1 -type f -name '[A-Za-z]*[_-][rv]e[lr]*' | grep -v "lsb" | cut -d'/' -f3 | cut -d'-' -f1 | cut -d'_' -f1)
fi
else
__distro=""
fi
# For everything else (or if above failed), just use generic identifier
[ "$__distro" == "" ] && __distro=$__uname
unset __uname
__distro=$(echo "$__distro" | tr "[:upper:]" "[:lower:]")
}
determine_sudo() {
if [[ "$__distro" =~ "debian" || "$__distro" = "ubuntu" ]]; then
systemctl status docker >/dev/null
result=$?
if [ ! "${result}" -eq 0 ]; then
echo "The docker daemon is not running. Please check docker installation."
echo "\"sudo systemctl status docker\" and \"sudo journalctl -fu docker\" will be helpful."
echo "Aborting."
exit 1
fi
fi
__maybe_sudo=""
if ! docker images >/dev/null 2>&1; then
echo "Will use sudo to access docker"
__maybe_sudo="sudo"
fi
}
determine_docker() {
if [ -n "$__maybe_sudo" ]; then
__docker_exe="sudo $__docker_exe"
fi
}
determine_compose() {
# Check for Compose V2 (docker compose) vs Compose V1 (docker-compose)
if docker compose version >/dev/null 2>&1; then
__compose_exe="docker compose"
__old_compose=0
else
__compose_exe="docker-compose"
__old_compose=1
__compose_version=$($__maybe_sudo docker-compose --version | sed -n -E -e "s/.*version [v]?([0-9.-]*).*/\1/ip")
if [ -n "${ETHDSECUNDO-}" ] || [ ! "${command}" = "update" ]; then # Don't run this twice
echo
echo "You are using docker-compose ${__compose_version}, which is unsupported by Docker, Inc."
echo "eth-docker will stop supporting it with Dencun, sometime fall 2023."
echo ""
echo "It is recommended that you replace compose V1 with compose V2."
while true; do
read -rp "Do you want to update compose to V2? (yes/no) " yn
case $yn in
[Nn]* ) echo "Please be sure to update compose yourself!"; break;;
* ) upgrade_compose; break;;
esac
done
fi
fi
if [ -n "$__maybe_sudo" ]; then
__compose_exe="sudo $__compose_exe"
fi
}
upgrade_compose() {
if ! type -P docker-compose >/dev/null 2>&1; then
echo "Compose has already been updated to V2"
return
fi
echo "Updating compose to V2"
if [[ "$__distro" = "ubuntu" ]]; then
${__auto_sudo} apt-get update && ${__auto_sudo} apt-get install -y ca-certificates curl gnupg lsb-release
__major_version=$(lsb_release -r | cut -d: -f2 | sed s/'^\t'// | cut -d. -f1)
if [ "${__major_version}" -lt 20 ]; then
echo "This script cannot update compose on Ubuntu ${__major_version}. Consider upgrading to 22.04 or 20.04"
exit 0
fi
${__auto_sudo} apt-get remove -y docker-compose
echo "Removed docker-compose"
${__auto_sudo} mkdir -p /etc/apt/keyrings
${__auto_sudo} curl -fsSL https://download.docker.com/linux/ubuntu/gpg | ${__auto_sudo} gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg
${__auto_sudo} echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | ${__auto_sudo} tee /etc/apt/sources.list.d/docker.list > /dev/null
${__auto_sudo} apt-get update
${__auto_sudo} apt-get install -y docker-compose-plugin
echo "Installed docker-compose-plugin"
__old_compose=0
__compose_exe="docker compose"
__compose_upgraded=1
elif [[ "$__distro" =~ "debian" ]]; then
${__auto_sudo} apt-get update && ${__auto_sudo} apt-get -y install ca-certificates curl gnupg lsb-release
__major_version=$(lsb_release -r | cut -f2)
if [ "${__major_version}" -lt 10 ]; then
echo "This script cannot update compose on Debian ${__major_version}. Consider upgrading to 11 or 12."
exit 0
fi
${__auto_sudo} apt-get remove -y docker-compose
echo "Removed docker-compose"
${__auto_sudo} mkdir -p /etc/apt/keyrings
${__auto_sudo} curl -fsSL https://download.docker.com/linux/debian/gpg | ${__auto_sudo} gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg
${__auto_sudo} echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | ${__auto_sudo} tee /etc/apt/sources.list.d/docker.list > /dev/null
${__auto_sudo} apt-get update
${__auto_sudo} apt-get install -y docker-compose-plugin
echo "Installed docker-compose-plugin"
__old_compose=0
__compose_exe="docker compose"
__compose_upgraded=1
else
echo "This script does not know how to update compose on $__distro"
fi
}
prep_prometheus() {
# Create custom-prom.yml if it doesn't exist
if [ ! -f "./prometheus/custom-prom.yml" ]; then
${__as_owner} touch "./prometheus/custom-prom.yml"
fi
}
handle_root() {
if [ "${EUID}" -eq 0 ]; then
__as_owner="sudo -u ${OWNER}"
__auto_sudo=""
else
__as_owner=""
__auto_sudo="sudo"
fi
}
check_for_snap() {
if [[ "$__distro" = "ubuntu" && -n "$(command -v snap)" ]] && snap list 2>/dev/null | grep -qw 'docker'; then
echo
echo "WARNING! Snap docker package detected. This WILL result in issues."
echo "Removing the package will delete volumes and require a resync,"
echo "as well as re-import of all validator keys."
echo
echo "Doing so is still highly recommended however."
echo
echo "The exact steps depend a little on whether there already is"
echo "an apt version of docker installed as well, but in a nutshell"
echo '"./ethd stop" followed by "sudo snap remove --purge docker"'
echo "and then a reboot, and as needed install docker.io or docker-ce with apt,"
echo "re-import keys and restart eth-docker."
echo
echo "Do join us on EthStaker Discord to work through this issue."
echo
echo "Aborting, this is not safe"
exit 1
fi
}
install() {
check_for_snap
set -e
read -rp "This will attempt to install docker and make your user part of the docker group. Do you wish to continue? (no/yes) " yn
case $yn in
[Yy]* ) ;;
* ) echo "Aborting, no changes made"; exit 0;;
esac
if [[ "$__distro" = "ubuntu" ]]; then
__major_version=$(lsb_release -r | cut -d: -f2 | sed s/'^\t'// | cut -d. -f1)
if [ "${__major_version}" -lt 20 ]; then
echo "This script cannot install docker on Ubuntu ${__major_version}. Consider upgrading to 22.04 or 20.04"
exit 0
fi
if [ -z "$(command -v docker)" ]; then
${__auto_sudo} apt-get update && ${__auto_sudo} apt-get install -y ca-certificates curl gnupg lsb-release whiptail bc chrony
${__auto_sudo} mkdir -p /etc/apt/keyrings
${__auto_sudo} curl -fsSL https://download.docker.com/linux/ubuntu/gpg | ${__auto_sudo} gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg
${__auto_sudo} echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | ${__auto_sudo} tee /etc/apt/sources.list.d/docker.list > /dev/null
${__auto_sudo} apt-get update
${__auto_sudo} apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
echo "Installed docker-ce and docker-compose-plugin"
else
echo "Docker is already installed"
fi
__groups=$(${__as_owner} groups)
if [[ ! "$__groups" =~ "docker" ]]; then
echo "Making your user part of the docker group"
${__auto_sudo} usermod -aG docker "${OWNER}"
echo "Please run newgrp docker or log out and back in"
else
echo "Your user is already part of the docker group"
fi
elif [[ "$__distro" =~ "debian" ]]; then
if [ -z "$(command -v docker)" ]; then
${__auto_sudo} apt-get update
${__auto_sudo} apt-get -y install ca-certificates curl gnupg lsb-release whiptail bc chrony
__major_version=$(lsb_release -r | cut -f2)
if [ "${__major_version}" -lt 10 ]; then
echo "This script cannot install docker on Debian ${__major_version}. Consider upgrading to 11 or 12."
exit 0
fi
${__auto_sudo} mkdir -p /etc/apt/keyrings
${__auto_sudo} curl -fsSL https://download.docker.com/linux/debian/gpg | ${__auto_sudo} gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg
${__auto_sudo} echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | ${__auto_sudo} tee /etc/apt/sources.list.d/docker.list > /dev/null
${__auto_sudo} apt-get update
${__auto_sudo} apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
echo "Installed docker-ce and docker-compose-plugin"
else
echo "Docker is already installed"
fi
__groups=$(${__as_owner} groups)
if [[ ! "$__groups" =~ "docker" ]]; then
echo "Making your user part of the docker group"
${__auto_sudo} usermod -aG docker "${OWNER}"
echo "Please run newgrp docker or log out and back in"
else
echo "Your user is already part of the docker group"
fi
else
echo "This script does not know how to install docker on $__distro"
fi
if ! [[ "$__distro" = "ubuntu" ]] || [[ "$__distro" =~ "debian" ]]; then
exit 0
fi
# We only get here on Ubuntu or Debian
__install_base=$(basename "$(dirname "$(realpath "${BASH_SOURCE[0]}")")")
if [ "${__install_base}" = "eth-docker" ]; then
read -rp "Do you want to be able to call 'ethd' from anywhere? (yes/no) " yn
case $yn in
[Nn]* ) exit 0;;
* ) ;;
esac
if grep -q "alias ethd" ~/.profile; then
sed -i'.original' -e "/alias ethd/d" ~/.profile
fi
echo "alias ethd=$(realpath "${BASH_SOURCE[0]}")" >>~/.profile
if grep -q "cat.*\.motd" ~/.profile; then
sed -i'.original' -e "/cat.*\.motd/d" ~/.profile
fi
echo "cat $(dirname "$(realpath "${BASH_SOURCE[0]}")")/.motd" >>~/.profile
echo "Go ahead and 'source ~/.profile' or log out and back in."
echo "After that, you can use the command 'ethd'."
fi
set +e
return 0
}
# Warn user if space is low, so they can prune
check_disk_space() {
__docker_dir=$(dodocker system info --format '{{.DockerRootDir}}')
__free_space=$(df -P "${__docker_dir}" | awk '/[0-9]%/{print $(NF-2)}')
re='^[0-9]+$'
if ! [[ "${__free_space}" =~ $re ]] ; then
echo "Unable to determine free disk space. This is likely a bug."
echo "df reports $(df -P "${__docker_dir}") and __free_space is ${__free_space}"
return
fi
var="COMPOSE_FILE"
value=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
var="AUTOPRUNE_NM"
auto_prune=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
# Literal match intended
# shellcheck disable=SC2076
if [[ "${value}" =~ "nethermind.yml" ]] && [[ "${__free_space}" -lt 314572800 ]]; then
echo ""
echo "You are running Nethermind and have less than 300 GiB of free disk space."
if [ "${auto_prune}" = true ]; then
echo "It should currently be auto-pruning, check logs with \"./ethd logs -f --tail 500 execution | grep Full\". Free space:"
else
echo "If the below reads above 250 GiB free, prune it with \"./ethd prune-nethermind\""
fi
echo ""
df -h "${__docker_dir}"
echo ""
elif [[ "${value}" =~ "geth.yml" ]] && [[ "${__free_space}" -lt 104857600 ]]; then
echo ""
echo "You are running Geth and have less than 100 GiB of free disk space."
echo "If Avail reads 40 GiB or more, prune with ./ethd prune-geth:"
echo ""
df -h "${__docker_dir}"
echo ""
echo "If it's less than 40 GiB, you may need to resync Geth from scratch."
echo ""
elif [[ "${__free_space}" -lt 52428800 ]]; then
echo ""
echo "You have less than 50 GiB of free disk space:"
echo ""
df -h "${__docker_dir}"
echo ""
echo "Pruning does not appear an option for your client mix."
echo "For Besu, Erigon or Reth, consider a resync."
echo "If total space is less than 1.5 TiB, consider cloning to a larger drive."
echo ""
fi
}
source_build() {
# Check whether there's a source-built client and if so, force it with --no-cache
var="COMPOSE_FILE"
value=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
case "${value}" in
*deposit-cli.yml* )
docompose --profile tools build --pull --no-cache deposit-cli-new
;;
esac
case "${value}" in
*mev-boost.yml* )
var="MEV_DOCKERFILE"
build=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
if [ "${build}" = "Dockerfile.source" ]; then
docompose build --pull --no-cache mev-boost
fi
;;
esac
case "${value}" in
*reth.yml* )
var="RETH_DOCKERFILE"
build=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
if [ "${build}" = "Dockerfile.source" ]; then
docompose build --pull --no-cache execution
fi
;;
*geth.yml* )
var="GETH_DOCKERFILE"
build=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
if [ "${build}" = "Dockerfile.source" ]; then
docompose build --pull --no-cache execution
fi
;;
*besu.yml* )
var="BESU_DOCKERFILE"
build=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
if [ "${build}" = "Dockerfile.source" ]; then
docompose build --pull --no-cache execution
fi
;;
*nethermind.yml* )
var="NM_DOCKERFILE"
build=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
if [ "${build}" = "Dockerfile.source" ]; then
docompose build --pull --no-cache execution
fi
;;
*erigon.yml* )
var="ERIGON_DOCKERFILE"
build=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
if [ "${build}" = "Dockerfile.source" ]; then
docompose build --pull --no-cache execution
fi
;;
*nimbus-el.yml* )
var="NIMEL_DOCKERFILE"
build=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
if [ "${build}" = "Dockerfile.source" ]; then
docompose build --pull --no-cache execution
fi
;;
esac
case "${value}" in
*lighthouse.yml* | *lighthouse-cl-only.yml* )
var="LH_DOCKERFILE"
build=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
if [ "${build}" = "Dockerfile.source" ]; then
docompose build --pull --no-cache consensus
fi
;;
*teku.yml* | *teku-cl-only.yml* )
var="TEKU_DOCKERFILE"
build=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
if [ "${build}" = "Dockerfile.source" ]; then
docompose build --pull --no-cache consensus
fi
;;
*lodestar.yml* | *lodestar-cl-only.yml* )
var="LS_DOCKERFILE"
build=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
if [ "${build}" = "Dockerfile.source" ]; then
docompose build --pull --no-cache consensus
fi
;;
*nimbus.yml* | *nimbus-cl-only.yml* )
var="NIM_DOCKERFILE"
build=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
if [ "${build}" = "Dockerfile.source" ]; then
docompose build --pull --no-cache consensus
fi
;;
*prysm.yml* | *prysm-cl-only.yml* )
var="PRYSM_DOCKERFILE"
build=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
if [ "${build}" = "Dockerfile.source" ]; then
docompose build --pull --no-cache consensus
fi
;;
esac
}
# Arguments are passed, but shellcheck doesn't recognize that
# shellcheck disable=SC2120
update() {
if [[ $(${__as_owner} git status --porcelain) ]]; then
__dirty=1
else
__dirty=0
fi
__free_space=$(df -P "$(pwd)" | awk '/[0-9]%/{print $(NF-2)}')
re='^[0-9]+$'
if ! [[ "${__free_space}" =~ $re ]] ; then
echo "Unable to determine free disk space. This is likely a bug."
echo "df reports $(df -P "$(pwd)") and __free_space is ${__free_space}"
elif [ "$(df -P "$(pwd)" | awk '/[0-9]%/{print $(NF-2)}')" -lt 1024 ]; then
echo "You have less than 1 MiB of space left on $(pwd)."
echo "Aborting, as an update is not safe."
exit 1
fi
__docker_dir=$(dodocker system info --format '{{.DockerRootDir}}')
__free_space=$(df -P "${__docker_dir}" | awk '/[0-9]%/{print $(NF-2)}')
re='^[0-9]+$'
if ! [[ "${__free_space}" =~ $re ]] ; then
echo "Unable to determine free disk space. This is likely a bug."
echo "df reports $(df -P "${__docker_dir}") and __free_space is ${__free_space}"
elif [ "${__free_space}" -lt 1048576 ]; then
echo "You have less than 1 GiB of space left on ${__docker_dir}."
echo "Aborting, as an update is not safe."
exit 1
fi
if [ -z "${ETHDSECUNDO-}" ]; then
if ${__as_owner} git branch | grep -q master; then
${__as_owner} git branch -m master main
${__as_owner} git fetch origin
${__as_owner} git branch -u origin/main main
${__as_owner} git remote set-head origin -a
fi
# Do not track changes to ext-network.yml
${__as_owner} git update-index --assume-unchanged ext-network.yml
${__as_owner} git config pull.rebase false
${__as_owner} git pull
export GITEXITCODE=$?
# BASH_SOURCE so newer code gets to do the update. Use an ENV var
# to avoid infinite loop
export ETHDSECUNDO=1
exec "${BASH_SOURCE[0]}" update "$@"
fi
__keeptargets=1
__targetcli=""
while :
do
if [ -z "${1+x}" ]; then
break
fi
case "$1" in
--keep-targets)
if [ -n "${__targetcli}" ]; then
echo "Error: --keep-targets and --refresh-targets cannot be used together; use either option once only"
exit 1
fi
__keeptargets=1
__targetcli="--keep-targets"
shift
;;
--refresh-targets)
if [ -n "${__targetcli}" ]; then
echo "Error: --keep-targets and --refresh-targets cannot be used together; use either option once only"
exit 1
fi
__keeptargets=0
__targetcli="--refresh-targets"
shift
;;
*)
echo "Error: Unknown option: $1" >&2
exit 1
;;
esac
done
# envmigrate used to be called w/ arguments and checks for that
# shellcheck disable=SC2119
envmigrate
if [ "${__switched_branch-}" -eq 1 ]; then
# This code has changed, run it again on the new branch
export ETHDSECUNDO=1 #Not strictly necessary but this way we don't rely on what happens earlier
export ETHDSWITCHED=1
exec "${BASH_SOURCE[0]}" update $__targetcli
fi
dodocker system prune --force
if [ ${__old_compose} -eq 1 ]; then
docompose --profile tools pull --ignore-pull-failures || true
else
docompose --profile tools pull --ignore-pull-failures --quiet || true
fi
source_build
docompose --profile tools build --pull
echo
if ! cmp -s "${ENV_FILE}" "${ENV_FILE}".source; then
${__as_owner} cp "${ENV_FILE}".source "${ENV_FILE}".bak
${__as_owner} rm "${ENV_FILE}".source
echo "Your ${ENV_FILE} configuration settings have been migrated to a fresh copy. You can \
find the original contents in ${ENV_FILE}.bak."
if [ $__keeptargets = "0" ]; then
echo "NB: If you made changes to the source or binary build targets, these have been \
reset to defaults."
fi
echo
echo "List of changes made to ${ENV_FILE} during migration - current on left, original on right:"
echo
diff -y --suppress-common-lines "${ENV_FILE}" "${ENV_FILE}".bak
if [ "$__pre_merge" -eq 1 ]; then
echo
echo "You appear to be coming from a pre-merge setup."
echo "A copy of your original settings is in .env.premerge"
echo
echo "Pay special attention to EL_NODE, as failover is no longer supported."
echo
echo "Decide whether to use mev-boost. Please see MEV_BOOST in .env for details."
fi
else
echo "No changes made to ${ENV_FILE} during update"
${__as_owner} rm "${ENV_FILE}".source
fi
if [ "$__el_infura" -eq 1 ]; then
echo
echo "Detected use of an Infura project as an EL or failover EL. This is no longer supported with merge."
echo "Please adjust your EL_NODE variable manually."
fi
if [ "$__el_adjusted" -eq 1 ]; then
echo
echo "Your EL_NODE variable has been adjusted to use the new Engine API port"
elif [ "$__pre_merge" -eq 1 ]; then
echo
echo "Your EL_NODE variable has not been adjusted to use the new Engine API port, as you had a non-standard value."
echo "Please take a look and adjust manually."
fi
echo
if [ -z "${GITEXITCODE+x}" ] || [ "${GITEXITCODE}" -eq 0 ]; then
echo "An \"./ethd up\" command will start using the new images and configuration."
else
echo "WARNING"
echo
echo "Updating eth-docker failed during \"git pull\""
echo
echo "Please try \"git pull\" manually."
echo "Do not run \"./ethd up\" until git can update eth-docker."
echo "The current partial update risks startup failure."
fi
if [[ "$__distro" = "ubuntu" ]]; then
__major_version=$(lsb_release -r | cut -d: -f2 | sed s/'^\t'// | cut -d. -f1)
if [ "${__major_version}" -lt 20 ]; then
echo
echo "Ubuntu ${__major_version} is older than the recommended 22.04 or 20.04 version"
echo
fi
fi
unset ETHDSECUNDO
unset GITEXITCODE
if [[ "${ETHDSWITCHED-}" -eq 1 ]]; then
unset ETHDSWITCHED
echo
echo "You were migrated to the $(${__as_owner} git name-rev --name-only HEAD) branch of eth-docker"
echo
fi
delete_erigon
# If this is called by an older version of ethd, envmigrate
# is in its own bash instance: Need to kill the ethd parent
# shellcheck disable=SC2009
if ps $PPID | grep -q "ethd"; then
echo
echo "Updated from an older version of eth-docker. You'll see \"Terminated\","
echo "which keeps the update from running twice. This is normal and will"
echo "only happen this once."
echo
kill $PPID
fi
check_for_snap
if [ "${__dirty}" -eq 1 ]; then
echo
echo "WARNING"
echo
echo "You have uncommitted local changes to eth-docker, which may interfere with updates."
echo "Please undo these changes or \"git commit\" them."
echo "These are the files with local changes:"
echo
${__as_owner} git status --porcelain
fi
}
# envmigrate used to be called w/ arguments and checks for that
# shellcheck disable=SC2120
envmigrate() {
if [ -z "${ETHDSECUNDO-}" ]; then
# We'd only ever hit this if called from an older version of ethd, so let's
# get the new version executed.
export ETHDSECUNDO=1
# Account for different ways that envmigrate was called in older code and
# set keep-targets correctly regardless
if [ -z "${KEEPTARGETS-}" ]; then
__keep=""
for var in "$@"; do
if [ "$var" = "--keep-targets" ]; then
__keep="--keep-targets"
fi
done
else
__keep=""
if [ "${KEEPTARGETS-}" -eq 1 ]; then
__keep="--keep-targets"
fi
fi
exec "${BASH_SOURCE[0]}" update ${__keep}
fi
if [ ! -f "./${ENV_FILE}" ]; then
return
fi
ALL_VARS=( COMPOSE_FILE FEE_RECIPIENT EL_NODE GRAFFITI DEFAULT_GRAFFITI NETWORK MEV_BOOST MEV_RELAYS MEV_MIN_BID MEV_NODE \
CL_MAX_PEER_COUNT CL_MIN_PEER_COUNT EL_MAX_PEER_COUNT EL_MIN_PEER_COUNT DOMAIN ACME_EMAIL AUTOPRUNE_NM LOGS_LABEL \
CF_DNS_API_TOKEN CF_ZONE_API_TOKEN CF_ZONE_ID AWS_PROFILE AWS_HOSTED_ZONE_ID GRAFANA_HOST DISTRIBUTED BESU_HEAP TEKU_HEAP \
PROM_HOST HOST_IP PRYSM_HOST EE_HOST EL_HOST EL_LB EL_WS_HOST EL_WS_LB CL_HOST CL_LB DDNS_SUBDOMAIN IPV6 \
DDNS_PROXY RAPID_SYNC_URL CL_NODE BEACON_STATS_API BEACON_STATS_MACHINE EL_P2P_PORT CL_P2P_PORT WEB3SIGNER \
PRYSM_PORT DOPPELGANGER PRYSM_UDP_PORT GRAFANA_PORT PROMETHEUS_PORT KEY_API_PORT TRAEFIK_WEB_PORT TRAEFIK_WEB_HTTP_PORT \
CL_REST_PORT EL_RPC_PORT EL_WS_PORT EE_PORT ERIGON_TORRENT_PORT LOG_LEVEL JWT_SECRET EL_EXTRAS CL_EXTRAS \
VC_EXTRAS ARCHIVE_NODE SSV_P2P_PORT SSV_P2P_PORT_UDP ERIGON_P2P_PORT_2 ERIGON_P2P_PORT_3 )
TARGET_VARS=( NIM_SRC_BUILD_TARGET NIM_DOCKER_TAG NIM_DOCKER_VC_TAG NIM_DOCKERFILE TEKU_SRC_BUILD_TARGET TEKU_DOCKER_TAG \
TEKU_DOCKERFILE LH_SRC_BUILD_TARGET LH_DOCKER_TAG LH_DOCKERFILE PRYSM_SRC_BUILD_TARGET \
PRYSM_DOCKER_TAG PRYSM_DOCKER_VC_TAG PRYSM_DOCKERFILE ERIGON_SRC_BUILD_TARGET ERIGON_DOCKER_TAG \
ERIGON_DOCKERFILE MEV_DOCKERFILE MEV_DOCKER_TAG NIMEL_SRC_BUILD_TARGET NIMEL_DOCKER_TAG NIMEL_DOCKERFILE \
LS_SRC_BUILD_TARGET LS_DOCKER_TAG LS_DOCKERFILE GETH_SRC_BUILD_TARGET GETH_DOCKER_TAG \
GETH_DOCKERFILE NM_SRC_BUILD_TARGET NM_DOCKER_TAG NM_DOCKERFILE BESU_SRC_BUILD_TARGET \
BESU_DOCKER_TAG BESU_DOCKERFILE SSV2_NODE_TAG DEPCLI_SRC_BUILD_TARGET DEPCLI_DOCKER_TAG W3S_DOCKER_TAG \
PG_DOCKER_TAG RETH_SRC_BUILD_TARGET RETH_DOCKER_TAG RETH_DOCKERFILE NODE_EXPORTER_IGNORE_MOUNT_REGEX )
OLD_VARS=( LH_PORT PRYSM_WEB_PORT EC_NODE REWARDS_TO GETH_CACHE CF_API_TOKEN \
EC_HOST EC_LB EC_WS_HOST EC_WS_LB CC_HOST CC_LB EC_P2P_PORT CC_NODE CC_P2P_PORT EC_RPC_PORT EC_WS_PORT )
NEW_VARS=( CL_P2P_PORT KEY_API_PORT EL_NODE FEE_RECIPIENT EL_EXTRAS CF_DNS_API_TOKEN \
EL_HOST EL_LB EL_WS_HOST EL_WS_LB CL_HOST CL_LB EL_P2P_PORT CL_NODE CL_P2P_PORT EL_RPC_PORT EL_WS_PORT )
if [ "${EUID}" -eq 0 ]; then
# Previous version of this tool when run as root may have created a root-owned .env.bak
if [ -f ./"${ENV_FILE}".bak ]; then
${__as_owner} rm "${ENV_FILE}".bak
fi
fi
${__as_owner} cp "${ENV_FILE}" "${ENV_FILE}".source
${__as_owner} cp default.env "${ENV_FILE}"
# Detect pre-merge
if grep -q "FALLBACK_NODE1" ".env.source"; then
__pre_merge=1
${__as_owner} cp .env.source .env.premerge
else
__pre_merge=0
fi
# Migrate over user settings
for var in "${ALL_VARS[@]}"; do
value=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env.source" || true)
if [ -n "${value}" ] || [ "${var}" = "GRAFFITI" ] || [ "${var}" = "MEV_RELAYS" ]; then
if [ "${var}" = "COMPOSE_FILE" ]; then
migrate_compose_file
fi
if [[ "${var}" = "NETWORK" && "${value}" =~ "prater" ]]; then
value="goerli"
fi
if [[ "${var}" = "HOST_IP" && "${value: -1}" != ":" ]]; then
value="${value}:" # ComposeV1 requires this so I can do v6
fi
# Handle & in GRAFFITI gracefully
sed -i'.original' -e "s~^\(${var}\s*=\s*\).*\$~\1${value//&/\\&}~" "${ENV_FILE}"
fi
done
if [ $__keeptargets = "1" ]; then
# Migrate over build targets
for var in "${TARGET_VARS[@]}"; do
value=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env.source" || true)
if [ -n "${value}" ]; then
sed -i'.original' -e "s~^\(${var}\s*=\s*\).*$~\1${value}~" "${ENV_FILE}"
fi
done
fi
# Move value from old variable name(s) to new one(s)
for index in "${!OLD_VARS[@]}"; do
var=${OLD_VARS[index]}
value=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env.source" || true)
if [ -n "${value}" ]; then
sed -i'.original' -e "s~^\(${NEW_VARS[index]}\s*=\s*\).*$~\1${value}~" "${ENV_FILE}"
fi
done
# Check whether we run a CL or VC, if so nag about FEE_RECIPIENT
var="COMPOSE_FILE"
value=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
# It's CL&VC, CL-only, or VC-only
# I do mean to match literally
# shellcheck disable=SC2076
if [[ "${value}" =~ "prysm.yml" || "${value}" =~ "lighthouse.yml" || "${value}" =~ "teku.yml" || "${value}" =~ "nimbus.yml" || "${value}" =~ "lodestar.yml" || \
"${value}" =~ "-cl-only.yml" || "${value}" =~ "-vc-only.yml" ]]; then
# Check for rewards
var="FEE_RECIPIENT"
value=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
if [[ -z "${value}" || ${value} != 0x* || ${#value} -ne 42 ]]; then
whiptail --msgbox "A fee recipient ETH wallet address is required in order to start the client. This is for post-merge priority fees and, optionally, MEV. Please enter a valid ETH address in the next screen. Refer to eth-docker docs (https://eth-docker.net/docs/About/Rewards) for more information.\n\nCAUTION: \"./ethd up\" will fail if no valid address is set" 16 75
__during_update=1
query_coinbase
set_value_in_env
fi
fi
# User signals it's a distributed setup and not to nag
# Ditto do not nag if we switched branch, as the code that does
# the check won't be accurate
var="DISTRIBUTED"
value=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
if [[ "${value}" = "true" || "${__switched_branch-}" -eq 1 ]]; then
${__as_owner} rm .env.original
return
fi
# Check for CL and EL, nag if we have only one without the other
var="COMPOSE_FILE"
value=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
# Case 1 ... CL, do we have an EL?
# I do mean to match literally
# shellcheck disable=SC2076
if [[ "${value}" =~ "prysm.yml" || "${value}" =~ "lighthouse.yml" || "${value}" =~ "teku.yml" || "${value}" =~ "nimbus.yml" || "${value}" =~ "lodestar.yml" || "${value}" =~ "-cl-only.yml" ]]; then
if [[ ! "${value}" =~ "geth.yml" && ! "${value}" =~ "besu.yml" && ! "${value}" =~ "erigon.yml" && ! "${value}" =~ "nethermind.yml" && ! "${value}" =~ "nimbus-el.yml" && ! "${value}" =~ "reth.yml" ]]; then
whiptail --msgbox "An Execution Layer client is required alongside your Consensus Layer client since Ethereum Merge.\n\nIf you run a distributed setup, you can shut off this nag screen by setting DISTRIBUTED=true in .env" 16 75
fi
# Case 2 ... EL, do we have a CL?
elif [[ "${value}" =~ "geth.yml" || "${value}" =~ "besu.yml" || "${value}" =~ "erigon.yml" || "${value}" =~ "nethermind.yml" || "${value}" =~ "nimbus-el.yml" || "${value}" =~ "reth.yml" ]]; then
if [[ ! "${value}" =~ "prysm.yml" && ! "${value}" =~ "lighthouse.yml" && ! "${value}" =~ "teku.yml" && ! "${value}" =~ "nimbus.yml" && ! "${value}" =~ "lodestar.yml" && ! "${value}" =~ "-cl-only.yml" ]]; then
whiptail --msgbox "A Consensus Layer client is required alongside your Execution Layer client since Ethereum Merge.\n\nIf you run a distributed setup, you can shut off this nag screen by setting DISTRIBUTED=true in .env" 16 75
fi
fi
# Adjust EL_NODE as needed
__el_adjusted=0
__el_infura=0
var="EL_NODE"
value=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
# I do mean to match literally
# shellcheck disable=SC2076
if [[ "${value}" =~ "infura.io" ]]; then
__el_infura=1
fi
if [[ "${value}" =~ "http://execution:8545" ]]; then
EL_NODE="http://execution:8551"
set_value_in_env
__el_adjusted=1
elif [[ "${value}" =~ "ws://execution:8546" || "${value}" =~ "ws://execution:8545" ]]; then
EL_NODE="ws://execution:8551"
set_value_in_env
__el_adjusted=1
fi
${__as_owner} rm .env.original
}
migrate_compose_file() {
# When this gets called $var is COMPOSE_FILE and $value is what is set in .env for it
# Some files have been renamed and others removed altogether
FROM_YML=( ec-shared.yml ec-traefik.yml cc-shared.yml grafana-insecure.yml prysm-web-insecure.yml lh-base-notz.yml lh-validator-notz.yml lh-slasher.yml teku-base-notz.yml teku-validator-notz.yml lh-consensus.yml lh-validator.yml lodestar-consensus.yml lodestar-validator.yml nimbus-consensus.yml prysm-consensus.yml prysm-consensus-rest.yml prysm-validator.yml teku-consensus.yml teku-validator.yml lh-base.yml lh-vc-only.yml lh-cl-only.yml nm.yml lighthouse-base.yml teku-base.yml nimbus-base.yml prysm-base.yml lodestar-base.yml traefik-cf-v6.yml prysm-web.yml blank-grafana.yml lh-grafana.yml lhcc-grafana.yml nimbus-grafana.yml prysm-grafana.yml teku-grafana.yml geth-grafana.yml erigon-grafana.yml oe.yml teku-stats.yml lh-stats.yml lh-stats-consensus.yml lh-stats-validator.yml traefik-shared.yml lighthouse-slasher.yml prysm-slasher.yml )
TO_YML=( el-shared.yml el-traefik.yml cl-shared.yml grafana-shared.yml prysm-web-shared.yml lighthouse-base.yml lighthouse-vc-only.yml lighthouse-slasher.yml teku-base.yml teku-vc-only.yml lighthouse-cl-only.yml lighthouse-vc-only.yml lodestar-cl-only.yml lodestar-vc-only.yml nimbus-cl-only.yml prysm-cl-only.yml prysm-cl-only.yml prysm-vc-only.yml teku-cl-only.yml teku-vc-only.yml lighthouse-base.yml lighthouse-vc-only.yml lighthouse-cl-only.yml nethermind.yml lighthouse.yml teku.yml nimbus.yml prysm.yml lodestar.yml traefik-cf.yml "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" )
__old_grafana=0
__new_grafana=0
__grafana_regex=".+-grafana\.yml"
__switched_branch=0
IFS=":"
set -o noglob
# Globbing is off
# shellcheck disable=SC2206
__ymlarray=($value) # split+glob with glob disabled, and split using : as delimiter
set +o noglob
# Unset restores default
unset IFS
value=""
for n in "${!__ymlarray[@]}"; do
__ymlfile="${__ymlarray[n]}"
if [[ "${__ymlfile}" =~ $__grafana_regex ]]; then
__old_grafana=1
fi
if [ "${__ymlfile}" = "grafana.yml" ]; then
__new_grafana=1
fi
for index in "${!FROM_YML[@]}"; do
if [ "${FROM_YML[index]}" = "${__ymlfile}" ]; then
__ymlfile=${TO_YML[index]}
break
fi
done
if [ -n "${__ymlfile}" ]; then
if [ -z "${value}" ]; then
value="${__ymlfile}"
else
value="${value}:${__ymlfile}"
fi
fi
done
if [ "${__new_grafana}" = 0 ] && [ "${__old_grafana}" = 1 ]; then
value="${value}:grafana.yml"
fi
}
delete_erigon() {
# Check for Erigon
var="COMPOSE_FILE"
value=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
# I do mean to match literally
# shellcheck disable=SC2076
if [[ ! "${value}" =~ "erigon.yml" ]]; then
return
fi
if ! dodocker volume ls -q | grep -q "$(basename "$(realpath .)")[_-]erigon-ec-data"; then
return
fi
echo "Detected Erigon. For merge, it will need to be re-synced from scratch"
echo
while true; do
read -rp "WARNING - About to delete the Erigon database. Do you wish to continue? (Y/n) " yn
case $yn in
[Nn]o | [Nn] ) echo "Aborting, no changes made"; exit 1;;
* ) break;;
esac
done
echo "Stopping Erigon container"
dodocker stop "$(dodocker ps -q -f "name=erigon")" && dodocker rm -f "$(dodocker ps -a -q -f "name=erigon")"
docompose stop execution && docompose rm -f execution
dodocker volume rm "$(dodocker volume ls -q -f "name=erigon-ec-data")"
echo ""
echo "Erigon stopped and database deleted."
echo ""
}
resync-execution() {
# Check for EL client
var="COMPOSE_FILE"
value=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
case "${value}" in
*erigon.yml* ) __el_volume='erigon-el-data'; __el_client="erigon";;
*geth.yml* ) __el_volume='geth-eth1-data'; __el_client="geth";;
*reth.yml* ) __el_volume='reth-el-data'; __el_client="reth";;
*besu.yml* ) __el_volume='besu-eth1-data'; __el_client="besu";;
*nethermind.yml* ) __el_volume='nm-eth1-data'; __el_client="nethermind";;
* ) echo "You do not appear to be running an execution layer client. Nothing to do."; return;;
esac
if ! dodocker volume ls -q | grep -q "$(basename "$(realpath .)")[_-]${__el_volume}"; then
echo "Did not find docker volume for ${__el_client}. Nothing to do."
return
fi
echo "This will stop ${__el_client} and delete its database to force a resync."
read -rp "WARNING - resync may take days. Do you wish to continue? (No/yes) " yn
case $yn in
[Yy][Ee][Ss] ) ;;
* ) echo "Aborting."; exit 1;;
esac
echo "Stopping ${__el_client} container"
docompose stop execution && docompose rm -f execution
dodocker volume rm "$(dodocker volume ls -q -f "name=${__el_volume}")"
echo ""
echo "${__el_client} stopped and database deleted."
echo ""
echo "Restarting for resync."
up
}
resync-consensus() {
# Check for CL client
var="COMPOSE_FILE"
value=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
case "${value}" in
*lighthouse.yml* ) __cl_volume='lhbeacon-data'; __cl_client="lighthouse";;
*lighthouse-cl-only.yml* ) __cl_volume='lhconsensus-data'; __cl_client="lighthouse";;
*teku.yml* ) __cl_volume='wipe-db'; __cl_client="teku";;
*teku-cl-only.yml* ) __cl_volume='tekuconsensus-data'; __cl_client="teku";;
*nimbus.yml* ) __cl_volume='wipe-db'; __cl_client="nimbus";;
*nimbus-cl-only.yml* ) __cl_volume='nimbus-consensus-data'; __cl_client="nimbus";;
*lodestar.yml* | *lodestar-cl-only.yml* ) __cl_volume='lsconsensus-data'; __cl_client="lodestar";;
*prysm.yml* ) __cl_volume='prysmbeacon-data'; __cl_client="prysm";;
*prysm-cl-only.yml* ) __cl_volume='prysmconsensus-data'; __cl_client="prysm";;
* ) echo "You do not appear to be running a consensus layer client. Nothing to do."; return;;
esac
if [ ! "${__cl_volume}" = "wipe-db" ] && ! dodocker volume ls -q | grep -q "$(basename "$(realpath .)")[_-]${__cl_volume}"; then
echo "Did not find docker volume for ${__cl_client}. Nothing to do."
return
fi
# Can we checkpoint sync?
var="RAPID_SYNC_URL"
value=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
echo "This will stop ${__cl_client} and delete its database to force a resync."
if [ -z "${value}" ]; then
read -rp "WARNING - RAPID_SYNC_URL not set, resync may take days. Do you wish to continue? (No/yes) " yn
else
read -rp "RAPID_SYNC_URL set, resync should finish in minutes. Do you wish to continue? (No/yes) " yn
fi
case $yn in
[Yy][Ee][Ss] ) ;;
* ) echo "Aborting."; exit 1;;
esac
echo "Stopping ${__cl_client} container"
docompose stop consensus && docompose rm -f consensus
if [ "${__cl_volume}" = "wipe-db" ]; then
docompose run --rm wipe-db
else
dodocker volume rm "$(dodocker volume ls -q -f "name=${__cl_volume}")"
fi
echo ""
echo "${__cl_client} stopped and database deleted."
echo ""
echo "Restarting for resync."
up
}
attach-geth() {
if [ ! -f "./${ENV_FILE}" ]; then
echo "${ENV_FILE} configuration file not found, aborting."
exit 1
fi
if ! grep -q '^COMPOSE_FILE=.*geth\.yml' "${ENV_FILE}" 2>/dev/null ; then
echo "You do not appear to be using Geth, aborting."
exit 1
fi
docompose exec -it execution bash -c "geth attach /var/lib/goethereum/geth.ipc"
}
prune-geth() {
__non_interactive=0
while :
do
if [ -z "${1+x}" ]; then
break
fi
case "$1" in
--non-interactive)
__non_interactive=1
shift
;;
*)
echo "Error: Unknown option: $1" >&2
exit 1
;;
esac
done
if [ ! -f "./${ENV_FILE}" ]; then
echo "${ENV_FILE} configuration file not found, aborting."
exit 1
fi