Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

fix: multiple docker builder searcher support #41

Merged
merged 2 commits into from
Oct 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,44 @@ echo "Node Type: $NODE_TYPE"
# Define paths
KEY_PATH="/keys"
CONFIG_PATH="/config"
IP=$(ifconfig eth0|grep inet|awk -F" " '{print $2}'|cut -d":" -f2)

# Check whether the private key file based on node type already exists
if [ "$NODE_TYPE" = "bootnode" ]; then
PRIV_KEY_FILE="${KEY_PATH}/bootnode"
CONFIG_FILE="${CONFIG_PATH}/bootnode.yml"
elif [ "$NODE_TYPE" = "builder" ]; then
PRIV_KEY_FILE="${KEY_PATH}/builder"
CONFIG_FILE="${CONFIG_PATH}/builder.yml"
PRIV_KEY_FILE="${KEY_PATH}/builder${IP}"
CONFIG_FILE="${CONFIG_PATH}/builder${IP}.yml"

if [ ! -f "$CONFIG_FILE" ]; then
cd $CONFIG_PATH
cp builder.yml builder${IP}.yml
cd -
fi
else
PRIV_KEY_FILE="${KEY_PATH}/searcher"
CONFIG_FILE="${CONFIG_PATH}/searcher.yml"
PRIV_KEY_FILE="${KEY_PATH}/searcher${IP}"
CONFIG_FILE="${CONFIG_PATH}/searcher${IP}.yml"

if [ ! -f "$CONFIG_FILE" ]; then
cd $CONFIG_PATH
cp searcher.yml searcher${IP}.yml
cd -
fi

fi

# Generate the private key based on node type only if it doesn't exist yet
if [ ! -f "$PRIV_KEY_FILE" ]; then

if [ "$NODE_TYPE" != "bootnode" ]; then
/app/mev-commit create-key ${PRIV_KEY_FILE}
# Update the private key path in the configuration
sed -i "s|priv_key_file:.*|priv_key_file: ${PRIV_KEY_FILE}|" ${CONFIG_FILE}
else
echo "Key file ${PRIV_KEY_FILE} already exists. Skipping key creation."
fi

if [ "$NODE_TYPE" == "bootnode" ] && [ ! -f "$PRIV_KEY_FILE" ];then
/app/mev-commit create-key ${PRIV_KEY_FILE}
# Update the private key path in the configuration
sed -i "s|priv_key_file:.*|priv_key_file: ${PRIV_KEY_FILE}|" ${CONFIG_FILE}
fi

# If this is not the bootnode, update the bootnodes entry with P2P ID
Expand Down
Loading