-
Notifications
You must be signed in to change notification settings - Fork 20
/
docker-entrypoint.sh
executable file
·86 lines (71 loc) · 2.06 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
#!/bin/bash
export TARAXA_CONF_PATH=${TARAXA_CONF_PATH:=/root/.taraxa/conf_taraxa.json}
export TARAXA_PERSISTENT_PATH=${TARAXA_PERSISTENT_PATH:=/root/.taraxa}
export TARAXA_COPY_COREDUMPS=${TARAXA_COPY_COREDUMPS:=true}
export TARAXA_SLEEP_DIAGNOSE=${TARAXA_SLEEP_DIAGNOSE:=false}
FLAGS=""
if [[ -z "${HOSTNAME}" ]]; then
echo "HOSTNAME is not set."
else
INDEX=${HOSTNAME##*-}
ADVERTISED_IP_NAME="ADVERTISED_IP_$INDEX"
ADVERTISED_IP=${!ADVERTISED_IP_NAME}
if [[ -z "${ADVERTISED_IP}" ]]; then
echo "ADVERTISED_IP is not set."
else
if [ "$ADVERTISED_IP" = "auto" ]; then
ADVERTISED_IP=$(curl icanhazip.com 2>/dev/null)
fi
FLAGS="--public-ip ${ADVERTISED_IP}"
fi
ADVERTISED_PORT_NAME="ADVERTISED_PORT_$INDEX"
ADVERTISED_PORT=${!ADVERTISED_PORT_NAME}
if [[ -z "${ADVERTISED_PORT}" ]]; then
echo "ADVERTISED_PORT is not set."
else
FLAGS="$FLAGS --port ${ADVERTISED_PORT}"
fi
fi
case $1 in
taraxa-bootnode)
echo "Starting taraxa-bootnode..."
taraxa-bootnode $FLAGS "${@:2}"
;;
taraxad)
echo "Starting taraxad..."
taraxad $FLAGS "${@:2}"
;;
join)
echo "Starting taraxad..."
taraxad $FLAGS \
--config $TARAXA_CONF_PATH \
--chain-id $2
;;
single)
echo "Starting taraxad..."
taraxad $FLAGS \
--config $TARAXA_CONF_PATH
;;
exec)
exec "${@:2}"
;;
*)
echo "You should choose between:"
echo "taraxa-bootnode, taraxad, single, join {NAMED_NETWOTK}"
;;
esac
# Hack to copy coredumps on K8s (gke) current /proc/sys/kernel/core_pattern
if [ "$TARAXA_COPY_COREDUMPS" = true ] ; then
echo "Copying dump (if any) to $TARAXA_PERSISTENT_PATH"
find / -maxdepth 1 -type f -name '*core*' -exec cp -v "{}" $TARAXA_PERSISTENT_PATH \;
fi
# Hack to sleep forever so devs can diagnose the pod on k8s
# We should not set Liveness/Readiness for this to work
if [ "$TARAXA_SLEEP_DIAGNOSE" = true ] ; then
echo "Sleeping forever for diagnosis"
while true
do
echo "Crashed. Waiting on diagnosis..."
sleep 300
done
fi