2022-10-14 03:18:39 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-04-19 06:52:13 +00:00
|
|
|
# See https://linuxconfig.org/how-to-propagate-a-signal-to-child-processes-from-a-bash-script
|
|
|
|
cleanup() {
|
|
|
|
echo "Signal received, cleaning up..."
|
|
|
|
kill $(jobs -p)
|
|
|
|
|
|
|
|
wait
|
|
|
|
echo "Done"
|
|
|
|
}
|
|
|
|
trap 'cleanup' SIGINT SIGTERM
|
|
|
|
|
|
|
|
if [ "true" == "$RUN_BOOTNODE" ]; then
|
2022-10-31 17:43:49 +00:00
|
|
|
cd /opt/testnet/build/cl
|
|
|
|
python3 -m http.server 3000 &
|
|
|
|
|
|
|
|
|
2022-10-14 03:18:39 +00:00
|
|
|
cd /opt/testnet/cl
|
2023-04-19 06:52:13 +00:00
|
|
|
./bootnode.sh 2>&1 | tee /var/log/lighthouse_bootnode.log &
|
|
|
|
bootnode_pid=$!
|
|
|
|
|
|
|
|
wait $bootnode_pid
|
2022-10-14 03:18:39 +00:00
|
|
|
else
|
|
|
|
while [ 1 -eq 1 ]; do
|
2022-10-31 17:43:49 +00:00
|
|
|
echo "Waiting on geth ..."
|
2022-10-14 03:18:39 +00:00
|
|
|
sleep 5
|
|
|
|
result=`wget --no-check-certificate --quiet \
|
|
|
|
-O - \
|
|
|
|
--method POST \
|
|
|
|
--timeout=0 \
|
|
|
|
--header 'Content-Type: application/json' \
|
2022-10-31 17:43:49 +00:00
|
|
|
--body-data '{ "jsonrpc": "2.0", "id": 1, "method": "eth_blockNumber", "params": [] }' "${ETH1_ENDPOINT:-localhost:8545}" | jq -r '.result'`
|
2022-10-14 03:18:39 +00:00
|
|
|
if [ ! -z "$result" ] && [ "null" != "$result" ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
cd /opt/testnet/cl
|
|
|
|
|
|
|
|
if [ -z "$LIGHTHOUSE_GENESIS_STATE_URL" ]; then
|
2023-04-19 06:52:13 +00:00
|
|
|
# Check if beacon node data exists to avoid resetting genesis time on a restart
|
|
|
|
if [ -d /opt/testnet/build/cl/node_"$NODE_NUMBER"/beacon ]; then
|
|
|
|
echo "Skipping genesis time reset"
|
|
|
|
else
|
|
|
|
./reset_genesis_time.sh
|
|
|
|
fi
|
2022-10-14 03:18:39 +00:00
|
|
|
else
|
|
|
|
while [ 1 -eq 1 ]; do
|
|
|
|
echo "Waiting on Genesis time ..."
|
|
|
|
sleep 5
|
|
|
|
result=`wget --no-check-certificate --quiet -O - --timeout=0 $LIGHTHOUSE_GENESIS_STATE_URL | jq -r '.data.genesis_time'`
|
|
|
|
if [ ! -z "$result" ]; then
|
2022-11-03 22:31:14 +00:00
|
|
|
./reset_genesis_time.sh $result
|
|
|
|
break;
|
2022-10-14 03:18:39 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2022-10-31 17:43:49 +00:00
|
|
|
if [ ! -z "$ENR_URL" ]; then
|
|
|
|
while [ 1 -eq 1 ]; do
|
|
|
|
echo "Waiting on ENR for boot node..."
|
|
|
|
sleep 5
|
|
|
|
result=`wget --no-check-certificate --quiet -O - --timeout=0 $ENR_URL`
|
|
|
|
if [ ! -z "$result" ]; then
|
2022-11-03 22:31:14 +00:00
|
|
|
export ENR="$result"
|
|
|
|
break;
|
2022-10-31 17:43:49 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2022-10-14 03:18:39 +00:00
|
|
|
export JWTSECRET="/opt/testnet/build/cl/jwtsecret"
|
|
|
|
echo -n "$JWT" > $JWTSECRET
|
|
|
|
|
|
|
|
./beacon_node.sh 2>&1 | tee /var/log/lighthouse_bn.log &
|
2023-04-19 06:52:13 +00:00
|
|
|
beacon_pid=$!
|
2022-10-14 03:18:39 +00:00
|
|
|
./validator_client.sh 2>&1 | tee /var/log/lighthouse_vc.log &
|
2023-04-19 06:52:13 +00:00
|
|
|
validator_pid=$!
|
2022-10-14 03:18:39 +00:00
|
|
|
|
2023-04-19 06:52:13 +00:00
|
|
|
wait $beacon_pid $validator_pid
|
2022-10-14 03:18:39 +00:00
|
|
|
fi
|