summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-advanced-reboot/luasrc
diff options
context:
space:
mode:
authorStan Grishin <stangri@melmac.net>2018-07-10 12:33:23 -0700
committerStan Grishin <stangri@melmac.net>2018-07-10 12:33:23 -0700
commit3c332e456482bdb9ae231040f50d010f67355086 (patch)
tree0beea70b3094a32e0235cb63e3a11a3c603dce9f /applications/luci-app-advanced-reboot/luasrc
parent36b6d98747e2d1830bbc6aa076303048bbb98d3d (diff)
luci-app-advanced-reboot: support for Linksys WRT32X
Signed-off-by: Stan Grishin <stangri@melmac.net>
Diffstat (limited to 'applications/luci-app-advanced-reboot/luasrc')
-rw-r--r--applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua45
-rw-r--r--applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/advanced_reboot.htm6
2 files changed, 26 insertions, 25 deletions
diff --git a/applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua b/applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua
index b5dd4fe0f..f4d28145e 100644
--- a/applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua
+++ b/applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua
@@ -3,25 +3,26 @@
module("luci.controller.advanced_reboot", package.seeall)
--- device_name, board_name, part1, part2, offset, env_var_1, value_1_1, value_1_2, env_var_2, value_2_1, value_2_2
devices = {
+ -- 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 E4200v2/EA4500", "linksys-viper", "mtd3", "mtd5", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"},
{"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 WRT1900AC", "linksys-mamba", "mtd4", "mtd6", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"},
{"Linksys WRT1900ACv2", "linksys-cobra", "mtd4", "mtd6", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"},
{"Linksys WRT1900ACS", "linksys-shelby", "mtd4", "mtd6", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"},
{"Linksys WRT3200ACM", "linksys-rango", "mtd5", "mtd7", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"},
- {"ZyXEL NBG6817","nbg6817","mmcblk0p4","mmcblk0p7",32,nil,255,1}
+ {"Linksys WRT32X", "linksys-venom", "mtd5", "mtd7", nil, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"},
+ {"ZyXEL NBG6817","nbg6817","mmcblk0p4","mmcblk0p7", 32, nil, 255, 1}
}
-errorMessage = ""
-device_board_name = luci.util.trim(luci.sys.exec("cat /tmp/sysinfo/board_name"))
+errorMessage = nil
+rom_board_name = luci.util.trim(luci.sys.exec("cat /tmp/sysinfo/board_name"))
for i=1, #devices do
- table_board_name = devices[i][2]:gsub('%p','')
- if device_board_name and device_board_name:gsub('%p',''):match(table_board_name) then
+ device_board_name = devices[i][2]:gsub('%p','')
+ if rom_board_name and rom_board_name:gsub('%p',''):match(device_board_name) then
device_name = devices[i][1]
partition_one_mtd = devices[i][3] or nil
partition_two_mtd = devices[i][4] or nil
@@ -40,16 +41,20 @@ for i=1, #devices do
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"))
n, partition_two_version = string.match(partition_two_label, '(Linux)-([%d|.]+)')
end
- if string.find(partition_one_label, "LEDE") then partition_one_os = "LEDE" end
- if string.find(partition_one_label, "OpenWrt") then partition_one_os = "OpenWrt" end
- if string.find(partition_one_label, "Linksys") then partition_one_os = "Linksys" end
- if string.find(partition_two_label, "LEDE") then partition_two_os = "LEDE" end
- if string.find(partition_two_label, "OpenWrt") then partition_two_os = "OpenWrt" end
- if string.find(partition_two_label, "Linksys") then partition_two_os = "Linksys" 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, "OpenWrt") then partition_one_os = "OpenWrt" end
+ if partition_one_label and string.find(partition_one_label, "Linksys") then partition_one_os = "Linksys" end
+ if partition_two_label and string.find(partition_two_label, "LEDE") then partition_two_os = "LEDE" end
+ if partition_two_label and string.find(partition_two_label, "OpenWrt") then partition_two_os = "OpenWrt" end
+ if partition_two_label and string.find(partition_two_label, "Linksys") then partition_two_os = "Linksys" end
if device_name and device_name == "ZyXEL NBG6817" then
if not partition_one_os then partition_one_os = "ZyXEL" end
if not partition_two_os then partition_two_os = "ZyXEL" end
end
+ if device_name and device_name == "Linksys WRT32X" then
+ if not partition_one_os then partition_one_os = "Unknown/Compressed" end
+ if not partition_two_os then partition_two_os = "Unknown/Compressed" end
+ end
if not partition_one_os then partition_one_os = "Unknown" end
if not partition_two_os then partition_two_os = "Unknown" end
if partition_one_os and partition_one_version then partition_one_os = partition_one_os .. " (Linux " .. partition_one_version .. ")" end
@@ -75,7 +80,6 @@ end
function index()
entry({"admin", "system", "advanced_reboot"}, template("advanced_reboot/advanced_reboot"), _("Advanced Reboot"), 90)
entry({"admin", "system", "advanced_reboot", "reboot"}, post("action_reboot"))
--- if device_name then entry({"admin", "system", "advanced_reboot", "altreboot"}, post("action_altreboot")) end
entry({"admin", "system", "advanced_reboot", "alternative_reboot"}, post("action_altreboot"))
entry({"admin", "system", "advanced_reboot", "power_off"}, post("action_poweroff"))
end
@@ -93,18 +97,10 @@ end
function action_altreboot()
local uci = require "luci.model.uci".cursor()
local zyxelFlagPartition, zyxelBootFlag, zyxelNewBootFlag, errorCode, curEnvSetting, newEnvSetting
- errorMessage = ""
+ errorMessage = nil
errorCode = 0
if luci.http.formvalue("cancel") then
luci.http.redirect(luci.dispatcher.build_url('admin/system/advanced_reboot'))
--- luci.template.render("advanced_reboot/advanced_reboot",{
--- device_name=device_name,
--- boot_envvar1_partition_one=boot_envvar1_partition_one,
--- partition_one_os=partition_one_os,
--- boot_envvar1_partition_two=boot_envvar1_partition_two,
--- partition_two_os=partition_two_os,
--- current_partition=current_partition,
--- errorMessage = luci.i18n.translate("Alternative reboot cancelled.")})
return
end
local step = tonumber(luci.http.formvalue("step") or 1)
@@ -161,7 +157,7 @@ function action_altreboot()
end
end
end
- if errorMessage == "" then
+ if not errorMessage then
luci.template.render("admin_system/applyreboot", {
title = luci.i18n.translate("Rebooting..."),
msg = luci.i18n.translate("The system is rebooting to an alternative partition now.<br /> DO NOT POWER OFF THE DEVICE!<br /> Wait a few minutes before you try to reconnect. It might be necessary to renew the address of your computer to reach the device again, depending on your settings."),
@@ -170,6 +166,7 @@ function action_altreboot()
luci.sys.reboot()
else
luci.template.render("advanced_reboot/advanced_reboot",{
+ rom_board_name=rom_board_name,
device_name=device_name,
boot_envvar1_partition_one=boot_envvar1_partition_one,
partition_one_os=partition_one_os,
diff --git a/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/advanced_reboot.htm b/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/advanced_reboot.htm
index 5f7429dfd..fabb793e3 100644
--- a/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/advanced_reboot.htm
+++ b/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/advanced_reboot.htm
@@ -79,7 +79,11 @@
</div>
</fieldset>
<%- else -%>
- <p class="alert-message warning"><%:Warning: This system does not have two partitions!%></p>
+ <%- if rom_board_name then -%>
+ <p class="alert-message warning"><%:Warning: Device (%><%=rom_board_name%><%:) is unknown or isn't a dual-partition device!%></p>
+ <%- else -%>
+ <p class="alert-message warning"><%:Warning: Unable to obtain device information!%></p>
+ <%- end -%>
<%- end -%>
<hr />