[18.06] luci-app-advanced-reboot: kernel version length bugfix + add routers
Signed-off-by: Stan Grishin <stangri@melmac.net>
This commit is contained in:
parent
dbaae4a815
commit
e277f936db
3 changed files with 23 additions and 13 deletions
|
@ -8,12 +8,12 @@ PKG_MAINTAINER:=Stan Grishin <stangri@melmac.net>
|
||||||
|
|
||||||
LUCI_TITLE:=Advanced Linksys Reboot Web UI
|
LUCI_TITLE:=Advanced Linksys Reboot Web UI
|
||||||
LUCI_DESCRIPTION:=Provides Web UI (found under System/Advanced Reboot) to reboot supported Linksys and ZyXEL routers to\
|
LUCI_DESCRIPTION:=Provides Web UI (found under System/Advanced Reboot) to reboot supported Linksys and ZyXEL routers to\
|
||||||
an altnerative partition. Also provides Web UI to shut down (power off) your device. Supported dual-partition\
|
an alternative partition. Also provides Web UI to shut down (power off) your device. Supported dual-partition\
|
||||||
routers are listed at https://github.com/stangri/openwrt-luci/blob/luci-app-advanced-reboot/applications/luci-app-advanced-reboot/README.md
|
routers are listed at https://github.com/stangri/openwrt-luci/blob/luci-app-advanced-reboot/applications/luci-app-advanced-reboot/README.md
|
||||||
|
|
||||||
LUCI_DEPENDS:=+luci-mod-admin-full
|
LUCI_DEPENDS:=+luci-mod-admin-full
|
||||||
LUCI_PKGARCH:=all
|
LUCI_PKGARCH:=all
|
||||||
PKG_RELEASE:=33
|
PKG_RELEASE:=39
|
||||||
|
|
||||||
include ../../luci.mk
|
include ../../luci.mk
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
# Advanced Reboot Web UI (luci-app-advanced-reboot)
|
# Advanced Reboot Web UI (luci-app-advanced-reboot)
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
This package allows you to reboot to an alternative partition on the supported (dual-partition) routers and to power off (power down) your OpenWrt/LEDE Project device.
|
|
||||||
|
This package allows you to reboot to an alternative partition on the supported (dual-partition) routers and to power off (power down) your OpenWrt device.
|
||||||
|
|
||||||
## Supported Devices
|
## Supported Devices
|
||||||
|
|
||||||
Currently supported dual-partition devices include:
|
Currently supported dual-partition devices include:
|
||||||
|
|
||||||
- Linksys EA3500
|
- Linksys EA3500
|
||||||
- Linksys E4200v2
|
- Linksys E4200v2
|
||||||
- Linksys EA4500
|
- Linksys EA4500
|
||||||
|
- Linksys EA6350v3
|
||||||
- Linksys EA8500
|
- Linksys EA8500
|
||||||
- Linksys WRT1200AC
|
- Linksys WRT1200AC
|
||||||
- Linksys WRT1900AC
|
- Linksys WRT1900AC
|
||||||
|
@ -17,22 +21,27 @@ Currently supported dual-partition devices include:
|
||||||
- Linksys WRT32X
|
- Linksys WRT32X
|
||||||
- ZyXEL NBG6817
|
- ZyXEL NBG6817
|
||||||
|
|
||||||
If you're interested in having your device supported, please post in [LEDE Project Forum Support Thread](https://forum.lede-project.org/t/web-ui-to-reboot-to-another-partition-dual-partition-routers/3423).
|
If you're interested in having your device supported, please post in [OpenWrt Forum Support Thread](https://forum.openwrt.org/t/web-ui-to-reboot-to-another-partition-dual-partition-routers/3423).
|
||||||
|
|
||||||
## Screenshot (luci-app-advanced-reboot)
|
## Screenshot (luci-app-advanced-reboot)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## How to install
|
## How to install
|
||||||
|
|
||||||
Install ```luci-app-advanced-reboot``` from Web UI or connect to your router via ssh and run the following commands:
|
Install ```luci-app-advanced-reboot``` from Web UI or connect to your router via ssh and run the following commands:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
opkg update
|
opkg update
|
||||||
opkg install luci-app-advanced-reboot
|
opkg install luci-app-advanced-reboot
|
||||||
```
|
```
|
||||||
|
|
||||||
## Notes/Known Issues
|
## Notes/Known Issues
|
||||||
|
|
||||||
- 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.
|
- 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/LEDE Project unless you reflash it, losing all the settings.
|
- 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.
|
- 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.
|
||||||
|
|
||||||
## Thanks
|
## Thanks
|
||||||
I'd like to thank everyone who helped create, test and troubleshoot this package. Without help from [@hnyman](https://github.com/hnyman), [@jpstyves](https://github.com/jpstyves) and many contributions from [@slh](https://github.com/pkgadd) it wouldn't have been possible.
|
|
||||||
|
I'd like to thank everyone who helped create, test and troubleshoot this package. Without help from [@hnyman](https://github.com/hnyman), [@jpstyves](https://github.com/jpstyves), [@imi2003](https://github.com/imi2003) and many contributions from [@slh](https://github.com/pkgadd) it wouldn't have been possible.
|
||||||
|
|
|
@ -7,6 +7,7 @@ devices = {
|
||||||
-- deviceName, boardName, partition1, partition2, offset, envVar1, envVar1Value1, envVar1Value2, envVar2, envVar2Value1, envVar2Value2
|
-- deviceName, boardName, partition1, partition2, offset, envVar1, envVar1Value1, envVar1Value2, envVar2, envVar2Value1, envVar2Value2
|
||||||
{"Linksys EA3500", "linksys-audi", "mtd3", "mtd5", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"},
|
{"Linksys EA3500", "linksys-audi", "mtd3", "mtd5", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"},
|
||||||
{"Linksys E4200v2/EA4500", "linksys-viper", "mtd3", "mtd5", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"},
|
{"Linksys E4200v2/EA4500", "linksys-viper", "mtd3", "mtd5", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"},
|
||||||
|
{"Linksys EA6350v3", "linksys-ea6350v3", "mtd10", "mtd12", 192, "boot_part", 1, 2},
|
||||||
{"Linksys EA8500", "ea8500", "mtd13", "mtd15", 32, "boot_part", 1, 2},
|
{"Linksys EA8500", "ea8500", "mtd13", "mtd15", 32, "boot_part", 1, 2},
|
||||||
-- {"Linksys EA9500", "linksys-panamera", "mtd3", "mtd6", 28, "boot_part", 1, 2},
|
-- {"Linksys EA9500", "linksys-panamera", "mtd3", "mtd6", 28, "boot_part", 1, 2},
|
||||||
{"Linksys WRT1200AC", "linksys-caiman", "mtd4", "mtd6", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"},
|
{"Linksys WRT1200AC", "linksys-caiman", "mtd4", "mtd6", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"},
|
||||||
|
@ -34,11 +35,11 @@ for i=1, #devices do
|
||||||
boot_envvar2_partition_one = devices[i][10] or nil
|
boot_envvar2_partition_one = devices[i][10] or nil
|
||||||
boot_envvar2_partition_two = devices[i][11] or nil
|
boot_envvar2_partition_two = devices[i][11] or nil
|
||||||
if partition_one_mtd and partition_skip then
|
if partition_one_mtd and partition_skip then
|
||||||
partition_one_label = luci.util.trim(luci.sys.exec("dd if=/dev/" .. partition_one_mtd .. " bs=1 skip=" .. partition_skip .. " count=25" .. " 2>/dev/null"))
|
partition_one_label = luci.util.trim(luci.sys.exec("dd if=/dev/" .. partition_one_mtd .. " bs=1 skip=" .. partition_skip .. " count=128" .. " 2>/dev/null"))
|
||||||
n, partition_one_version = string.match(partition_one_label, '(Linux)-([%d|.]+)')
|
n, partition_one_version = string.match(partition_one_label, '(Linux)-([%d|.]+)')
|
||||||
end
|
end
|
||||||
if partition_two_mtd and partition_skip then
|
if partition_two_mtd and partition_skip then
|
||||||
partition_two_label = luci.util.trim(luci.sys.exec("dd if=/dev/" .. partition_two_mtd .. " bs=1 skip=" .. partition_skip .. " count=25" .. " 2>/dev/null"))
|
partition_two_label = luci.util.trim(luci.sys.exec("dd if=/dev/" .. partition_two_mtd .. " bs=1 skip=" .. partition_skip .. " count=128" .. " 2>/dev/null"))
|
||||||
n, partition_two_version = string.match(partition_two_label, '(Linux)-([%d|.]+)')
|
n, partition_two_version = string.match(partition_two_label, '(Linux)-([%d|.]+)')
|
||||||
end
|
end
|
||||||
if partition_one_label and string.find(partition_one_label, "LEDE") then partition_one_os = "LEDE" end
|
if partition_one_label and string.find(partition_one_label, "LEDE") then partition_one_os = "LEDE" end
|
||||||
|
@ -63,7 +64,7 @@ for i=1, #devices do
|
||||||
if device_name and device_name == "ZyXEL NBG6817" then
|
if device_name and device_name == "ZyXEL NBG6817" then
|
||||||
if not zyxelFlagPartition then zyxelFlagPartition = luci.util.trim(luci.sys.exec("source /lib/functions.sh; find_mtd_part 0:DUAL_FLAG")) end
|
if not zyxelFlagPartition then zyxelFlagPartition = luci.util.trim(luci.sys.exec("source /lib/functions.sh; find_mtd_part 0:DUAL_FLAG")) end
|
||||||
if not zyxelFlagPartition then
|
if not zyxelFlagPartition then
|
||||||
errorMessage = errorMessage .. luci.i18n.translate("Unable to find Dual Boot Flag Partition." .. " ")
|
errorMessage = errorMessage or "" .. luci.i18n.translate("Unable to find Dual Boot Flag Partition." .. " ")
|
||||||
luci.util.perror(luci.i18n.translate("Unable to find Dual Boot Flag Partition."))
|
luci.util.perror(luci.i18n.translate("Unable to find Dual Boot Flag Partition."))
|
||||||
else
|
else
|
||||||
current_partition = tonumber(luci.sys.exec("dd if=" .. zyxelFlagPartition .. " bs=1 count=1 2>/dev/null | hexdump -n 1 -e '1/1 \"%d\"'"))
|
current_partition = tonumber(luci.sys.exec("dd if=" .. zyxelFlagPartition .. " bs=1 count=1 2>/dev/null | hexdump -n 1 -e '1/1 \"%d\"'"))
|
||||||
|
@ -121,7 +122,7 @@ function action_altreboot()
|
||||||
newEnvSetting = curEnvSetting == boot_envvar1_partition_one and boot_envvar1_partition_two or boot_envvar1_partition_one
|
newEnvSetting = curEnvSetting == boot_envvar1_partition_one and boot_envvar1_partition_two or boot_envvar1_partition_one
|
||||||
errorCode = luci.sys.call("/usr/sbin/fw_setenv " .. boot_envvar1 .. " " .. newEnvSetting)
|
errorCode = luci.sys.call("/usr/sbin/fw_setenv " .. boot_envvar1 .. " " .. newEnvSetting)
|
||||||
if errorCode ~= 0 then
|
if errorCode ~= 0 then
|
||||||
errorMessage = errorMessage .. luci.i18n.translate("Unable to set firmware environment variable") .. ": " .. boot_envvar1 .. " " .. luci.i18n.translate("to") .. " " .. newEnvSetting .. ". "
|
errorMessage = errorMessage or "" .. luci.i18n.translate("Unable to set firmware environment variable") .. ": " .. boot_envvar1 .. " " .. luci.i18n.translate("to") .. " " .. newEnvSetting .. ". "
|
||||||
luci.util.perror(luci.i18n.translate("Unable to set firmware environment variable") .. ": " .. boot_envvar1 .. " " .. luci.i18n.translate("to") .. " " .. newEnvSetting .. ".")
|
luci.util.perror(luci.i18n.translate("Unable to set firmware environment variable") .. ": " .. boot_envvar1 .. " " .. luci.i18n.translate("to") .. " " .. newEnvSetting .. ".")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -129,13 +130,13 @@ function action_altreboot()
|
||||||
if boot_envvar2 then
|
if boot_envvar2 then
|
||||||
curEnvSetting = luci.util.trim(luci.sys.exec("/usr/sbin/fw_printenv -n " .. boot_envvar2))
|
curEnvSetting = luci.util.trim(luci.sys.exec("/usr/sbin/fw_printenv -n " .. boot_envvar2))
|
||||||
if not curEnvSetting then
|
if not curEnvSetting then
|
||||||
errorMessage = errorMessage .. luci.i18n.translate("Unable to obtain firmware environment variable") .. ": " .. boot_envvar2 .. ". "
|
errorMessage = errorMessage or "" .. luci.i18n.translate("Unable to obtain firmware environment variable") .. ": " .. boot_envvar2 .. ". "
|
||||||
luci.util.perror(luci.i18n.translate("Unable to obtain firmware environment variable") .. ": " .. boot_envvar2 .. ".")
|
luci.util.perror(luci.i18n.translate("Unable to obtain firmware environment variable") .. ": " .. boot_envvar2 .. ".")
|
||||||
else
|
else
|
||||||
newEnvSetting = curEnvSetting == boot_envvar2_partition_one and boot_envvar2_partition_two or boot_envvar2_partition_one
|
newEnvSetting = curEnvSetting == boot_envvar2_partition_one and boot_envvar2_partition_two or boot_envvar2_partition_one
|
||||||
errorCode = luci.sys.call("/usr/sbin/fw_setenv " .. boot_envvar2 .. " '" .. newEnvSetting .. "'")
|
errorCode = luci.sys.call("/usr/sbin/fw_setenv " .. boot_envvar2 .. " '" .. newEnvSetting .. "'")
|
||||||
if errorCode ~= 0 then
|
if errorCode ~= 0 then
|
||||||
errorMessage = errorMessage .. luci.i18n.translate("Unable to set firmware environment variable") .. ": " .. boot_envvar2 .. " " .. luci.i18n.translate("to") .. " " .. newEnvSetting .. ". "
|
errorMessage = errorMessage or "" .. luci.i18n.translate("Unable to set firmware environment variable") .. ": " .. boot_envvar2 .. " " .. luci.i18n.translate("to") .. " " .. newEnvSetting .. ". "
|
||||||
luci.util.perror(luci.i18n.translate("Unable to set firmware environment variable") .. ": " .. boot_envvar2 .. " " .. luci.i18n.translate("to") .. " " .. newEnvSetting .. ".")
|
luci.util.perror(luci.i18n.translate("Unable to set firmware environment variable") .. ": " .. boot_envvar2 .. " " .. luci.i18n.translate("to") .. " " .. newEnvSetting .. ".")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -151,7 +152,7 @@ function action_altreboot()
|
||||||
if zyxelNewBootFlag then
|
if zyxelNewBootFlag then
|
||||||
errorCode = luci.sys.call("printf \"" .. zyxelNewBootFlag .. "\" >" .. zyxelFlagPartition )
|
errorCode = luci.sys.call("printf \"" .. zyxelNewBootFlag .. "\" >" .. zyxelFlagPartition )
|
||||||
if errorCode ~= 0 then
|
if errorCode ~= 0 then
|
||||||
errorMessage = errorMessage .. luci.i18n.translate("Unable to set Dual Boot Flag Partition entry for partition") .. ": " .. zyxelFlagPartition .. ". "
|
errorMessage = errorMessage or "" .. luci.i18n.translate("Unable to set Dual Boot Flag Partition entry for partition") .. ": " .. zyxelFlagPartition .. ". "
|
||||||
luci.util.perror(luci.i18n.translate("Unable to set Dual Boot Flag Partition entry for partition") .. ": " .. zyxelFlagPartition .. ".")
|
luci.util.perror(luci.i18n.translate("Unable to set Dual Boot Flag Partition entry for partition") .. ": " .. zyxelFlagPartition .. ".")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue