#!/bin/bash
# SSH to Proxmox with password (using sshpass if available)

set -e

# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
RED='\033[0;31m'
NC='\033[0m' # No Color

PROXMOX_PASSWORD="L@kers2010"

# Check if sshpass is installed
if ! command -v sshpass &> /dev/null; then
    echo -e "${YELLOW}sshpass not installed. Installing...${NC}"
    if command -v apt-get &> /dev/null; then
        sudo apt-get update && sudo apt-get install -y sshpass
    elif command -v yum &> /dev/null; then
        sudo yum install -y sshpass
    else
        echo -e "${RED}Could not install sshpass. Please install manually or use regular SSH.${NC}"
        echo ""
        echo "To connect manually:"
        echo "  ssh root@192.168.11.10  # Site 1"
        echo "  ssh root@192.168.11.11  # Site 2"
        echo ""
        echo "Password: $PROXMOX_PASSWORD"
        exit 1
    fi
fi

echo -e "${BLUE}=== Proxmox SSH Connection ===${NC}"
echo ""
echo "Select which Proxmox server to connect to:"
echo "  1) Site 1 - ml110-01 (192.168.11.10)"
echo "  2) Site 2 - r630-01 (192.168.11.11)"
echo ""
read -p "Enter choice [1-2]: " choice

case $choice in
    1)
        IP="192.168.11.10"
        NAME="ml110-01"
        ;;
    2)
        IP="192.168.11.11"
        NAME="r630-01"
        ;;
    *)
        echo "Invalid choice"
        exit 1
        ;;
esac

echo -e "${YELLOW}Connecting to $NAME at $IP...${NC}"
echo ""

# Use sshpass to provide password
sshpass -p "$PROXMOX_PASSWORD" ssh -o StrictHostKeyChecking=no root@$IP

