Make Idunn witness checks use daemon-owned state

This commit is contained in:
Meta Vens 2026-06-23 17:04:07 +01:00
commit 544668b6ef
3 changed files with 46 additions and 11 deletions

View file

@ -67,6 +67,21 @@ else
echo 'Muninn serve process is not running on Nightwing' >&2
exit 1
fi
process_line="`$(pgrep -af '[m]uninn serve .*--host nightwing' | head -n1 || true)"
if [ -z "`$process_line" ]; then
echo 'Nightwing Muninn serve command line is unavailable' >&2
exit 1
fi
for pattern in \
'--idunn-rudp-health $IdunnRudpHealth' \
'--idunn-daemon nightwing-muninn' \
'--idunn-health-contract muninn.cultnet-rudp-remote-telemetry-and-move-hid'
do
if ! printf '%s\n' "`$process_line" | grep -F -- "`$pattern" >/dev/null 2>&1; then
echo "Nightwing Muninn serve command line is missing `$pattern" >&2
exit 1
fi
done
if [ ! -f '$StorePath' ]; then
echo 'Muninn telemetry store is missing on Nightwing' >&2
exit 1
@ -78,13 +93,18 @@ if [ "`$store_age" -gt '$MaxStoreAgeSeconds' ]; then
echo "Muninn telemetry store is stale on Nightwing (`$store_age s old)" >&2
exit 1
fi
identity_output="`$('$MuninnExe' move-identity-status --store '$StorePath' --host nightwing)"
if printf '%s\n' "`$identity_output" | grep -Fq 'No Muninn Move identity records found'; then
echo 'Muninn Move identity roster is empty on Nightwing' >&2
exit 1
if printf '%s\n' "`$process_line" | grep -F -- '--move-state' >/dev/null 2>&1 || \
printf '%s\n' "`$process_line" | grep -F -- '--move-evidence-stream' >/dev/null 2>&1; then
identity_output="`$('$MuninnExe' move-identity-status --store '$StorePath' --host nightwing)"
if printf '%s\n' "`$identity_output" | grep -Fq 'No Muninn Move identity records found'; then
echo 'Muninn Move identity roster is empty on Nightwing' >&2
exit 1
fi
identity_count="`$(printf '%s\n' "`$identity_output" | grep -c 'move-identity move=')"
echo "Muninn healthy: nightwing store_age=`${store_age}s move_runtime=explicit move_identities=`${identity_count}"
else
echo "Muninn healthy: nightwing store_age=`${store_age}s move_runtime=disabled"
fi
identity_count="`$(printf '%s\n' "`$identity_output" | grep -c 'move-identity move=')"
echo "Muninn healthy: nightwing store_age=`${store_age}s move_identities=`${identity_count}"
"@
Invoke-NightwingUploadedShell -SshTarget $SshTarget -RemoteScriptContent $remoteScript -TempPrefix "odin-nightwing-muninn-health"

View file

@ -1,2 +1,2 @@
@echo off
powershell.exe -NoProfile -ExecutionPolicy Bypass -File E:\Projects\Odin\scripts\restart-nightwing-muninn.ps1
powershell.exe -NoProfile -ExecutionPolicy Bypass -File E:\Projects\Odin\scripts\restart-nightwing-muninn.ps1 -DiscoverMoveState -ClaimUsbMoves

View file

@ -4,6 +4,8 @@ param(
[string] $StorePath = "/home/metacrat/.local/state/gamecult/muninn/muninn.telemetry.cc",
[string] $LogRoot = "/home/metacrat/.local/state/gamecult/muninn",
[string[]] $MoveState = @(),
[switch] $DiscoverMoveState,
[switch] $ClaimUsbMoves,
[string] $MoveEvidenceStream = "muninn:nightwing:move-evidence",
[int] $IntervalSeconds = 15,
[string] $IdunnRudpHealth = "10.77.0.2:17870",
@ -18,16 +20,30 @@ function Quote-ShSingle([string] $Value) {
}
$moveStateSpecs = @($MoveState | Where-Object { -not [string]::IsNullOrWhiteSpace($_) })
if ($moveStateSpecs.Count -eq 0) {
if ($ClaimUsbMoves.IsPresent -and -not $DiscoverMoveState.IsPresent -and $moveStateSpecs.Count -eq 0) {
throw "-ClaimUsbMoves requires -DiscoverMoveState or at least one explicit -MoveState value."
}
if ($DiscoverMoveState.IsPresent) {
$claimScript = Join-Path $PSScriptRoot "claim-nightwing-usb-moves.ps1"
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File $claimScript -SshTarget $SshTarget
if ($ClaimUsbMoves.IsPresent) {
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File $claimScript -SshTarget $SshTarget
}
$sourceScript = Join-Path $PSScriptRoot "get-nightwing-move-state-sources.ps1"
$moveStateSpecs = @(& powershell.exe -NoProfile -ExecutionPolicy Bypass -File $sourceScript -SshTarget $SshTarget)
if ($moveStateSpecs.Count -eq 0) {
throw "Nightwing Move runtime was explicitly requested, but no live Move state sources were discovered."
}
}
$moveStateSetLines = ($moveStateSpecs | ForEach-Object {
"set -- ""`$@"" --move-state $(Quote-ShSingle $_)"
}) -join "`n"
$moveRuntimeSetLines = @()
if ($moveStateSpecs.Count -gt 0) {
$moveRuntimeSetLines += $moveStateSetLines
$moveRuntimeSetLines += "set -- ""`$@"" --move-evidence-stream $(Quote-ShSingle $MoveEvidenceStream)"
}
$moveRuntimeSetBlock = ($moveRuntimeSetLines -join "`n")
$remoteScript = @"
set -eu
@ -47,9 +63,8 @@ set -- serve \
--store '$StorePath' \
--log-root '$LogRoot' \
--host nightwing
$moveStateSetLines
$moveRuntimeSetBlock
set -- "`$@" \
--move-evidence-stream '$MoveEvidenceStream' \
--interval-seconds '$IntervalSeconds' \
--idunn-rudp-health '$IdunnRudpHealth' \
--idunn-daemon '$IdunnDaemon' \