forked from eth-educators/eth-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
executable file
·89 lines (76 loc) · 2.88 KB
/
docker-entrypoint.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
#!/bin/sh
set -eu
cd /etc/prometheus
select_clients() {
# Start from scratch every time
rm -rf rootless.d
mkdir rootless.d
case "$CLIENT" in
*lighthouse.yml* ) cp ./rootless/lh-prom.yml ./rootless.d ;;
*lighthouse-cl-only* ) cp ./rootless/lhcc-prom.yml ./rootless.d ;;
*prysm.yml* ) cp ./rootless/prysm-prom.yml ./rootless.d ;;
*prysm-cl-only* ) cp ./rootless/prysmcc-prom.yml ./rootless.d ;;
*nimbus.yml* ) cp ./rootless/nimbus-prom.yml ./rootless.d ;;
*nimbus-cl-only* ) cp ./rootless/nimbus-prom.yml ./rootless.d ;;
*teku.yml* ) cp ./rootless/teku-prom.yml ./rootless.d ;;
*teku-cl-only* ) cp ./rootless/teku-prom.yml ./rootless.d ;;
*lodestar.yml* ) cp ./rootless/ls-prom.yml ./rootless.d ;;
*lodestar-cl-only* ) cp ./rootless/lscc-prom.yml ./rootless.d ;;
* ) ;;
esac
case "$CLIENT" in
*geth* ) cp ./rootless/geth-prom.yml ./rootless.d ;;
*erigon* ) cp ./rootless/erigon-prom.yml ./rootless.d ;;
*besu* ) cp ./rootless/besu-prom.yml ./rootless.d ;;
*nethermind* ) cp ./rootless/nethermind-prom.yml ./rootless.d ;;
*reth* ) cp ./rootless/reth-prom.yml ./rootless.d ;;
esac
case "$CLIENT" in
*web3signer.yml* ) cp ./rootless/web3signer-prom.yml ./rootless.d ;;
esac
case "$CLIENT" in
*ssv.yml* ) cp ./rootless/ssv-prom.yml ./rootless.d ;;
esac
case "$CLIENT" in
*traefik-* ) cp ./rootless/traefik-prom.yml ./rootless.d ;;
esac
__num_files="$(find ./rootless.d -type f | wc -l)"
if [ "$__num_files" -gt 0 ]; then
echo "Activated $__num_files configuration files"
else
echo "No Prometheus configurations have been enabled based on the provided CLIENT variable"
fi
}
__config_file=/etc/prometheus/prometheus.yml
prepare_config() {
# CLIENT is only set for rootless mode
if [ -z "${CLIENT:-}" ]; then
echo "No Client information passed, running in Docker target detection mode"
__base_config=base-config.yml
else
echo "Client information detected, compiling prometheus config"
select_clients
__base_config=rootless-base-config.yml
fi
# Merge custom config overrides, if provided
if [ -s custom-prom.yml ]; then
echo "Applying custom configuration"
# $item isn't a shell variable, single quotes OK here
# shellcheck disable=SC2016
yq eval-all '. as $item ireduce ({}; . *+ $item)' "${__base_config}" custom-prom.yml > "${__config_file}"
else
echo "No custom configuration detected"
cp "${__base_config}" "${__config_file}"
fi
}
# Check if --config.file was passed in the command arguments
# If it was, then display a warning and skip all our manual processing
for var in "$@"; do
case "$var" in
--config.file* )
echo "WARNING - Manual setting of --config.file found, bypassing automated config preparation in favour of supplied argument"
/bin/prometheus "$@"
esac
done
prepare_config
exec /bin/prometheus "$@" --config.file="${__config_file}"