luci-app-advanced-reboot: add logger messages, README update

Signed-off-by: Stan Grishin <stangri@melmac.net>
This commit is contained in:
Stan Grishin 2019-11-19 16:55:51 -07:00
parent af8310fd15
commit b6e00b7a21
2 changed files with 39 additions and 2 deletions

View file

@ -44,6 +44,35 @@ If the ```luci-app-advanced-reboot``` package is not found in the official feed/
- When you reboot to a different partition, your current settings (WiFi SSID/password, etc.) will not apply to a different partition. Different partitions might have completely different settings and even firmware.
- If you reboot to a partition which doesn't allow you to switch boot partitions (like stock vendor firmware), you might not be able to boot back to OpenWrt unless you reflash it, losing all the settings.
- Some devices allow you to trigger reboot to an alternative partition by interrupting boot 3 times in a row (by resetting/switching off the device or pulling power). As these methods might be different for different devices, do your own homework.
- Newer versions of this package try to mount alternative partition on compatible NAND routers in order to retrieve detailed firmware information. When that happens, it is normal to have messages similar to the below in the system log:
```sh
Tue Nov 19 15:45:03 2019 user.notice luci-app-advanced-reboot: attempting to mount alternative partition (mtd6)
Tue Nov 19 15:45:03 2019 kern.notice kernel: [30392.673826] ubi2: attaching mtd6
Tue Nov 19 15:45:03 2019 kern.notice kernel: [30392.876698] ubi2: scanning is finished
Tue Nov 19 15:45:03 2019 kern.notice kernel: [30392.885267] ubi2: attached mtd6 (name "rootfs1", size 74 MiB)
Tue Nov 19 15:45:03 2019 kern.notice kernel: [30392.891063] ubi2: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
Tue Nov 19 15:45:03 2019 kern.notice kernel: [30392.898011] ubi2: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
Tue Nov 19 15:45:03 2019 kern.notice kernel: [30392.904878] ubi2: VID header offset: 2048 (aligned 2048), data offset: 4096
Tue Nov 19 15:45:03 2019 kern.notice kernel: [30392.911928] ubi2: good PEBs: 592, bad PEBs: 0, corrupted PEBs: 0
Tue Nov 19 15:45:03 2019 kern.notice kernel: [30392.917962] ubi2: user volume: 2, internal volumes: 1, max. volumes count: 128
Tue Nov 19 15:45:03 2019 kern.notice kernel: [30392.925252] ubi2: max/mean erase counter: 48/32, WL threshold: 4096, image sequence number: 1659081076
Tue Nov 19 15:45:03 2019 kern.notice kernel: [30392.934623] ubi2: available PEBs: 0, total reserved PEBs: 592, PEBs reserved for bad PEB handling: 40
Tue Nov 19 15:45:03 2019 kern.notice kernel: [30392.944346] ubi2: background thread "ubi_bgt2d" started, PID 26780
Tue Nov 19 15:45:03 2019 kern.info kernel: [30392.952596] block ubiblock2_0: created from ubi2:0 (rootfs)
Tue Nov 19 15:45:03 2019 kern.notice kernel: [30392.964083] UBIFS (ubi2:1): background thread "ubifs_bgt2_1" started, PID 26787
Tue Nov 19 15:45:03 2019 kern.notice kernel: [30393.009298] UBIFS (ubi2:1): UBIFS: mounted UBI device 2, volume 1, name "rootfs_data"
Tue Nov 19 15:45:03 2019 kern.notice kernel: [30393.017185] UBIFS (ubi2:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
Tue Nov 19 15:45:03 2019 kern.notice kernel: [30393.027213] UBIFS (ubi2:1): FS size: 61075456 bytes (58 MiB, 481 LEBs), journal size 3047424 bytes (2 MiB, 24 LEBs)
Tue Nov 19 15:45:03 2019 kern.notice kernel: [30393.037733] UBIFS (ubi2:1): reserved for root: 2884744 bytes (2817 KiB)
Tue Nov 19 15:45:03 2019 kern.notice kernel: [30393.044389] UBIFS (ubi2:1): media format: w4/r0 (latest is w5/r0), UUID 76F0C52C-6197-4E00-B306-747262B06545, small LPT model
Tue Nov 19 15:45:03 2019 user.notice luci-app-advanced-reboot: attempting to unmount alternative partition (mtd6)
Tue Nov 19 15:45:03 2019 kern.notice kernel: [30393.132743] UBIFS (ubi2:1): un-mount UBI device 2
Tue Nov 19 15:45:03 2019 kern.notice kernel: [30393.137481] UBIFS (ubi2:1): background thread "ubifs_bgt2_1" stops
Tue Nov 19 15:45:03 2019 kern.info kernel: [30393.390961] block ubiblock2_0: released
Tue Nov 19 15:45:03 2019 kern.notice kernel: [30393.396576] ubi2: detaching mtd6
Tue Nov 19 15:45:03 2019 kern.notice kernel: [30393.400117] ubi2: mtd6 is detached
```
## Thanks

View file

@ -15,6 +15,11 @@ local http = require "luci.http"
local sys = require "luci.sys"
local dispatcher = require "luci.dispatcher"
local uci = require "luci.model.uci".cursor()
local packageName = "luci-app-advanced-reboot"
function logger(t)
util.exec("logger -t " .. packageName .. " '" .. tostring(t) .. "'")
end
function is_alt_mountable(p1_mtd, p2_mtd)
if p1_mtd:sub(1,3) == "mtd" and
@ -33,11 +38,13 @@ function get_partition_os_info(op_ubi)
if fs.access("/etc/os-release") then
cp_info = util.trim(util.exec('. /etc/os-release && echo "$PRETTY_NAME"'))
end
logger(i18n.translate("attempting to mount alternative partition") .. " (mtd" .. tostring(op_ubi) .. ")")
alt_partition_unmount(op_ubi)
alt_partition_mount(op_ubi)
if fs.access("/alt/rom/etc/os-release") then
ap_info = util.trim(util.exec('. /alt/rom/etc/os-release && echo "$PRETTY_NAME"'))
end
logger(i18n.translate("attempting to unmount alternative partition") .. " (mtd" .. tostring(op_ubi) .. ")")
alt_partition_unmount(op_ubi)
return cp_info, ap_info
end
@ -58,10 +65,12 @@ function alt_partition_mount(op_ubi)
end
function alt_partition_unmount(op_ubi)
local mtdCount = tonumber(util.exec("ubinfo | grep 'Present UBI devices' | grep -c ','"))
mtdCount = mtdCount and mtdCount + 1 or 10
-- util.exec("[ -d /alt/firmware ] && umount /alt/firmware")
util.exec("[ -d /alt/overlay ] && umount /alt/overlay")
util.exec("[ -d /alt/rom ] && umount /alt/rom")
for i = 0, 10 do
for i = 0, mtdCount do
if not fs.access("/sys/devices/virtual/ubi/ubi" .. tostring(i) .. "/mtd_num") then break end
ubi_mtd = tonumber(util.trim(util.exec("cat /sys/devices/virtual/ubi/ubi" .. i .. "/mtd_num")))
if ubi_mtd and ubi_mtd == op_ubi then
@ -266,7 +275,6 @@ function action_altreboot()
end
function action_poweroff()
local uci = require "luci.model.uci".cursor()
if http.formvalue("cancel") then
http.redirect(dispatcher.build_url('admin/system/advanced_reboot'))
return