Preserve USB Move identity during Bluetooth pickup
This commit is contained in:
parent
4b55f2d660
commit
beed394f45
4 changed files with 58 additions and 11 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue