Web UI to reboot to another partition (for Linksys/ZyXEL dual-partition routers) and to power off/power down

I find the app quite useful, but you need to be careful with it. It is far too dangerous for novice users to be presented casually for everybody.

Support for each router needs to be added separately to decrease the risk of bricking the device. For example, some device uses boot_part values "0" and "1". So when you detect "1" there, it would be wrong to change that to "2".

Out of my head, some ideas for developing to a really nice package:

A page that tells the user which firmware is installed in which partition and offers the possibility to switch to the other partition.

  • detect the device. e.g. using /tmp/sysinfo/board_name
  • based on that detection, look for available firmwares on part1 and part2 using the correct mtd partitions:
    • e.g. in wrt3200acm:
      dd if=/dev/mtd5 bs=1 skip=32 count=25
      (25 chars should be enough for LEDE, Openwrt and Linksys ID strings. It seems to always be a properly 0-terminated string)

      • mtd5 offset 32: "ARM LEDE Linux 4.9.20" = LEDE firmware
      • mtd7 offset 32: "Linksys WRT3200 Router" = Linksys OEM firmware
      • (Openwrt would be "ARM Openwrt Linux 4.4.44" if I remember right)
    • based on wiki, for wrt1900acs that would be mtd4 and mtd6

    • for EA8500, mtd13 and mtd15, etc.

  • Display that detection result to the user and also tell him which partition we are currently running (based on boot_part).
  • Offer the possibility to switch boot to the other partition.
    • Also mention that the other partition will boot with the config settings currently on that partition, not the ones used by the current partition. That will be unclear for novice users, as it is not self-evident.
  • If yes, then use the known parameters to set the needed u-boot env variables.

Package needs to contain a list of supported router and their parameters. Something like

device, part1, part2, offset, env_var_1, value_1_1, value_2_2, env_var_2, value_2_1, value_2_2
wrt23200acm, mtd5, mtd7, 32, boot_part, 1, 2, bootcmd, "run nandboot", "run altnandboot"
wrt1900acs, mtd4, mtd6, 32, boot_part, 1, 2, bootcmd, "run nandboot", "run altnandboot"
EA8500, mtd13, mtd15, ...