forked from MetisProtocol/metis-replica-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeth.sh
More file actions
executable file
·74 lines (66 loc) · 2.1 KB
/
geth.sh
File metadata and controls
executable file
·74 lines (66 loc) · 2.1 KB
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
#!/bin/sh
set -eou
RETRIES=${RETRIES:-40}
VERBOSITY=${VERBOSITY:-6}
if [ -z "$DATADIR" ]; then
echo "Must pass DATADIR"
exit 1
fi
if [ -z "$BLOCK_SIGNER_PRIVATE_KEY" ]; then
echo "Must pass BLOCK_SIGNER_PRIVATE_KEY"
exit 1
fi
if [ -z "$BLOCK_SIGNER_PRIVATE_KEY_PASSWORD" ]; then
echo "Must pass BLOCK_SIGNER_PRIVATE_KEY_PASSWORD"
exit 1
fi
if [ -z "$L2GETH_GENESIS_URL" ]; then
echo "Must pass L2GETH_GENESIS_URL"
exit 1
fi
if [[ -z $BLOCK_SIGNER_ADDRESS ]]; then
echo "Must pass BLOCK_SIGNER_ADDRESS"
exit 1
fi
# Check for an existing chaindata folder.
# If it exists, assume it's correct and skip geth init step
GETH_CHAINDATA_DIR=$DATADIR/geth/chaindata
if [ -d "$GETH_CHAINDATA_DIR" ]; then
echo "$GETH_CHAINDATA_DIR existing, skipping geth init"
else
echo "$GETH_CHAINDATA_DIR missing, running geth init"
echo "Retrieving genesis file $L2GETH_GENESIS_URL"
TEMP_DIR=$(mktemp -d)
wget -O "$TEMP_DIR"/genesis.json "$L2GETH_GENESIS_URL"
geth init --datadir=/"$DATADIR" "$TEMP_DIR"/genesis.json
fi
# Check for an existing keystore folder.
# If it exists, assume it's correct and skip geth acount import step
GETH_KEYSTORE_DIR=$DATADIR/keystore
mkdir -p "$GETH_KEYSTORE_DIR"
GETH_KEYSTORE_KEYS=$(find "$GETH_KEYSTORE_DIR" -type f)
if [ ! -z "$GETH_KEYSTORE_KEYS" ]; then
echo "$GETH_KEYSTORE_KEYS exist, skipping account import if any keys are present"
else
echo "$GETH_KEYSTORE_DIR missing, running account import"
echo -n "$BLOCK_SIGNER_PRIVATE_KEY_PASSWORD" >"$DATADIR"/password
echo -n "$BLOCK_SIGNER_PRIVATE_KEY" >"$DATADIR"/block-signer-key
geth account import \
--datadir=/"$DATADIR" \
--password "$DATADIR"/password \
"$DATADIR"/block-signer-key
fi
echo "l2geth setup complete"
# start the geth peer node
echo "Starting Geth peer node"
exec geth \
--datadir "$DATADIR" \
--verbosity="$VERBOSITY" \
--password "$DATADIR/password" \
--allow-insecure-unlock \
--unlock $BLOCK_SIGNER_ADDRESS \
--mine \
--miner.etherbase $BLOCK_SIGNER_ADDRESS \
--syncmode full \
--gcmode archive \
"$@"