@geekbeer/minion 2.42.3 → 2.42.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/win/minion-cli.ps1 +58 -17
package/package.json
CHANGED
package/win/minion-cli.ps1
CHANGED
|
@@ -68,6 +68,28 @@ function Test-CommandExists {
|
|
|
68
68
|
$null -ne (Get-Command $Name -ErrorAction SilentlyContinue)
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
function Get-WebsockifyCommand {
|
|
72
|
+
# Returns @(executable, args-prefix) for launching websockify.
|
|
73
|
+
# 1) websockify.exe on PATH
|
|
74
|
+
if (Get-Command websockify -ErrorAction SilentlyContinue) {
|
|
75
|
+
return @((Get-Command websockify).Source)
|
|
76
|
+
}
|
|
77
|
+
# 2) Look in Python Scripts directories
|
|
78
|
+
if (Test-CommandExists 'python') {
|
|
79
|
+
$scriptsDir = & python -c "import sysconfig; print(sysconfig.get_path('scripts'))" 2>$null
|
|
80
|
+
if ($scriptsDir) {
|
|
81
|
+
$wsExe = Join-Path $scriptsDir 'websockify.exe'
|
|
82
|
+
if (Test-Path $wsExe) { return @($wsExe) }
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
# 3) Fallback: python -m websockify
|
|
86
|
+
if (Test-CommandExists 'python') {
|
|
87
|
+
$check = & python -c "import websockify" 2>&1
|
|
88
|
+
if ($LASTEXITCODE -eq 0) { return @('python', '-m', 'websockify') }
|
|
89
|
+
}
|
|
90
|
+
return $null
|
|
91
|
+
}
|
|
92
|
+
|
|
71
93
|
function Get-LanIPAddress {
|
|
72
94
|
try {
|
|
73
95
|
$ip = (Get-NetIPAddress -AddressFamily IPv4 -ErrorAction SilentlyContinue |
|
|
@@ -329,17 +351,21 @@ function Invoke-Setup {
|
|
|
329
351
|
|
|
330
352
|
# Try prebuilt version first (no Build Tools required)
|
|
331
353
|
try {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
354
|
+
$npmResult = cmd /c "npm install node-pty-prebuilt-multiarch 2>&1"
|
|
355
|
+
if ($LASTEXITCODE -eq 0) {
|
|
356
|
+
Write-Detail "node-pty-prebuilt-multiarch installed (no Build Tools needed)"
|
|
357
|
+
$ptyInstalled = $true
|
|
358
|
+
}
|
|
335
359
|
} catch {}
|
|
336
360
|
|
|
337
361
|
# Fallback: source-compiled version (requires Visual Studio Build Tools)
|
|
338
362
|
if (-not $ptyInstalled) {
|
|
339
363
|
try {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
364
|
+
$npmResult = cmd /c "npm install node-pty 2>&1"
|
|
365
|
+
if ($LASTEXITCODE -eq 0) {
|
|
366
|
+
Write-Detail "node-pty installed (compiled from source)"
|
|
367
|
+
$ptyInstalled = $true
|
|
368
|
+
}
|
|
343
369
|
} catch {}
|
|
344
370
|
}
|
|
345
371
|
|
|
@@ -412,10 +438,17 @@ if (`$vncExe) {
|
|
|
412
438
|
}
|
|
413
439
|
# Reload registry config (ensures no-auth settings are applied)
|
|
414
440
|
& `$vncExe -controlapp -reload 2>`$null
|
|
415
|
-
|
|
441
|
+
`$wsCmd = Get-WebsockifyCommand
|
|
442
|
+
if (`$wsCmd) {
|
|
416
443
|
`$wsProc = Get-Process -Name websockify -ErrorAction SilentlyContinue
|
|
417
444
|
if (-not `$wsProc) {
|
|
418
|
-
|
|
445
|
+
if (`$wsCmd.Count -eq 1) {
|
|
446
|
+
Start-Process -FilePath `$wsCmd[0] -ArgumentList '6080', 'localhost:5900' -WindowStyle Hidden
|
|
447
|
+
} else {
|
|
448
|
+
# python -m websockify 6080 localhost:5900
|
|
449
|
+
`$wsArgs = (`$wsCmd[1..(`$wsCmd.Count-1)] + @('6080', 'localhost:5900')) -join ' '
|
|
450
|
+
Start-Process -FilePath `$wsCmd[0] -ArgumentList `$wsArgs -WindowStyle Hidden
|
|
451
|
+
}
|
|
419
452
|
}
|
|
420
453
|
}
|
|
421
454
|
}
|
|
@@ -547,7 +580,7 @@ Remove-Item `$PidFile -Force -ErrorAction SilentlyContinue
|
|
|
547
580
|
|
|
548
581
|
# Step 8: Setup websockify (WebSocket proxy for VNC)
|
|
549
582
|
Write-Step 8 $totalSteps "Setting up websockify..."
|
|
550
|
-
if (
|
|
583
|
+
if (Get-WebsockifyCommand) {
|
|
551
584
|
Write-Detail "websockify already installed"
|
|
552
585
|
}
|
|
553
586
|
else {
|
|
@@ -561,9 +594,10 @@ Remove-Item `$PidFile -Force -ErrorAction SilentlyContinue
|
|
|
561
594
|
if (-not $pythonUsable) {
|
|
562
595
|
Write-Host " Python not found. Installing via winget..."
|
|
563
596
|
try {
|
|
564
|
-
|
|
597
|
+
$wingetResult = cmd /c "winget install --id Python.Python.3.12 --accept-package-agreements --accept-source-agreements 2>&1"
|
|
565
598
|
$env:PATH = [System.Environment]::GetEnvironmentVariable('PATH', 'Machine') + ';' + [System.Environment]::GetEnvironmentVariable('PATH', 'User')
|
|
566
|
-
Write-Detail "Python installed"
|
|
599
|
+
if ($LASTEXITCODE -eq 0) { Write-Detail "Python installed" }
|
|
600
|
+
else { Write-Warn "winget install may have failed (exit code $LASTEXITCODE): $wingetResult" }
|
|
567
601
|
}
|
|
568
602
|
catch {
|
|
569
603
|
Write-Warn "Failed to install Python: $_"
|
|
@@ -573,21 +607,28 @@ Remove-Item `$PidFile -Force -ErrorAction SilentlyContinue
|
|
|
573
607
|
|
|
574
608
|
Write-Host " Installing websockify via pip..."
|
|
575
609
|
try {
|
|
610
|
+
# Use cmd /c to prevent pip's stderr (progress bars, warnings) from
|
|
611
|
+
# becoming RemoteException errors in PowerShell remoting sessions.
|
|
576
612
|
if (Test-CommandExists 'pip') {
|
|
577
|
-
|
|
578
|
-
Write-Detail "websockify installed"
|
|
613
|
+
$pipResult = cmd /c "pip install websockify 2>&1"
|
|
614
|
+
if ($LASTEXITCODE -eq 0) { Write-Detail "websockify installed" }
|
|
615
|
+
else { Write-Warn "pip install failed (exit code $LASTEXITCODE): $pipResult" }
|
|
579
616
|
}
|
|
580
617
|
elseif (Test-CommandExists 'pip3') {
|
|
581
|
-
|
|
582
|
-
Write-Detail "websockify installed"
|
|
618
|
+
$pipResult = cmd /c "pip3 install websockify 2>&1"
|
|
619
|
+
if ($LASTEXITCODE -eq 0) { Write-Detail "websockify installed" }
|
|
620
|
+
else { Write-Warn "pip3 install failed (exit code $LASTEXITCODE): $pipResult" }
|
|
583
621
|
}
|
|
584
622
|
elseif (Test-CommandExists 'python') {
|
|
585
|
-
|
|
586
|
-
Write-Detail "websockify installed (via python -m pip)"
|
|
623
|
+
$pipResult = cmd /c "python -m pip install websockify 2>&1"
|
|
624
|
+
if ($LASTEXITCODE -eq 0) { Write-Detail "websockify installed (via python -m pip)" }
|
|
625
|
+
else { Write-Warn "python -m pip install failed (exit code $LASTEXITCODE): $pipResult" }
|
|
587
626
|
}
|
|
588
627
|
else {
|
|
589
628
|
Write-Warn "pip not found. Install Python first, then: pip install websockify"
|
|
590
629
|
}
|
|
630
|
+
# Refresh PATH so websockify.exe in Python Scripts dir is discoverable
|
|
631
|
+
$env:PATH = [System.Environment]::GetEnvironmentVariable('PATH', 'Machine') + ';' + [System.Environment]::GetEnvironmentVariable('PATH', 'User')
|
|
591
632
|
}
|
|
592
633
|
catch {
|
|
593
634
|
Write-Warn "Failed to install websockify: $_"
|