POC: On-device config management

I've been mulling over the idea of a simple on-device profile/role/configuration/backup management for a while. The use case is a portable/travel router that might serve different roles at different locations, e.g. a Wi-Fi router at home, a portable client + AP + VPN in a cafe, etc. Which can already be done by using the existing config backup/restore UI, but then you need to always have a device with the backups a hand. Or, alternatively, using sysupgrade via shell, which is not as convenient on the go (despite you looking like hacker in the middle of a cafe).

I made this POC, mainly for myself, to implement the basic functionality of saving/restoring multiple local configs, including partial restores, via the System > Flash operations UI (luci-mod-system). This uses sysupgrade for creating and restoring full backups under the hood, and a small rpcd plugin to calculate and restore partial ones. Backups are stored under /etc/backups.

The idea is that this leads to a more generic profile/role management UI in the future.

This post if for gathering feedback and suggestions about the UI and functionality.

Here's a video of it in action, without doing an actual restore. It might not be viewable outside of YouTube in hi-res (or perhaps it's still being processed). The UI is rough around the edges, so please don't throw all the rocks at once :face_with_peeking_eye:

TODO:

  • figure out what to do about the backup files during sysupgrade
  • integrate hardware switches to switch profiles
  • a nicer profile switching UI on top of this functionality
1 Like

Look at travelmate which can handle different uplinks, VPNs, and the like. Does your POC differ significantly in a way that would make sense to further flesh out?

Unless I misunderstand what travelmate does, the idea behind this POC is to have a simple single-click UI to switch profiles, that are preconfigured in advance. So this would live above travelmate (and include it's configs) or any other software on device. The hypothetical scenario is a device having physical buttons/switches like Home, Work, Starbucks (which might have travelmate enabled) that would switch to the respective profiles when triggered.

Keep in mind that too many flash writes may speed up flash wear. To avoid unnecessary flash wear, either gzip the files or make sure that only files which have changed are rewritten when updating backups. Or both. To check if files are identical, you could use md5sum, or for files where lines order doesn't matter, you could use this function which intelligently compares non-empty lines while ignoring their order.

1 Like

I've implemented a partial config restore, where the individual file changes are based on an md5 checksum. Since the code is shared with the uploaded config restores, partial restore is enabled there as well. Here's the video of the current UI in actions. It's a bit clunky, but works as intended.

And thanks to @antonk for the feedback.

1 Like