From 28d7e8894c27c2457ffee1d1b0f5dc58af74e0b1 Mon Sep 17 00:00:00 2001 From: Sebastian <379651+czarly@users.noreply.github.com> Date: Wed, 19 Mar 2025 14:04:41 +0100 Subject: [PATCH] fix --- berachain/bepolia/script/init.sh | 68 ++++++++++++++++---------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/berachain/bepolia/script/init.sh b/berachain/bepolia/script/init.sh index 4fdb9cb7..20553382 100644 --- a/berachain/bepolia/script/init.sh +++ b/berachain/bepolia/script/init.sh @@ -2,43 +2,45 @@ set -e # Exit on failure -apt-get update && apt-get install -y curl - echo "MONIKER: $MONIKER" # this goes first because it won't overwrite shit -/usr/bin/beacond init ${MONIKER} --chain-id bepolia-beacon-80069 --consensus-key-algo bls12_381 --home /root/.beacond/ +if /usr/bin/beacond init ${MONIKER} --chain-id bepolia-beacon-80069 --consensus-key-algo bls12_381 --home /root/.beacond/; then + apt-get update && apt-get install -y curl + + # Define variables + CONFIG_DIR="/root/.beacond/config" + CONFIG_TOML_URL="https://raw.githubusercontent.com/berachain/beacon-kit/main/testing/networks/80069/config.toml" + APP_TOML_URL="https://raw.githubusercontent.com/berachain/beacon-kit/main/testing/networks/80069/app.toml" + SEEDS_URL="https://raw.githubusercontent.com/berachain/beacon-kit/main/testing/networks/80069/cl-seeds.txt" + + # Create config directory + mkdir -p "$CONFIG_DIR" + + # Download config files + curl -sL "$CONFIG_TOML_URL" -o "$CONFIG_DIR/config.toml" + curl -sL "$APP_TOML_URL" -o "$CONFIG_DIR/app.toml" + + # Update moniker if set + if [ -n "$MONIKER" ] && [ -f "$CONFIG_DIR/config.toml" ]; then + sed -i "s/^moniker = \".*\"/moniker = \"$MONIKER\"/" "$CONFIG_DIR/config.toml" + fi + + # Fetch and format SEEDS + SEEDS=$(curl -s "$SEEDS_URL" | tail -n +2 | tr '\n' ',' | sed 's/,$//') + + # Update seeds and persistent_peers + if [ -n "$SEEDS" ] && [ -f "$CONFIG_DIR/config.toml" ]; then + sed -i "s/^seeds = \".*\"/seeds = \"$SEEDS\"/" "$CONFIG_DIR/config.toml" + sed -i "s/^persistent_peers = \".*\"/persistent_peers = \"$SEEDS\"/" "$CONFIG_DIR/config.toml" + fi -# Define variables -CONFIG_DIR="/root/.beacond/config" -CONFIG_TOML_URL="https://raw.githubusercontent.com/berachain/beacon-kit/main/testing/networks/80069/config.toml" -APP_TOML_URL="https://raw.githubusercontent.com/berachain/beacon-kit/main/testing/networks/80069/app.toml" -SEEDS_URL="https://raw.githubusercontent.com/berachain/beacon-kit/main/testing/networks/80069/cl-seeds.txt" - -# Create config directory -mkdir -p "$CONFIG_DIR" - -# Download config files -curl -sL "$CONFIG_TOML_URL" -o "$CONFIG_DIR/config.toml" -curl -sL "$APP_TOML_URL" -o "$CONFIG_DIR/app.toml" - -# Update moniker if set -if [ -n "$MONIKER" ] && [ -f "$CONFIG_DIR/config.toml" ]; then - sed -i "s/^moniker = \".*\"/moniker = \"$MONIKER\"/" "$CONFIG_DIR/config.toml" -fi - -# Fetch and format SEEDS -SEEDS=$(curl -s "$SEEDS_URL" | tail -n +2 | tr '\n' ',' | sed 's/,$//') - -# Update seeds and persistent_peers -if [ -n "$SEEDS" ] && [ -f "$CONFIG_DIR/config.toml" ]; then - sed -i "s/^seeds = \".*\"/seeds = \"$SEEDS\"/" "$CONFIG_DIR/config.toml" - sed -i "s/^persistent_peers = \".*\"/persistent_peers = \"$SEEDS\"/" "$CONFIG_DIR/config.toml" -fi - -# Update RPC dial URL in app.toml -if [ -f "$CONFIG_DIR/app.toml" ]; then - sed -i "s|^rpc-dial-url = \".*\"|rpc-dial-url = \"http://berachain-bepolia:8551\"|" "$CONFIG_DIR/app.toml" + # Update RPC dial URL in app.toml + if [ -f "$CONFIG_DIR/app.toml" ]; then + sed -i "s|^rpc-dial-url = \".*\"|rpc-dial-url = \"http://berachain-bepolia:8551\"|" "$CONFIG_DIR/app.toml" + fi +else + echo "Already initialized, continuing!" >&2 fi # Execute beacond