Preserve USB Move identity during Bluetooth pickup

This commit is contained in:
Meta Vens 2026-06-17 11:27:33 +01:00
commit beed394f45
4 changed files with 58 additions and 11 deletions

View file

@ -7,17 +7,24 @@ $ErrorActionPreference = "Stop"
$scriptPath = Join-Path $PSScriptRoot "nightwing-claim-usb-moves.sh"
$sshExe = Join-Path $env:SystemRoot "System32\OpenSSH\ssh.exe"
function Quote-ShSingle([string] $Value) {
return "'" + ($Value -replace "'", "'\''") + "'"
}
$scriptContent = [System.IO.File]::ReadAllText($scriptPath) -replace "`r?`n", "`n"
$script64 = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($scriptContent))
$remoteArgs = ""
if (-not [string]::IsNullOrWhiteSpace($HostAddress)) {
$remoteArgs = " " + ($HostAddress -replace "'", "'\''")
$remoteArgs = " " + (Quote-ShSingle $HostAddress)
}
$command = '"' + $sshExe + '" -o BatchMode=yes -o ConnectTimeout=5 ' +
$SshTarget +
' "sh -s' +
' "printf %s ' +
(Quote-ShSingle $script64) +
' | base64 -d | sh -s --' +
$remoteArgs +
'" < "' +
$scriptPath +
'"'
cmd.exe /c $command

View file

@ -6,10 +6,17 @@ $ErrorActionPreference = "Stop"
$scriptPath = Join-Path $PSScriptRoot "nightwing-move-state-sources.sh"
$sshExe = Join-Path $env:SystemRoot "System32\OpenSSH\ssh.exe"
function Quote-ShSingle([string] $Value) {
return "'" + ($Value -replace "'", "'\''") + "'"
}
$scriptContent = [System.IO.File]::ReadAllText($scriptPath) -replace "`r?`n", "`n"
$script64 = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($scriptContent))
$command = '"' + $sshExe + '" -o BatchMode=yes -o ConnectTimeout=5 ' +
$SshTarget +
' "sh -s" < "' +
$scriptPath +
'"'
' "printf %s ' +
(Quote-ShSingle $script64) +
' | base64 -d | sh -s"'
& cmd.exe /d /c $command
exit $LASTEXITCODE

View file

@ -62,8 +62,14 @@ $moveStateSpecs = @($MoveState | Where-Object { -not [string]::IsNullOrWhiteSpac
if ($moveStateSpecs.Count -eq 0) {
$claimScript = Join-Path $PSScriptRoot "claim-nightwing-usb-moves.ps1"
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File $claimScript -SshTarget $SshTarget
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
$sourceScript = Join-Path $PSScriptRoot "get-nightwing-move-state-sources.ps1"
$moveStateSpecs = @(& powershell.exe -NoProfile -ExecutionPolicy Bypass -File $sourceScript -SshTarget $SshTarget)
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
}
$moveStateSetLines = ($moveStateSpecs | ForEach-Object {