July 4, 2025

nexus III phase (multi)

1. Create nexus.sh

nano nexus.sh

2. Paste code (ctrl+V)

#!/bin/bash

# Delete all containers nexus
cleanup_containers() {
    echo "Stop and remove all containers nexus..."
    docker stop $(docker ps -aq --filter "name=nexus*") 2>/dev/null
    docker rm $(docker ps -aq --filter "name=nexus*") 2>/dev/null
    echo "All nexus containers have been removed"
}

# Coun containers for run (edit)
CONTAINER_COUNT=

# List of node-id (add your IDs separated by space)
BASE_NODE_ID="YOUR_ID"

# Check args 
if [ "$1" == "clean" ]; then
    cleanup_containers
    exit 0
fi

# Convert text to array
NODE_IDS=($BASE_NODE_ID)

# Check if there are enough IDs for all containers
if [ ${#NODE_IDS[@]} -lt $CONTAINER_COUNT ]; then
    echo "Error: Not enough node-id in list BASE_NODE_ID"
    echo "Required: $CONTAINER_COUNT, Available: ${#NODE_IDS[@]}"
    exit 1
fi

# Base name of the container
BASE_NAME="nexus"

# The main container launch cycle
for (( i=0; i<$CONTAINER_COUNT; i++ ))
do
    # Forming a container name
    CONTAINER_NAME="${BASE_NAME}${i}"
    
    # We take the corresponding node-id from the array
    NODE_ID=${NODE_IDS[$i]}
    
    # Launching the container
    echo "Launch container $CONTAINER_NAME with node-id $NODE_ID"
    docker run -d -it --init \
        --name $CONTAINER_NAME \
        nexusxyz/nexus-cli:v0.9.0 \
        start --node-id $NODE_ID --max-threads 8
    
    # Checking the success of the launch
    if [ $? -eq 0 ]; then
        echo "✅ Container $CONTAINER_NAME started successfully (Node ID: $NODE_ID)"
    else
        echo "❌ Error starting container $CONTAINER_NAME"
    fi
done

echo -e "\n=== Summary information ==="
echo "Containers launched: $CONTAINER_COUNT"
echo "Used Node ID: ${NODE_IDS[@]:0:$CONTAINER_COUNT}"
echo -e "\nCommands for control:"
echo "  View all containers: docker ps -a --filter 'name=nexus*'"
echo "  Stop all containers: $0 clean"

3. Allow launch

chmod +x nexus.sh

4. Launch script

./nexus.sh

5. Delete all containers

./nexus.sh clean

Description:

CONTAINER_COUNT=Number, your number of containers you want to run
Ex:

CONTAINER_COUNT=3

BASE_NODE_ID="Your node IDs are separated by a space, but less than the point with CONTAINER_COUNT"

Ex:

If your CONTAINER_COUNT=3, then:

BASE_NODE_ID="375193 3759195 358175"

In a few minutes, the dashboard will show statistics.