Install to /cache/rayhunter-data for tplink, add --data-dir parameter

This fixes several space-related issues at once.

We have observed the following phenomenon on TP-Link, Orbic and Moxee:

- Filling /data bricks the device (broken wifi, broken rndis, broken
  display)

- Filling /cache does not (it only bricks rayhunter if it's installed
  there, and it might break firmware updates)

Therefore it would make sense to store the entire rayhunter installation
in /cache.

This is a great idea for TP-Link and Moxee, because /cache is
significantly larger than /data. However, on Orbic, /data is
significantly larger than /cache!

This PR refactors orbic-network and tplink to use a shared codepath for
setting up the data directory. A symlink is created at /data/rayhunter,
and what it points to is device-specific:

- Orbic will have its data at `/data/rayhunter-data`

- There is a new alias `installer moxee` that overrides this to
  `/cache/rayhunter-data`

- TP-Link will have its data at /cache/rayhunter-data when there's no SD
  card, and /media/whatever when there is one.

In all cases, existing data is migrated to the new location. The user
can switch back and forth between two values of --data-dir and the data
will be moved over every time.

This PR has one huge wart, and that is that the USB installer for Orbic
remains untouched. The annoying reason for this is that the
DeviceConnection trait is insufficient to reflect all the different
kinds of shells you can have over USB: adb with fakeroot, and serial
with real root. I think it's not possible to create the right
directories with 'rootshell -c'.

I'm thinking of spawning a telnet server over serial, so that we can
just do telnet again, but this is for another time.
This commit is contained in:
Markus Unterwaditzer
2026-02-14 17:20:45 +01:00
committed by Will Greenberg
parent 83664e23f2
commit 3e38f500a9
8 changed files with 238 additions and 71 deletions

View File

@@ -102,7 +102,7 @@ pub async fn telnet_send_file(
let handle = tokio::spawn(async move {
telnet_send_command_with_output(
addr,
&format!("nc -l -p 8081 >{filename}.tmp"),
&format!("nc -l -p 8081 2>&1 >{filename}.tmp"),
wait_for_prompt,
)
.await
@@ -130,7 +130,7 @@ pub async fn telnet_send_file(
print!("attempt {attempts}... ");
}
{
let send_result: Result<()> = async {
let mut stream = stream?;
stream.write_all(payload).await?;
@@ -143,14 +143,21 @@ pub async fn telnet_send_file(
// application buffers here.
sleep(Duration::from_millis(1000)).await;
// ensure that stream is dropped before we wait for nc to terminate.
drop(stream);
Ok(())
}
.await;
handle
let nc_output = handle
.await
.context("background nc writer failed")?
.context("background nc writer failed")?
.context("background nc writer failed")?;
if let Err(e) = send_result {
bail!(
"Failed to send data to nc: {e}. nc output: '{}'",
nc_output.trim()
);
}
};
let checksum = md5::compute(payload);