@geekbeer/minion 3.6.1 → 3.6.3
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 +79 -21
package/package.json
CHANGED
package/win/minion-cli.ps1
CHANGED
|
@@ -451,7 +451,7 @@ function Restart-MinionService {
|
|
|
451
451
|
# ============================================================
|
|
452
452
|
|
|
453
453
|
function Invoke-Setup {
|
|
454
|
-
$totalSteps =
|
|
454
|
+
$totalSteps = 12
|
|
455
455
|
|
|
456
456
|
# Minionization warning
|
|
457
457
|
Write-Host ""
|
|
@@ -877,8 +877,59 @@ function Invoke-Setup {
|
|
|
877
877
|
Write-Warn "websockify not available, VNC WebSocket proxy will not be registered"
|
|
878
878
|
}
|
|
879
879
|
|
|
880
|
+
# Step 10: Download and register cloudflared
|
|
881
|
+
Write-Step 10 $totalSteps "Setting up Cloudflare Tunnel (cloudflared)..."
|
|
882
|
+
$cfExe = $null
|
|
883
|
+
if (Get-Command cloudflared -ErrorAction SilentlyContinue) {
|
|
884
|
+
$cfExe = (Get-Command cloudflared).Source
|
|
885
|
+
Write-Detail "cloudflared already installed: $cfExe"
|
|
886
|
+
} else {
|
|
887
|
+
Write-Host " Downloading cloudflared..."
|
|
888
|
+
try {
|
|
889
|
+
$cfUrl = 'https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-amd64.exe'
|
|
890
|
+
$cfPath = Join-Path $DataDir 'cloudflared.exe'
|
|
891
|
+
Invoke-WebRequest -Uri $cfUrl -OutFile $cfPath -UseBasicParsing
|
|
892
|
+
$cfExe = $cfPath
|
|
893
|
+
Write-Detail "cloudflared downloaded to $cfExe"
|
|
894
|
+
}
|
|
895
|
+
catch {
|
|
896
|
+
Write-Warn "Failed to download cloudflared: $_"
|
|
897
|
+
Write-Host " You can install manually or re-run setup later." -ForegroundColor Gray
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
if ($cfExe) {
|
|
901
|
+
# Register cloudflared as NSSM service (config will be set by 'configure --setup-tunnel')
|
|
902
|
+
Invoke-Nssm stop minion-cloudflared
|
|
903
|
+
Invoke-Nssm remove minion-cloudflared confirm
|
|
904
|
+
$cfConfigDir = Join-Path $TargetUserProfile '.cloudflared'
|
|
905
|
+
$cfConfigPath = Join-Path $cfConfigDir 'config.yml'
|
|
906
|
+
Invoke-Nssm install minion-cloudflared $cfExe "tunnel run --config `"$cfConfigPath`""
|
|
907
|
+
# Set USERPROFILE/HOME so cloudflared resolves ~/.cloudflared/ to the target user's profile
|
|
908
|
+
# (NSSM runs as LocalSystem, whose ~ is C:\Windows\system32\config\systemprofile)
|
|
909
|
+
$cfEnvLines = @(
|
|
910
|
+
"USERPROFILE=$TargetUserProfile",
|
|
911
|
+
"HOME=$TargetUserProfile"
|
|
912
|
+
)
|
|
913
|
+
Invoke-Nssm set minion-cloudflared AppEnvironmentExtra ($cfEnvLines -join "`n")
|
|
914
|
+
Invoke-Nssm set minion-cloudflared Start SERVICE_DEMAND_START
|
|
915
|
+
Invoke-Nssm set minion-cloudflared DisplayName "Minion Cloudflared"
|
|
916
|
+
Invoke-Nssm set minion-cloudflared Description "Cloudflare Tunnel for Minion"
|
|
917
|
+
Invoke-Nssm set minion-cloudflared AppRestartDelay 5000
|
|
918
|
+
Invoke-Nssm set minion-cloudflared AppStdout (Join-Path $LogDir 'cloudflared-stdout.log')
|
|
919
|
+
Invoke-Nssm set minion-cloudflared AppStderr (Join-Path $LogDir 'cloudflared-stderr.log')
|
|
920
|
+
Invoke-Nssm set minion-cloudflared AppStdoutCreationDisposition 4
|
|
921
|
+
Invoke-Nssm set minion-cloudflared AppStderrCreationDisposition 4
|
|
922
|
+
Invoke-Nssm set minion-cloudflared AppRotateFiles 1
|
|
923
|
+
Invoke-Nssm set minion-cloudflared AppRotateBytes 10485760
|
|
924
|
+
Grant-ServiceControlToUser 'minion-cloudflared' $setupUserSid
|
|
925
|
+
if ($targetUserSid -and $targetUserSid -ne $setupUserSid) {
|
|
926
|
+
Grant-ServiceControlToUser 'minion-cloudflared' $targetUserSid
|
|
927
|
+
}
|
|
928
|
+
Write-Detail "minion-cloudflared service registered (starts via 'configure --setup-tunnel')"
|
|
929
|
+
}
|
|
930
|
+
|
|
880
931
|
# Step 11: Disable screensaver, lock screen, and sleep
|
|
881
|
-
Write-Step
|
|
932
|
+
Write-Step 11 $totalSteps "Disabling screensaver, lock screen, and sleep..."
|
|
882
933
|
Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name ScreenSaveActive -Value '0'
|
|
883
934
|
Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name ScreenSaveTimeOut -Value '0'
|
|
884
935
|
Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name SCRNSAVE.EXE -Value ''
|
|
@@ -892,7 +943,7 @@ function Invoke-Setup {
|
|
|
892
943
|
Write-Detail "Sleep and monitor timeout disabled"
|
|
893
944
|
|
|
894
945
|
# Configure firewall rules
|
|
895
|
-
Write-Step
|
|
946
|
+
Write-Step 12 $totalSteps "Configuring firewall rules..."
|
|
896
947
|
$fwRules = @(
|
|
897
948
|
@{ Name = 'Minion Agent'; Port = 8080 },
|
|
898
949
|
@{ Name = 'Minion Terminal'; Port = 7681 },
|
|
@@ -985,6 +1036,7 @@ function Invoke-Setup {
|
|
|
985
1036
|
Write-Host "Services registered (not yet started):"
|
|
986
1037
|
Write-Host " minion-agent - AI Agent (port 8080)"
|
|
987
1038
|
Write-Host " minion-websockify - WebSocket proxy (port 6080)"
|
|
1039
|
+
Write-Host " minion-cloudflared - Cloudflare Tunnel (starts via configure --setup-tunnel)"
|
|
988
1040
|
Write-Host " MinionVNC (task) - TightVNC (port 5900, starts at logon)"
|
|
989
1041
|
Write-Host ""
|
|
990
1042
|
Write-Host "Next step: Connect to HQ (run as regular user):" -ForegroundColor Yellow
|
|
@@ -1303,23 +1355,32 @@ function Invoke-Configure {
|
|
|
1303
1355
|
[System.IO.File]::WriteAllText((Join-Path $cfConfigDir 'config.yml'), $tunnelData.config_yml, [System.Text.UTF8Encoding]::new($false))
|
|
1304
1356
|
Write-Detail "Tunnel config saved"
|
|
1305
1357
|
|
|
1306
|
-
#
|
|
1307
|
-
$
|
|
1308
|
-
if (
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1358
|
+
# Start cloudflared service (registered during setup)
|
|
1359
|
+
$cfState = Get-ServiceState 'minion-cloudflared'
|
|
1360
|
+
if ($cfState) {
|
|
1361
|
+
# Enable auto-start now that tunnel config is in place
|
|
1362
|
+
Invoke-Nssm set minion-cloudflared Start SERVICE_AUTO_START 2>&1 | Out-Null
|
|
1363
|
+
sc.exe start minion-cloudflared 2>&1 | Out-Null
|
|
1364
|
+
Write-Detail "minion-cloudflared started"
|
|
1365
|
+
} else {
|
|
1366
|
+
# Fallback: service not registered (e.g. setup was run before v3.6.2)
|
|
1367
|
+
$cfExe = $null
|
|
1368
|
+
if (Get-Command cloudflared -ErrorAction SilentlyContinue) {
|
|
1369
|
+
$cfExe = (Get-Command cloudflared).Source
|
|
1370
|
+
} elseif (Test-Path (Join-Path $DataDir 'cloudflared.exe')) {
|
|
1371
|
+
$cfExe = Join-Path $DataDir 'cloudflared.exe'
|
|
1372
|
+
}
|
|
1373
|
+
if ($cfExe) {
|
|
1317
1374
|
$isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
|
1318
1375
|
if ($isAdmin) {
|
|
1319
1376
|
$cfConfigPath = Join-Path $cfConfigDir 'config.yml'
|
|
1320
|
-
Invoke-Nssm stop minion-cloudflared
|
|
1321
|
-
Invoke-Nssm remove minion-cloudflared confirm
|
|
1322
1377
|
Invoke-Nssm install minion-cloudflared $cfExe "tunnel run --config `"$cfConfigPath`""
|
|
1378
|
+
# Set USERPROFILE/HOME so cloudflared resolves ~/.cloudflared/ to the target user's profile
|
|
1379
|
+
$cfEnvLines = @(
|
|
1380
|
+
"USERPROFILE=$TargetUserProfile",
|
|
1381
|
+
"HOME=$TargetUserProfile"
|
|
1382
|
+
)
|
|
1383
|
+
Invoke-Nssm set minion-cloudflared AppEnvironmentExtra ($cfEnvLines -join "`n")
|
|
1323
1384
|
Invoke-Nssm set minion-cloudflared Start SERVICE_AUTO_START
|
|
1324
1385
|
Invoke-Nssm set minion-cloudflared DisplayName "Minion Cloudflared"
|
|
1325
1386
|
Invoke-Nssm set minion-cloudflared Description "Cloudflare Tunnel for Minion"
|
|
@@ -1332,15 +1393,12 @@ function Invoke-Configure {
|
|
|
1332
1393
|
Invoke-Nssm set minion-cloudflared AppRotateBytes 10485760
|
|
1333
1394
|
$setupUserSid = Get-SetupUserSid
|
|
1334
1395
|
Grant-ServiceControlToUser 'minion-cloudflared' $setupUserSid
|
|
1335
|
-
Write-Detail "minion-cloudflared service registered"
|
|
1396
|
+
Write-Detail "minion-cloudflared service registered (fallback)"
|
|
1336
1397
|
sc.exe start minion-cloudflared 2>&1 | Out-Null
|
|
1337
1398
|
Write-Detail "minion-cloudflared started"
|
|
1338
1399
|
} else {
|
|
1339
|
-
Write-Warn "minion-cloudflared service not registered. Run '
|
|
1400
|
+
Write-Warn "minion-cloudflared service not registered. Run 'setup' as admin to register, or run 'configure --setup-tunnel' as admin."
|
|
1340
1401
|
}
|
|
1341
|
-
} else {
|
|
1342
|
-
sc.exe start minion-cloudflared 2>&1 | Out-Null
|
|
1343
|
-
Write-Detail "minion-cloudflared started"
|
|
1344
1402
|
}
|
|
1345
1403
|
}
|
|
1346
1404
|
}
|