Skip to content

Comments

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

Open
untitaker wants to merge 1 commit intomainfrom
cache-rayhunter
Open

Install to /cache/rayhunter-data for tplink, add --data-dir parameter#886
untitaker wants to merge 1 commit intomainfrom
cache-rayhunter

Conversation

@untitaker
Copy link
Collaborator

@untitaker untitaker commented Feb 14, 2026

This fixes several space-related issues at once. Ref #865

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

  • Moxee will have its data at /cache/rayhunter-data (you have to use installer moxee though)

  • 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.

@untitaker untitaker changed the title Install to /cache/rayhunter-data for tplink and orbic Install to /cache/rayhunter-data for tplink, add --data-dir parameter Feb 14, 2026
@untitaker untitaker force-pushed the cache-rayhunter branch 3 times, most recently from da21bf1 to f34e103 Compare February 14, 2026 18:57
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.
@untitaker untitaker marked this pull request as ready for review February 14, 2026 19:00
@BeigeBox
Copy link
Contributor

Looks good to me, no concerns

@untitaker untitaker mentioned this pull request Feb 14, 2026
8 tasks
@amyipdev
Copy link

Is additional testing necessary? I've got 2 unbricked Moxees I can test on

@untitaker
Copy link
Collaborator Author

I've tested that the installer works on tplink orbit and moxee, and I think I did a test to manually fill the cache partition too.

let result = output
.lines()
.find_map(|line| line.trim().strip_prefix("RL:"))
.unwrap_or("")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this not an error case?

/// - If `/data/rayhunter` is a symlink to a different location, moves from the old target
/// - If `/data/rayhunter` doesn't exist, just creates the symlink
/// - If `/data/rayhunter` is a symlink to `data_dir`, does nothing
pub async fn setup_data_directory<C: DeviceConnection>(conn: &mut C, data_dir: &str) -> Result<()> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems this only results in a new directory at data_dir if there was old data that needed migrating. should it not do a mkdir -p {data_dir} otherwise?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that's what's on line 139?

/// Overwrite config.toml even if it already exists on the device.
#[arg(long)]
reset_config: bool,

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this right? why are we migrating data_dir by default on Orbics?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was easier to make /data/rayhunter a symlink to some other directory in all cases than to special-case the orbic where /data/rayhunter is currently a dir. that's why the layout for orbic would end up with a symlink from /data/rayhunter to /data/rayhunter-data even though it's not really necessary

Comment on lines +91 to +92
/// Override the data directory path. Defaults to /cache/rayhunter-data (or SD card path when
/// SD card is used). Must not be /data/rayhunter.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think including a small snippet explaining why would help illustrate why this parameter exists:

Suggested change
/// Override the data directory path. Defaults to /cache/rayhunter-data (or SD card path when
/// SD card is used). Must not be /data/rayhunter.
/// Override the data directory path. Defaults to /cache/rayhunter-data (or SD card path when
/// SD card is used). Must not be /data/rayhunter, which lives on a storage partition that's
/// too small for normal Rayhunter operation.

}

async fn setup_rayhunter(admin_ip: &str, reset_config: bool) -> Result<()> {
async fn setup_rayhunter(admin_ip: &str, reset_config: bool, data_dir: &str) -> Result<()> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i feel like this should be an optional arg, and we don't call setup_data_directory if it's None


/// Check if a directory exists using a DeviceConnection
pub async fn dir_exists<C: DeviceConnection>(conn: &mut C, path: &str) -> bool {
conn.run_command(&format!("test -d {path} && echo exists || echo missing"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The helpers (setup_data_directory, readlink, dir_exists, is_symlink) interpolate paths directly into shell commands format!("mv {old_source} {data_dir}").

A --data-dir path containing spaces would break here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants