Odin/scripts/stop-odin.ps1
2026-08-16 22:46:13 +02:00

24 lines
644 B
PowerShell

param(
[string] $StateDir = ""
)
$ErrorActionPreference = "Stop"
$repoRoot = Split-Path -Parent $PSScriptRoot
if ([string]::IsNullOrWhiteSpace($StateDir)) { $StateDir = Join-Path $repoRoot "scratch\odin" }
$pidPath = Join-Path $StateDir "odin.pid"
if (-not (Test-Path $pidPath)) {
Write-Host "No Odin PID file found at $pidPath."
exit 0
}
$odinPid = (Get-Content -Raw $pidPath).Trim()
if ($odinPid -match "^\d+$") {
$process = Get-Process -Id ([int] $odinPid) -ErrorAction SilentlyContinue
if ($process) {
Stop-Process -Id $process.Id
Write-Host "Stopped Odin PID $odinPid."
}
}
Remove-Item -LiteralPath $pidPath -Force