forked from eth-educators/eth-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint-vc.sh
executable file
·63 lines (57 loc) · 2.19 KB
/
docker-entrypoint-vc.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
#!/bin/bash
set -Eeuo pipefail
if [ "$(id -u)" = '0' ]; then
chown -R lhvalidator:lhvalidator /var/lib/lighthouse
exec gosu lhvalidator docker-entrypoint.sh "$@"
fi
if [[ "${NETWORK}" =~ ^https?:// ]]; then
echo "Custom testnet at ${NETWORK}"
repo=$(awk -F'/tree/' '{print $1}' <<< "${NETWORK}")
branch=$(awk -F'/tree/' '{print $2}' <<< "${NETWORK}" | cut -d'/' -f1)
config_dir=$(awk -F'/tree/' '{print $2}' <<< "${NETWORK}" | cut -d'/' -f2-)
echo "This appears to be the ${repo} repo, branch ${branch} and config directory ${config_dir}."
# For want of something more amazing, let's just fail if git fails to pull this
set -e
if [ ! -d "/var/lib/lighthouse/validators/testnet/${config_dir}" ]; then
mkdir -p /var/lib/lighthouse/validators/testnet
cd /var/lib/lighthouse/validators/testnet
git init --initial-branch="${branch}"
git remote add origin "${repo}"
git config core.sparseCheckout true
echo "${config_dir}" > .git/info/sparse-checkout
git pull origin "${branch}"
fi
set +e
__network="--testnet-dir=/var/lib/lighthouse/validators/testnet/${config_dir}"
else
__network="--network=${NETWORK}"
fi
# Check whether we should use MEV Boost
if [ "${MEV_BOOST}" = "true" ]; then
__mev_boost="--builder-proposals"
echo "MEV Boost enabled"
else
__mev_boost=""
fi
# Check whether we should send stats to beaconcha.in
if [ -n "${BEACON_STATS_API}" ]; then
__beacon_stats="--monitoring-endpoint https://beaconcha.in/api/v1/client/metrics?apikey=${BEACON_STATS_API}&machine=${BEACON_STATS_MACHINE}"
else
__beacon_stats=""
fi
# Check whether we should enable doppelganger protection
if [ "${DOPPELGANGER}" = "true" ]; then
__doppel="--enable-doppelganger-protection"
echo "Doppelganger protection enabled, VC will pause for 2 epochs"
else
__doppel=""
fi
if [ "${DEFAULT_GRAFFITI}" = "true" ]; then
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" ${__network} ${__mev_boost} ${__beacon_stats} ${__doppel} ${VC_EXTRAS}
else
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" ${__network} "--graffiti" "${GRAFFITI}" ${__mev_boost} ${__beacon_stats} ${__doppel} ${VC_EXTRAS}
fi