repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by admin
topgrade/repair-podman-machine.ps1
Raw[CmdletBinding()]
param()
$ErrorActionPreference = 'Stop'
$repoPath = '/etc/yum.repos.d/podman-release-copr.repo'
$repoRepair = "sh -c 'if grep -q ''podman-container-tools-podman-29249'' ''$repoPath''; then sed -i ''s/^enabled=1`$/enabled=0/'' ''$repoPath''; fi'"
& podman.exe machine ssh --username root $repoRepair
if ($LASTEXITCODE -ne 0) {
throw "Podman machine repository repair failed with exit code $LASTEXITCODE."
}
$sourcePath = Join-Path $HOME '.config\containers\registries.conf'
$directoryPath = Join-Path $env:APPDATA 'containers\registries.conf.d'
$targetPath = Join-Path $directoryPath '999-podman-desktop-registries-from-host.conf'
$brokenPath = "$targetPath.broken"
$sourceContent = if (Test-Path -LiteralPath $sourcePath -PathType Leaf) {
Get-Content -LiteralPath $sourcePath -Raw
}
if ($null -ne $sourceContent -and [string]::IsNullOrWhiteSpace($sourceContent)) {
throw "Podman registry source is empty: $sourcePath"
}
New-Item -ItemType Directory -Path $directoryPath -Force | Out-Null
foreach ($path in @($targetPath, $brokenPath)) {
$item = Get-Item -LiteralPath $path -Force -ErrorAction SilentlyContinue
if ($null -ne $item -and (($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0 -or $path -eq $brokenPath)) {
Remove-Item -LiteralPath $path -Force
}
}
if ($null -ne $sourceContent) {
$currentContent = if (Test-Path -LiteralPath $targetPath -PathType Leaf) {
Get-Content -LiteralPath $targetPath -Raw
}
if ($currentContent -ne $sourceContent) {
Set-Content -LiteralPath $targetPath -Value $sourceContent -NoNewline
}
}
Write-Output "Podman machine config repaired; stale COPR repo disabled."