@geekbeer/minion 3.5.32 → 3.5.34
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 +46 -17
package/package.json
CHANGED
package/win/minion-cli.ps1
CHANGED
|
@@ -114,6 +114,35 @@ function Test-CommandExists {
|
|
|
114
114
|
$null -ne (Get-Command $Name -ErrorAction SilentlyContinue)
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
function Invoke-Winget {
|
|
118
|
+
# Wrapper for winget install that handles broken sources.
|
|
119
|
+
# winget's msstore source can fail with 0x8a15000f on fresh/misconfigured systems.
|
|
120
|
+
# This function tries: (1) --source winget, (2) winget source reset + retry, (3) fail.
|
|
121
|
+
param([string]$Id)
|
|
122
|
+
|
|
123
|
+
if (-not (Test-CommandExists 'winget')) { return $false }
|
|
124
|
+
|
|
125
|
+
# Attempt 1: install with --source winget (skip msstore)
|
|
126
|
+
$result = cmd /c "winget install --id $Id --source winget --accept-package-agreements --accept-source-agreements 2>&1"
|
|
127
|
+
if ($LASTEXITCODE -eq 0) { return $true }
|
|
128
|
+
|
|
129
|
+
# Attempt 2: reset sources and retry
|
|
130
|
+
Write-Host " Retrying after winget source reset..."
|
|
131
|
+
cmd /c "winget source reset --force 2>&1" | Out-Null
|
|
132
|
+
$result = cmd /c "winget install --id $Id --source winget --accept-package-agreements --accept-source-agreements 2>&1"
|
|
133
|
+
if ($LASTEXITCODE -eq 0) { return $true }
|
|
134
|
+
|
|
135
|
+
return $false
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function Remove-ScheduledTaskSilent {
|
|
139
|
+
# Delete a scheduled task without emitting errors if it doesn't exist.
|
|
140
|
+
# PowerShell's NativeCommandError makes schtasks stderr impossible to suppress
|
|
141
|
+
# with 2>&1 | Out-Null alone, so we run via cmd /c.
|
|
142
|
+
param([string]$TaskName)
|
|
143
|
+
cmd /c "schtasks /Delete /TN `"$TaskName`" /F >nul 2>&1"
|
|
144
|
+
}
|
|
145
|
+
|
|
117
146
|
function Get-WebsockifyCommand {
|
|
118
147
|
# Returns @(executable, args-prefix) for launching websockify.
|
|
119
148
|
# Python writes informational output to stderr, which causes terminating errors
|
|
@@ -491,8 +520,8 @@ function Invoke-Setup {
|
|
|
491
520
|
}
|
|
492
521
|
else {
|
|
493
522
|
Write-Host " Installing Node.js via winget..."
|
|
494
|
-
|
|
495
|
-
|
|
523
|
+
$installed = Invoke-Winget 'OpenJS.NodeJS.LTS'
|
|
524
|
+
if ($installed) {
|
|
496
525
|
# Refresh PATH
|
|
497
526
|
$env:PATH = [System.Environment]::GetEnvironmentVariable('PATH', 'Machine') + ';' + [System.Environment]::GetEnvironmentVariable('PATH', 'User')
|
|
498
527
|
if (Test-CommandExists 'node') {
|
|
@@ -503,7 +532,7 @@ function Invoke-Setup {
|
|
|
503
532
|
exit 1
|
|
504
533
|
}
|
|
505
534
|
}
|
|
506
|
-
|
|
535
|
+
else {
|
|
507
536
|
Write-Error "Failed to install Node.js. Please install manually from https://nodejs.org/"
|
|
508
537
|
exit 1
|
|
509
538
|
}
|
|
@@ -523,8 +552,8 @@ function Invoke-Setup {
|
|
|
523
552
|
}
|
|
524
553
|
else {
|
|
525
554
|
Write-Host " Installing Git via winget..."
|
|
526
|
-
|
|
527
|
-
|
|
555
|
+
$installed = Invoke-Winget 'Git.Git'
|
|
556
|
+
if ($installed) {
|
|
528
557
|
# Refresh PATH
|
|
529
558
|
$env:PATH = [System.Environment]::GetEnvironmentVariable('PATH', 'Machine') + ';' + [System.Environment]::GetEnvironmentVariable('PATH', 'User')
|
|
530
559
|
if (Test-CommandExists 'git') {
|
|
@@ -538,7 +567,7 @@ function Invoke-Setup {
|
|
|
538
567
|
Write-Warn "Git installed but not in PATH. Please restart this terminal."
|
|
539
568
|
}
|
|
540
569
|
}
|
|
541
|
-
|
|
570
|
+
else {
|
|
542
571
|
Write-Warn "Failed to install Git. Please install manually from https://git-scm.com/downloads/win"
|
|
543
572
|
}
|
|
544
573
|
}
|
|
@@ -761,7 +790,7 @@ function Invoke-Setup {
|
|
|
761
790
|
Invoke-Nssm remove minion-vnc confirm
|
|
762
791
|
|
|
763
792
|
# Register VNC as logon task (must run in user session for desktop capture)
|
|
764
|
-
|
|
793
|
+
Remove-ScheduledTaskSilent "MinionVNC"
|
|
765
794
|
schtasks /Create /TN "MinionVNC" /TR "'$vncExePath' -run" /SC ONLOGON /RL HIGHEST /F | Out-Null
|
|
766
795
|
Write-Detail "TightVNC registered as logon task (user session, not service)"
|
|
767
796
|
}
|
|
@@ -780,15 +809,13 @@ function Invoke-Setup {
|
|
|
780
809
|
}
|
|
781
810
|
if (-not $pythonUsable) {
|
|
782
811
|
Write-Host " Python not found. Installing via winget..."
|
|
783
|
-
|
|
784
|
-
|
|
812
|
+
$installed = Invoke-Winget 'Python.Python.3.12'
|
|
813
|
+
if ($installed) {
|
|
785
814
|
$env:PATH = [System.Environment]::GetEnvironmentVariable('PATH', 'Machine') + ';' + [System.Environment]::GetEnvironmentVariable('PATH', 'User')
|
|
786
|
-
|
|
787
|
-
else { Write-Warn "winget install may have failed (exit code $LASTEXITCODE): $wingetResult" }
|
|
815
|
+
Write-Detail "Python installed"
|
|
788
816
|
}
|
|
789
|
-
|
|
790
|
-
Write-Warn "Failed to install Python:
|
|
791
|
-
Write-Host " Install manually: winget install Python.Python.3.12"
|
|
817
|
+
else {
|
|
818
|
+
Write-Warn "Failed to install Python. Install manually: winget install --id Python.Python.3.12"
|
|
792
819
|
}
|
|
793
820
|
}
|
|
794
821
|
|
|
@@ -1012,7 +1039,7 @@ function Invoke-Uninstall {
|
|
|
1012
1039
|
}
|
|
1013
1040
|
|
|
1014
1041
|
# Remove VNC logon task and legacy NSSM service
|
|
1015
|
-
|
|
1042
|
+
Remove-ScheduledTaskSilent "MinionVNC"
|
|
1016
1043
|
Invoke-Nssm stop minion-vnc
|
|
1017
1044
|
Invoke-Nssm remove minion-vnc confirm
|
|
1018
1045
|
Write-Detail "VNC logon task and legacy service removed"
|
|
@@ -1245,8 +1272,10 @@ function Invoke-Configure {
|
|
|
1245
1272
|
if (-not (Test-CommandExists 'cloudflared')) {
|
|
1246
1273
|
Write-Host " Installing cloudflared..."
|
|
1247
1274
|
if (Test-CommandExists 'winget') {
|
|
1248
|
-
|
|
1249
|
-
|
|
1275
|
+
$installed = Invoke-Winget 'Cloudflare.cloudflared'
|
|
1276
|
+
if ($installed) {
|
|
1277
|
+
$env:PATH = [System.Environment]::GetEnvironmentVariable('PATH', 'Machine') + ';' + [System.Environment]::GetEnvironmentVariable('PATH', 'User')
|
|
1278
|
+
}
|
|
1250
1279
|
}
|
|
1251
1280
|
elseif (Test-CommandExists 'choco') {
|
|
1252
1281
|
& choco install cloudflared -y
|