Harden RF node control and agent updates

This commit is contained in:
LittleSam129
2026-09-30 11:42:19 +03:00
parent a94f2db4ee
commit 0d6fff224e
34 changed files with 14010 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
$ErrorActionPreference = "Stop"
$taskName = "SDR Rover HTTP Control Server"
$repository = Split-Path -Parent $PSScriptRoot
$pythonCommand = Get-Command python.exe -ErrorAction Stop
$python = $pythonCommand.Source
$serverScript = Join-Path $repository "tools\rf001_http_control.py"
$tokenFile = Join-Path $repository ".local\rf001_http_token.txt"
$stateFile = Join-Path $repository ".local\rf001_http_server_state.json"
$logFile = Join-Path $repository ".local\logs\rf001_http_service.log"
foreach ($required in @($python, $serverScript, $tokenFile)) {
if (-not (Test-Path -LiteralPath $required -PathType Leaf)) {
throw "Required file is absent: $required"
}
}
$arguments = @(
"-u",
"-B",
('"{0}"' -f $serverScript),
"serve",
"--bind", "192.168.255.185",
"--port", "8765",
"--allowed-agent-ip", "192.168.255.56",
"--state-file", ('"{0}"' -f $stateFile),
"--token-file", ('"{0}"' -f $tokenFile),
"--log-file", ('"{0}"' -f $logFile),
"--bind-retry-seconds", "300"
) -join " "
$account = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
$action = New-ScheduledTaskAction -Execute $python -Argument $arguments -WorkingDirectory $repository
$trigger = New-ScheduledTaskTrigger -AtLogOn -User $account
$principal = New-ScheduledTaskPrincipal -UserId $account -LogonType Interactive -RunLevel Limited
$settings = New-ScheduledTaskSettingsSet `
-AllowStartIfOnBatteries `
-DontStopIfGoingOnBatteries `
-StartWhenAvailable `
-RestartCount 10 `
-RestartInterval (New-TimeSpan -Minutes 1) `
-ExecutionTimeLimit ([TimeSpan]::Zero) `
-MultipleInstances IgnoreNew
$existing = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
if ($null -ne $existing) {
Stop-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
}
Register-ScheduledTask `
-TaskName $taskName `
-Action $action `
-Trigger $trigger `
-Principal $principal `
-Settings $settings `
-Description "Authenticated RF-001 control server. No network RF TX operation." `
-Force | Out-Null
Start-ScheduledTask -TaskName $taskName
Start-Sleep -Seconds 2
$task = Get-ScheduledTask -TaskName $taskName
$taskInfo = Get-ScheduledTaskInfo -TaskName $taskName
"AUTOSTART_TASK=$taskName"
"AUTOSTART_ACCOUNT=$account"
"AUTOSTART_MODE=USER_LOGON"
"TASK_STATE=$($task.State)"
"LAST_TASK_RESULT=$($taskInfo.LastTaskResult)"
"RF_TX=0"