7
7
# ask_reset_dir_func checks if the directory passed in exists, and if so asks the user whether it
8
8
# should delete it. Note that on linux, docker may have created the directory with root
9
9
# permissions, so we may need to ask the user to delete it with sudo
10
+ # Creates a flag file to indicate if the directory was reset
10
11
define ask_reset_dir_func
11
12
@abs_path=$(abspath $(1 ) ) ; \
13
+ rm -f .tmp/.dir_was_reset; \
12
14
if test -d "$$abs_path"; then \
13
15
read -p "Directory '$$abs_path' exists. Do you want to delete it? (y/n): " confirm && \
14
16
if [ "$$confirm" = "y" ]; then \
@@ -17,10 +19,13 @@ define ask_reset_dir_func
17
19
if test -d "$$abs_path"; then \
18
20
echo "Failed to delete directory '$$abs_path'."; \
19
21
exit 1; \
22
+ else \
23
+ mkdir -p .tmp && touch .tmp/.dir_was_reset; \
20
24
fi; \
21
25
fi \
22
26
else \
23
27
echo "Directory '$$abs_path' does not exist."; \
28
+ mkdir -p .tmp && touch .tmp/.dir_was_reset; \
24
29
fi
25
30
endef
26
31
@@ -76,12 +81,18 @@ start-reth:
76
81
# # Start an ephemeral `geth` node with docker
77
82
start-geth :
78
83
$(call ask_reset_dir_func, $(ETH_DATA_DIR ) )
79
- docker run \
80
- --rm -v $(PWD ) /${TESTAPP_FILES_DIR} :/${TESTAPP_FILES_DIR} \
81
- -v $(PWD ) /.tmp:/.tmp \
82
- ghcr.io/berachain/bera-geth:latest init \
83
- --datadir ${ETH_DATA_DIR} \
84
- ${ETH_GENESIS_PATH}
84
+ @if [ -f .tmp/.dir_was_reset ]; then \
85
+ echo " Initializing geth..." ; \
86
+ docker run \
87
+ --rm -v $(PWD ) /${TESTAPP_FILES_DIR} :/${TESTAPP_FILES_DIR} \
88
+ -v $(PWD ) /.tmp:/.tmp \
89
+ ghcr.io/berachain/bera-geth:latest init \
90
+ --datadir ${ETH_DATA_DIR} \
91
+ ${ETH_GENESIS_PATH} ; \
92
+ rm -f .tmp/.dir_was_reset; \
93
+ else \
94
+ echo " Skipping geth init (directory was not reset)" ; \
95
+ fi
85
96
86
97
docker run \
87
98
-p 30303:30303 \
@@ -114,13 +125,19 @@ start-bepolia:
114
125
115
126
start-geth-bepolia :
116
127
$(call ask_reset_dir_func, $(ETH_DATA_DIR ) )
117
- docker run \
118
- --rm -v $(PWD ) /${TESTAPP_FILES_DIR} :/${TESTAPP_FILES_DIR} \
119
- --rm -v $(PWD ) /${BEPOLIA_NETWORK_FILES_DIR} :/${BEPOLIA_NETWORK_FILES_DIR} \
120
- -v $(PWD ) /.tmp:/.tmp \
121
- ghcr.io/berachain/bera-geth:latest init \
122
- --datadir ${ETH_DATA_DIR} \
123
- ${BEPOLIA_ETH_GENESIS_PATH}
128
+ @if [ -f .tmp/.dir_was_reset ]; then \
129
+ echo " Initializing geth..." ; \
130
+ docker run \
131
+ --rm -v $(PWD ) /${TESTAPP_FILES_DIR} :/${TESTAPP_FILES_DIR} \
132
+ --rm -v $(PWD ) /${BEPOLIA_NETWORK_FILES_DIR} :/${BEPOLIA_NETWORK_FILES_DIR} \
133
+ -v $(PWD ) /.tmp:/.tmp \
134
+ ghcr.io/berachain/bera-geth:latest init \
135
+ --datadir ${ETH_DATA_DIR} \
136
+ ${BEPOLIA_ETH_GENESIS_PATH} ; \
137
+ rm -f .tmp/.dir_was_reset; \
138
+ else \
139
+ echo " Skipping geth init (directory was not reset)" ; \
140
+ fi
124
141
125
142
@# Read bootnodes from the file; the file is mounted into the container.
126
143
@bootnodes=`cat $(PWD)/$(BEPOLIA_NETWORK_FILES_DIR)/el-bootnodes.txt`; \
@@ -181,13 +198,19 @@ start-mainnet:
181
198
# discovery bootnodes by region, refer to testing/networks/80094/el-bootnodes.txt
182
199
start-geth-mainnet :
183
200
$(call ask_reset_dir_func, $(ETH_DATA_DIR ) )
184
- docker run \
185
- --rm -v $(PWD ) /${TESTAPP_FILES_DIR} :/${TESTAPP_FILES_DIR} \
186
- --rm -v $(PWD ) /${MAINNET_NETWORK_FILES_DIR} :/${MAINNET_NETWORK_FILES_DIR} \
187
- -v $(PWD ) /.tmp:/.tmp \
188
- ghcr.io/berachain/bera-geth:latest init \
189
- --datadir ${ETH_DATA_DIR} \
190
- ${MAINNET_ETH_GENESIS_PATH}
201
+ @if [ -f .tmp/.dir_was_reset ]; then \
202
+ echo " Initializing geth..." ; \
203
+ docker run \
204
+ --rm -v $(PWD ) /${TESTAPP_FILES_DIR} :/${TESTAPP_FILES_DIR} \
205
+ --rm -v $(PWD ) /${MAINNET_NETWORK_FILES_DIR} :/${MAINNET_NETWORK_FILES_DIR} \
206
+ -v $(PWD ) /.tmp:/.tmp \
207
+ ghcr.io/berachain/bera-geth:latest init \
208
+ --datadir ${ETH_DATA_DIR} \
209
+ ${MAINNET_ETH_GENESIS_PATH} ; \
210
+ rm -f .tmp/.dir_was_reset; \
211
+ else \
212
+ echo " Skipping geth init (directory was not reset)" ; \
213
+ fi
191
214
192
215
@# Read bootnodes from the file; the file is mounted into the container.
193
216
@bootnodes=`cat $(PWD)/$(MAINNET_NETWORK_FILES_DIR)/el-peers.txt`; \
0 commit comments