From 960a1f6181df7bb0d75a8cc70d54e10a4d101917 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 17 Jun 2026 11:13:23 +0100 Subject: [PATCH] Keep Muninn Move pickup detail in identity state --- crates/muninn-daemon/src/main.rs | 13 +++++++- scripts/restart-nightwing-muninn.ps1 | 47 ++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/crates/muninn-daemon/src/main.rs b/crates/muninn-daemon/src/main.rs index 769248f..574a2d9 100644 --- a/crates/muninn-daemon/src/main.rs +++ b/crates/muninn-daemon/src/main.rs @@ -3772,7 +3772,18 @@ fn move_source_status(options: Options) -> Result<()> { } fn move_identity_status(options: Options) -> Result<()> { - let mut identities = current_move_identity_records(&options)?; + let node = open_node(&options, "muninn-move-identity-status")?; + let mut identities = node.cache().get_all::()?; + identities.retain(|identity| identity.host_id == options.host_id); + let current = current_move_identity_records(&options)?; + for identity in current { + if !identities + .iter() + .any(|existing| existing.identity_id == identity.identity_id) + { + identities.push(identity); + } + } if let Some(move_filter) = options.move_filter.as_deref() { identities.retain(|identity| identity.move_id == move_filter); } diff --git a/scripts/restart-nightwing-muninn.ps1 b/scripts/restart-nightwing-muninn.ps1 index c95d1dc..22f00f4 100644 --- a/scripts/restart-nightwing-muninn.ps1 +++ b/scripts/restart-nightwing-muninn.ps1 @@ -4,6 +4,7 @@ param( [string] $StorePath = "/home/metacrat/.local/state/gamecult/muninn/muninn.telemetry.cc", [string] $LogRoot = "/home/metacrat/.local/state/gamecult/muninn", [string[]] $MoveState = @(), + [string] $MoveHost = "5C:93:A2:9C:A8:A8", [string] $MoveEvidenceStream = "muninn:nightwing:move-evidence", [int] $IntervalSeconds = 15, [string] $IdunnRudpHealth = "10.77.0.2:17870", @@ -17,6 +18,46 @@ function Quote-ShSingle([string] $Value) { return "'" + ($Value -replace "'", "'\''") + "'" } +function Set-AsciiFile { + param( + [Parameter(Mandatory = $true)] [string] $Path, + [Parameter(Mandatory = $true)] [string] $Content + ) + + [System.IO.File]::WriteAllText($Path, ($Content -replace "`r?`n", "`n"), [System.Text.Encoding]::ASCII) +} + +function Invoke-UploadedShell { + param( + [Parameter(Mandatory = $true)] [string] $SshTarget, + [Parameter(Mandatory = $true)] [string] $RemoteScriptContent + ) + + $uploadId = [guid]::NewGuid().ToString("N") + $localTempRoot = Join-Path $env:TEMP "odin-nightwing-muninn-restart-$uploadId" + $localRemoteScript = Join-Path $localTempRoot "restart-nightwing-muninn-$uploadId.sh" + $localSftpBatch = Join-Path $localTempRoot "restart-nightwing-muninn-$uploadId.sftp" + $remoteScriptPath = "/tmp/restart-nightwing-muninn-$uploadId.sh" + + try { + New-Item -ItemType Directory -Force -Path $localTempRoot | Out-Null + Set-AsciiFile -Path $localRemoteScript -Content $RemoteScriptContent + Set-AsciiFile -Path $localSftpBatch -Content ('put "{0}" "{1}"' -f $localRemoteScript, $remoteScriptPath) + + & sftp.exe -b $localSftpBatch $SshTarget + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } + + & ssh.exe -o BatchMode=yes -o ConnectTimeout=10 $SshTarget "chmod +x '$remoteScriptPath' && bash '$remoteScriptPath'" + $remoteExit = $LASTEXITCODE + & ssh.exe -o BatchMode=yes -o ConnectTimeout=10 $SshTarget "rm -f '$remoteScriptPath'" + exit $remoteExit + } finally { + Remove-Item -LiteralPath $localTempRoot -Recurse -Force -ErrorAction SilentlyContinue + } +} + $moveStateSpecs = @($MoveState | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }) if ($moveStateSpecs.Count -eq 0) { $claimScript = Join-Path $PSScriptRoot "claim-nightwing-usb-moves.ps1" @@ -46,7 +87,8 @@ done set -- serve \ --store '$StorePath' \ --log-root '$LogRoot' \ - --host nightwing + --host nightwing \ + --move-host '$MoveHost' $moveStateSetLines set -- "`$@" \ --move-evidence-stream '$MoveEvidenceStream' \ @@ -67,5 +109,4 @@ if ! pgrep -af '[m]uninn serve .*--host nightwing' | grep -F -- '--idunn-rudp-he fi "@ -ssh.exe -o BatchMode=yes -o ConnectTimeout=5 $SshTarget $remoteScript -exit $LASTEXITCODE +Invoke-UploadedShell -SshTarget $SshTarget -RemoteScriptContent $remoteScript