# Copyright (c) 2026 K2Aley. GAR-BOT. All rights reserved.
param(
    [Parameter(Mandatory=$true)]
    [string]$BootDrive,

    [string]$Username = "garbot"
)

$ErrorActionPreference = "Stop"

if ($BootDrive.Length -eq 1) {
    $BootDrive = "$BootDrive`:"
}

$bootRoot = Join-Path $BootDrive "\"
if (-not (Test-Path $bootRoot)) {
    throw "Boot drive '$BootDrive' was not found. Insert the Pi SD card and use its boot partition drive letter."
}

$sshPath = Join-Path $bootRoot "ssh"
New-Item -ItemType File -Path $sshPath -Force | Out-Null

Write-Host "Created SSH enable file: $sshPath"
Write-Host ""
Write-Host "If this Pi image already has a user account, eject the card, boot the Pi, then connect:"
Write-Host "ssh $Username@192.168.0.161"
Write-Host ""
Write-Host "For a brand-new Raspberry Pi OS image with no user account, set the user/password with Raspberry Pi Imager,"
Write-Host "or run enable_ssh_mac_linux.sh on a Mac/Linux machine to create userconf.txt with a hashed password."
