diff options
Diffstat (limited to 'applications/luci-app-advanced-reboot')
9 files changed, 98 insertions, 87 deletions
diff --git a/applications/luci-app-advanced-reboot/Makefile b/applications/luci-app-advanced-reboot/Makefile index d270498308..08919640d7 100644 --- a/applications/luci-app-advanced-reboot/Makefile +++ b/applications/luci-app-advanced-reboot/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Stan Grishin (stangri@melmac.net) +# Copyright 2017-2018 Stan Grishin (stangri@melmac.net) # This is free software, licensed under the GNU General Public License v3. include $(TOPDIR)/rules.mk @@ -11,9 +11,9 @@ LUCI_DESCRIPTION:=Provides Web UI (found under System/Advanced Reboot) to reboot an altnerative 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 -LUCI_DEPENDS:=+luci +LUCI_DEPENDS:=+luci-mod-admin-full LUCI_PKGARCH:=all -PKG_RELEASE:=27 +PKG_RELEASE:=33 include ../../luci.mk diff --git a/applications/luci-app-advanced-reboot/README.md b/applications/luci-app-advanced-reboot/README.md index d4659c8dc7..4fa335fb3f 100644 --- a/applications/luci-app-advanced-reboot/README.md +++ b/applications/luci-app-advanced-reboot/README.md @@ -14,6 +14,7 @@ Currently supported dual-partition devices include: - Linksys WRT1900ACv2 - Linksys WRT1900ACS - Linksys WRT3200ACM +- Linksys WRT32X - 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). @@ -34,4 +35,4 @@ opkg install luci-app-advanced-reboot - 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 -I'd like to thank everyone who helped create, test and troubleshoot this package. Without contributions from [@hnyman](https://github.com/hnyman), [@jpstyves](https://github.com/jpstyves) and [@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) and many contributions from [@slh](https://github.com/pkgadd) it wouldn't have been possible. 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 b5dd4fe0f4..dd8071677e 100644 --- a/applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua +++ b/applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua @@ -1,27 +1,28 @@ --- Copyright 2017 Stan Grishin <stangri@melmac.net> +-- Copyright 2017-2018 Stan Grishin <stangri@melmac.net> -- Licensed to the public under the Apache License 2.0. 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 0629c84b36..5c14f52ff8 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 @@ -1,7 +1,7 @@ <%# Copyright 2008 Steven Barth <steven@midlink.org> Copyright 2008-2015 Jo-Philipp Wich <jow@openwrt.org> - Copyright 2017 Stan Grishin <stangri@melmac.net> + Copyright 2017-2018 Stan Grishin <stangri@melmac.net> Licensed to the public under the Apache License 2.0. -%> @@ -21,65 +21,69 @@ <%- if device_name then -%> <fieldset class="cbi-section"> <legend><%=device_name%><%: Partitions%></legend> - <table class="cbi-section-table" id="partitions"> - <tr class="cbi-section-table-titles"> - <th class="cbi-section-table-cell"><%:Partition%></th> - <th class="cbi-section-table-cell"><%:Status%></th> - <th class="cbi-section-table-cell"><%:Firmware/OS (Kernel)%></th> - <th class="cbi-section-table-cell"><%:Action%></th> - </tr> - <tr class="cbi-section-table-row"> - <td> + <div class="table cbi-section-table" id="partitions"> + <div class="tr cbi-section-table-titles"> + <div class="th cbi-section-table-cell"><%:Partition%></div> + <div class="th cbi-section-table-cell"><%:Status%></div> + <div class="th cbi-section-table-cell"><%:Firmware/OS (Kernel)%></div> + <div class="th cbi-section-table-cell"><%:Action%></div> + </div> + <div class="tr cbi-section-table-row"> + <div class="td"> <%=string.format("%X", boot_envvar1_partition_one)%> - </td> - <td> + </div> + <div class="td"> <%- if boot_envvar1_partition_one == current_partition then -%><%:Current%><%- else -%><%:Alternative%><%- end -%> - </td> - <td> + </div> + <div class="td"> <%=partition_one_os%> - </td> - <td> + </div> + <div class="td"> <%- if boot_envvar1_partition_one == current_partition then -%> <form method="post" action="<%=url('admin/system/advanced_reboot/reboot')%>"> <input type="hidden" name="token" value="<%=token%>" /> - <input id="reboot-button" type="submit" class="cbi-button cbi-button-apply" value="<%:Reboot to current partition%>" /> + <input id="reboot-button" type="submit" class="cbi-button cbi-button-apply important" value="<%:Reboot to current partition%>" /> </form> <%- else -%> <form method="post" action="<%=url('admin/system/advanced_reboot/alternative_reboot')%>"> <input type="hidden" name="token" value="<%=token%>" /> - <input id="altreboot-button" type="submit" class="cbi-button cbi-button-apply" value="<%:Reboot to alternative partition...%>" /> + <input id="altreboot-button" type="submit" class="cbi-button cbi-button-apply important" value="<%:Reboot to alternative partition...%>" /> </form> <%- end -%> - </td> - </tr> - <tr class="cbi-section-table-row"> - <td> + </div> + </div> + <div class="tr cbi-section-table-row"> + <div class="td"> <%=string.format("%X", boot_envvar1_partition_two)%> - </td> - <td> + </div> + <div class="td"> <%- if boot_envvar1_partition_two == current_partition then -%><%:Current%><%- else -%><%:Alternative%><%- end -%> - </td> - <td> + </div> + <div class="td"> <%=partition_two_os%> - </td> - <td> + </div> + <div class="td"> <%- if boot_envvar1_partition_two == current_partition then -%> <form method="post" action="<%=url('admin/system/advanced_reboot/reboot')%>"> <input type="hidden" name="token" value="<%=token%>" /> - <input id="reboot-button" type="submit" class="cbi-button cbi-button-apply" value="<%:Reboot to current partition%>" /> + <input id="reboot-button" type="submit" class="cbi-button cbi-button-apply important" value="<%:Reboot to current partition%>" /> </form> <%- else -%> <form method="post" action="<%=url('admin/system/advanced_reboot/alternative_reboot')%>"> <input type="hidden" name="token" value="<%=token%>" /> - <input id="altreboot-button" type="submit" class="cbi-button cbi-button-apply" value="<%:Reboot to alternative partition...%>" /> + <input id="altreboot-button" type="submit" class="cbi-button cbi-button-apply important" value="<%:Reboot to alternative partition...%>" /> </form> <%- end -%> - </td> - </tr> - </table> + </div> + </div> + </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"><%=pcdata(translatef("Warning: Device (%s) is unknown or isn't a dual-partition device!", rom_board_name))%></p> + <%- else -%> + <p class="alert-message warning"><%=pcdata(translatef("Warning: Unable to obtain device information!"))%></p> + <%- end -%> <%- end -%> <hr /> @@ -87,7 +91,7 @@ <%- if nixio.fs.access("/sbin/poweroff") then -%> <form method="post" action="<%=url('admin/system/advanced_reboot/power_off')%>"> <input type="hidden" name="token" value="<%=token%>" /> - <input id="poweroff-button" type="submit" class="cbi-button cbi-button-apply" value="<%:Perform power off...%>" /> + <input id="poweroff-button" type="submit" class="cbi-button cbi-button-apply important" value="<%:Perform power off...%>" /> </form> <%- else -%> <p class="alert-message warning"><%:Warning: This system does not support powering off!%></p> diff --git a/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/alternative_reboot.htm b/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/alternative_reboot.htm index 6325934094..b15f16b0d5 100644 --- a/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/alternative_reboot.htm +++ b/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/alternative_reboot.htm @@ -1,7 +1,7 @@ <%# Copyright 2008 Steven Barth <steven@midlink.org> Copyright 2008-2009 Jo-Philipp Wich <jow@openwrt.org> - Copyright 2017 Stan Grishin <stangri@melmac.net> + Copyright 2017-2018 Stan Grishin <stangri@melmac.net> Licensed to the public under the Apache License 2.0. -%> @@ -21,8 +21,8 @@ <form class="inline" action="<%=REQUEST_URI%>" method="post"> <input type="hidden" name="token" value="<%=token%>" /> <input type="hidden" name="step" value="2" /> - <input class="cbi-button cbi-button-reset" name="cancel" type="submit" value="<%:Cancel%>" /> - <input class="cbi-button cbi-button-apply" type="submit" value="<%:Proceed%>" /> + <input class="cbi-button cbi-button-reset important" name="cancel" type="submit" value="<%:Cancel%>" /> + <input class="cbi-button cbi-button-apply important" type="submit" value="<%:Proceed%>" /> </form> </div> diff --git a/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/power_off.htm b/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/power_off.htm index 0ddea11e65..1acf01b995 100644 --- a/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/power_off.htm +++ b/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/power_off.htm @@ -1,7 +1,7 @@ <%# Copyright 2008 Steven Barth <steven@midlink.org> Copyright 2008-2009 Jo-Philipp Wich <jow@openwrt.org> - Copyright 2017 Stan Grishin <stangri@melmac.net> + Copyright 2017-2018 Stan Grishin <stangri@melmac.net> Licensed to the public under the Apache License 2.0. -%> @@ -17,8 +17,8 @@ <form class="inline" action="<%=REQUEST_URI%>" method="post"> <input type="hidden" name="token" value="<%=token%>" /> <input type="hidden" name="step" value="2" /> - <input class="cbi-button cbi-button-reset" name="cancel" type="submit" value="<%:Cancel%>" /> - <input class="cbi-button cbi-button-apply" type="submit" value="<%:Proceed%>" /> + <input class="cbi-button cbi-button-reset important" name="cancel" type="submit" value="<%:Cancel%>" /> + <input class="cbi-button cbi-button-apply important" type="submit" value="<%:Proceed%>" /> </form> </div> diff --git a/applications/luci-app-advanced-reboot/po/ru/advanced-reboot.po b/applications/luci-app-advanced-reboot/po/ru/advanced-reboot.po index 75d463677b..8ad352055f 100644 --- a/applications/luci-app-advanced-reboot/po/ru/advanced-reboot.po +++ b/applications/luci-app-advanced-reboot/po/ru/advanced-reboot.po @@ -22,9 +22,6 @@ msgstr "Дополнительная перезагрузка" msgid "Alternative" msgstr "Альтернатива" -msgid "Alternative reboot cancelled." -msgstr "Альтернативная перезагрузка отменена." - msgid "Cancel" msgstr "Отменить" @@ -148,16 +145,25 @@ msgstr "" "которое не поддерживает выключение питания.<br /><br /> Нажмите \"Продолжить" "\" ниже, чтобы выключить устройство." +msgid "Warning: Device (%s) is unknown or isn't a dual-partition device!" +msgstr "" + msgid "Warning: There are unsaved changes that will get lost on reboot!" msgstr "" "Внимание: Есть несохраненные изменения, которые будут потеряны при " "перезагрузке!" -msgid "Warning: This system does not have two partitions!" -msgstr "Внимание: Эта система не имеет двух разделов!" - msgid "Warning: This system does not support powering off!" msgstr "Внимание: Эта система не поддерживает отключение питания!" +msgid "Warning: Unable to obtain device information!" +msgstr "" + msgid "to" msgstr "" + +#~ msgid "Alternative reboot cancelled." +#~ msgstr "Альтернативная перезагрузка отменена." + +#~ msgid "Warning: This system does not have two partitions!" +#~ msgstr "Внимание: Эта система не имеет двух разделов!" diff --git a/applications/luci-app-advanced-reboot/po/sv/advanced-reboot.po b/applications/luci-app-advanced-reboot/po/sv/advanced-reboot.po index e0e13cfda9..46008b1322 100644 --- a/applications/luci-app-advanced-reboot/po/sv/advanced-reboot.po +++ b/applications/luci-app-advanced-reboot/po/sv/advanced-reboot.po @@ -10,9 +10,6 @@ msgstr "Avancerad omstart" msgid "Alternative" msgstr "Alternativ" -msgid "Alternative reboot cancelled." -msgstr "" - msgid "Cancel" msgstr "Avbryt" @@ -119,15 +116,21 @@ msgstr "" "stöd för avstängning.<br /><br /> Klicka på \"Fortsätt\" nedanför för att " "stänga av din enhet." +msgid "Warning: Device (%s) is unknown or isn't a dual-partition device!" +msgstr "" + msgid "Warning: There are unsaved changes that will get lost on reboot!" msgstr "" "Varning: Det finns osparade ändringar som kommer att förloras vid omstart!" -msgid "Warning: This system does not have two partitions!" -msgstr "Varning: Det här systemet har inte två partitioner!" - msgid "Warning: This system does not support powering off!" msgstr "Varning: Det här systemet har inte stöd för avstängning!" +msgid "Warning: Unable to obtain device information!" +msgstr "" + msgid "to" msgstr "" + +#~ msgid "Warning: This system does not have two partitions!" +#~ msgstr "Varning: Det här systemet har inte två partitioner!" diff --git a/applications/luci-app-advanced-reboot/po/templates/advanced-reboot.pot b/applications/luci-app-advanced-reboot/po/templates/advanced-reboot.pot index 47a81e1dd0..8324ea4e2e 100644 --- a/applications/luci-app-advanced-reboot/po/templates/advanced-reboot.pot +++ b/applications/luci-app-advanced-reboot/po/templates/advanced-reboot.pot @@ -10,9 +10,6 @@ msgstr "" msgid "Alternative" msgstr "" -msgid "Alternative reboot cancelled." -msgstr "" - msgid "Cancel" msgstr "" @@ -113,14 +110,17 @@ msgid "" "device." msgstr "" -msgid "Warning: There are unsaved changes that will get lost on reboot!" +msgid "Warning: Device (%s) is unknown or isn't a dual-partition device!" msgstr "" -msgid "Warning: This system does not have two partitions!" +msgid "Warning: There are unsaved changes that will get lost on reboot!" msgstr "" msgid "Warning: This system does not support powering off!" msgstr "" +msgid "Warning: Unable to obtain device information!" +msgstr "" + msgid "to" msgstr "" |