#!/bin/bash
# Deploy RPC Translator to all VMIDs (2400, 2401, 2402)
# Usage: ./scripts/deploy-all-vmids.sh

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"

# VMID configuration - adjust IPs as needed
declare -A VMIDS=(
  ["2400"]="192.168.11.240"
  ["2401"]="192.168.11.241"
  ["2402"]="192.168.11.242"
)

echo "Deploying RPC Translator to all VMIDs..."
echo ""

for VMID in "${!VMIDS[@]}"; do
  VMIP="${VMIDS[$VMID]}"
  echo "========================================="
  echo "Deploying to VMID $VMID ($VMIP)..."
  echo "========================================="
  "$SCRIPT_DIR/deploy-to-vmid.sh" "$VMID" "$VMIP"
  echo ""
done

echo "✅ Deployment to all VMIDs complete!"
echo ""
echo "Next steps:"
echo "1. Configure .env on each VMID (2400, 2401, 2402)"
echo "2. Start services on each VMID:"
echo "   systemctl start rpc-translator-138.service"
echo "3. Check service status:"
echo "   systemctl status rpc-translator-138.service"
echo ""
