Add self-hosted RustDesk bootstrap management
This commit is contained in:
@@ -4,6 +4,8 @@ param(
|
||||
[switch]$RequireRemoteAccess,
|
||||
[switch]$RequireBrokerHealth,
|
||||
[string]$RemoteDesktopPrincipal = 'LCI\SG-Laboratorio-Usuarios-RDP',
|
||||
[switch]$RequireRustDesk,
|
||||
[string]$RustDeskServerAddress,
|
||||
[switch]$Enforce
|
||||
)
|
||||
|
||||
@@ -158,6 +160,42 @@ if ($RequireRemoteAccess) {
|
||||
}
|
||||
}
|
||||
|
||||
$rustDeskReady = $null
|
||||
$rustDeskId = $null
|
||||
if ($RequireRustDesk) {
|
||||
if ([string]::IsNullOrWhiteSpace($RustDeskServerAddress)) {
|
||||
$issues.Add('RustDesk validation requires RustDeskServerAddress.')
|
||||
}
|
||||
$rustDeskService = Get-Service -Name 'RustDesk' -ErrorAction SilentlyContinue
|
||||
$rustDeskStatePath = Join-Path $env:ProgramData 'SGU\RustDesk\Client\device.json'
|
||||
$rustDeskSecretPath = Join-Path $env:ProgramData 'SGU\RustDesk\Client\access.secret'
|
||||
$rustDeskConfigPath = Join-Path $env:WINDIR `
|
||||
'ServiceProfiles\LocalService\AppData\Roaming\RustDesk\config\RustDesk2.toml'
|
||||
$rustDeskConfig = if (Test-Path -LiteralPath $rustDeskConfigPath -PathType Leaf) {
|
||||
Get-Content -LiteralPath $rustDeskConfigPath -Raw
|
||||
}
|
||||
else {
|
||||
''
|
||||
}
|
||||
$rustDeskState = $null
|
||||
try {
|
||||
$rustDeskState = Get-Content -LiteralPath $rustDeskStatePath -Raw | ConvertFrom-Json
|
||||
$rustDeskId = [string]$rustDeskState.RustDeskId
|
||||
}
|
||||
catch {
|
||||
# The checks below report the missing or invalid state as one enrollment issue.
|
||||
}
|
||||
$rustDeskReady =
|
||||
$rustDeskService -and $rustDeskService.Status -eq 'Running' -and
|
||||
(Test-Path -LiteralPath $rustDeskSecretPath -PathType Leaf) -and
|
||||
$rustDeskState -and $rustDeskState.ServerAddress -eq $RustDeskServerAddress -and
|
||||
$rustDeskId -match '^\d+$' -and
|
||||
$rustDeskConfig -match [regex]::Escape("rendezvous_server = '$RustDeskServerAddress`:21116'")
|
||||
if (-not $rustDeskReady) {
|
||||
$issues.Add('RustDesk is not installed, running, or configured for the expected self-hosted server.')
|
||||
}
|
||||
}
|
||||
|
||||
$result = [pscustomobject]@{
|
||||
ComputerName = $env:COMPUTERNAME
|
||||
Domain = $computer.Domain
|
||||
@@ -175,6 +213,8 @@ $result = [pscustomobject]@{
|
||||
DotNetRuntimePresent = $dotNetRuntimePresent
|
||||
BrokerHealth = $brokerHealth
|
||||
RemoteAccessReady = $remoteAccessReady
|
||||
RustDeskReady = $rustDeskReady
|
||||
RustDeskId = $rustDeskId
|
||||
IsValid = $issues.Count -eq 0
|
||||
Issues = $issues.ToArray()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user