Newer
Older
cortex-hub / agent-node / spawn_local_agent.sh
#!/bin/bash
# scripts/spawn_local_agent.sh

echo "🚀 Cortex Agent Node - Local Spawner"
echo "===================================="

# Check for environment variables
read -p "Enter Node ID (Default: local-agent-$(hostname)): " NODE_ID
NODE_ID=${NODE_ID:-local-agent-$(hostname)}

echo ""
echo "STEP 1: Register your node"
echo "--------------------------"
echo "Go to: https://ai.jerxie.com/nodes"
echo "1. Click '+ Register Node'"
echo "2. Use ID: $NODE_ID"
echo "3. Copy the 'Secret Key' provided."
echo ""

read -sp "Enter the Secret Key: " SECRET_KEY
echo ""

read -p "Enter Hub gRPC Endpoint (Default: ai.jerxie.com:50051): " GRPC_ENDPOINT
GRPC_ENDPOINT=${GRPC_ENDPOINT:-ai.jerxie.com:50051}

# Create .env file
cat > .env <<EOF
AGENT_NODE_ID=$NODE_ID
AGENT_SECRET_KEY=$SECRET_KEY
GRPC_ENDPOINT=$GRPC_ENDPOINT
AGENT_TLS_ENABLED=true
EOF

echo "✅ Configuration saved to .env"

# Build and Start
echo "📦 Building and starting container..."
docker compose build
docker compose up -d

echo ""
echo "🎉 Agent '$NODE_ID' is now running!"
echo "Check logs with: docker logs -f cortex-local-agent"