Add build, deploy and test sources

This commit is contained in:
Paravis committed 2026-11-13 07:52:37 +03:00
1 parent b962581812
commit 3d1a08f230
259 files changed
+15273

No files matched your search

@@ -0,0 +1,70 @@
#Requires -RunAsAdministrator
<#
.SYNOPSIS
Убирает из VMware VM второй raw-диск (nvme0:0), указывающий на тот же
\\.\PhysicalDrive2, что и sata0:0. Плюс чистит устаревшие .lck.
.DESCRIPTION
VMware не может открыть один физический диск дважды — отсюда
"Операция с файлом \\.\PhysicalDrive2 не удалась".
Скрипт:
1. проверяет, что VM не запущена (нет процесса vmware-vmx);
2. делает бэкап .vmx;
3. удаляет строки nvme0.*;
4. удаляет устаревшие каталоги *.lck;
5. печатает оставшиеся диски.
.PARAMETER Vmx
Путь к .vmx. По умолчанию "D:\Paravis\Documents\Virtual Machines\Windows 10\Windows 10.vmx".
#>
[CmdletBinding()]
param(
[string]$Vmx = 'D:\Paravis\Documents\Virtual Machines\Windows 10\Windows 10.vmx'
)
$ErrorActionPreference = 'Stop'
function Write-Step([string]$t) { Write-Host "`n=== $t ===" -ForegroundColor Cyan }
function Write-Ok([string]$t) { Write-Host "OK: $t" -ForegroundColor Green }
function Write-Warn([string]$t) { Write-Host "WARN: $t" -ForegroundColor Yellow }
if (-not (Test-Path $Vmx)) { throw "Нет файла: $Vmx" }
$dir = Split-Path $Vmx
Write-Step "Проверка, что VM не запущена"
$vmxProc = Get-Process -Name 'vmware-vmx' -ErrorAction SilentlyContinue
if ($vmxProc) {
throw "VM запущена (vmware-vmx PID $($vmxProc.Id -join ',')). Выключите её и повторите."
}
Write-Ok "vmware-vmx не запущен."
Write-Step "Бэкап"
$bak = "$Vmx.bak-{0:yyyyMMdd-HHmmss}" -f (Get-Date)
Copy-Item $Vmx $bak -Force
Write-Ok "бэкап: $bak"
Write-Step "Удаление nvme0:* из VMX"
$lines = Get-Content $Vmx -Encoding UTF8
$keep = $lines | Where-Object { $_ -notmatch '^nvme0' }
$removed = $lines.Count - $keep.Count
if ($removed -eq 0) {
Write-Warn "строк nvme0 не найдено — возможно, уже убрано."
} else {
$utf8 = New-Object System.Text.UTF8Encoding($false)
[IO.File]::WriteAllLines($Vmx, $keep, $utf8)
Write-Ok ("удалено строк: {0}" -f $removed)
}
Write-Step "Удаление устаревших .lck"
Get-ChildItem $dir -Directory -Filter '*.lck' -ErrorAction SilentlyContinue | ForEach-Object {
Remove-Item $_.FullName -Recurse -Force -ErrorAction SilentlyContinue
Write-Ok ("удалён {0}" -f $_.Name)
}
Write-Step "Текущие диски в VMX"
Select-String -Path $Vmx -Pattern 'present = "TRUE"|fileName|deviceType' |
Where-Object { $_.Line -match '^(sata|nvme|scsi|ide)' } |
Select-Object -ExpandProperty Line
Write-Step "Готово"
Write-Host "Запускайте VM. Должен остаться один raw-диск (sata0:0 -> Windows 10-1.vmdk)." -ForegroundColor Green