#!/usr/bin/env bash
# Set Root Password for Proxmox LXC Container
# Must be run on Proxmox host with pct command available

set -euo pipefail

VMID="${1:-2500}"
PASSWORD="${2:-L@kers2010}"

if ! command -v pct >/dev/null 2>&1; then
    echo "Error: pct command not found"
    echo "This script must be run on the Proxmox host"
    echo ""
    echo "To set password manually, run on Proxmox host:"
    echo "  pct set $VMID --password \"$PASSWORD\""
    exit 1
fi

echo "Setting root password for VMID $VMID..."
pct set "$VMID" --password "$PASSWORD"

if [ $? -eq 0 ]; then
    echo "✅ Password set successfully for VMID $VMID"
    echo ""
    echo "You can now SSH into the container:"
    echo "  ssh root@<container-ip>"
    echo "  Password: $PASSWORD"
else
    echo "❌ Failed to set password"
    exit 1
fi

