#!/bin/bash
# Helper script to run disk analysis on r630-01
# This script copies the analysis script and runs it remotely

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
ANALYSIS_SCRIPT="$SCRIPT_DIR/analyze-r630-disk-layout.sh"

# Check if analysis script exists
if [ ! -f "$ANALYSIS_SCRIPT" ]; then
    echo "Error: Analysis script not found at $ANALYSIS_SCRIPT"
    exit 1
fi

echo "=========================================="
echo "R630-01 Disk Analysis Runner"
echo "=========================================="
echo ""
echo "This script will run the disk analysis on r630-01"
echo ""
echo "Option 1: Run via SSH (requires password)"
echo "  ssh root@192.168.11.11 'bash -s' < $ANALYSIS_SCRIPT"
echo ""
echo "Option 2: Copy script and run"
echo "  scp $ANALYSIS_SCRIPT root@192.168.11.11:/tmp/"
echo "  ssh root@192.168.11.11 '/tmp/analyze-r630-disk-layout.sh'"
echo ""
echo "Option 3: Use existing SSH script"
echo "  bash scripts/ssh-r630-01.sh 'bash -s' < $ANALYSIS_SCRIPT"
echo ""
echo "=========================================="
echo "Attempting Option 3..."
echo "=========================================="
echo ""

# Try to run via ssh-r630-01.sh
if [ -f "$SCRIPT_DIR/ssh-r630-01.sh" ]; then
    bash "$SCRIPT_DIR/ssh-r630-01.sh" 'bash -s' < "$ANALYSIS_SCRIPT"
else
    echo "ssh-r630-01.sh not found. Please run manually using one of the options above."
    exit 1
fi

