From 89486bd66f828e272a1456b0ccd6e18617ae5ff0 Mon Sep 17 00:00:00 2001 From: Dirk Brenken Date: Fri, 17 Aug 2018 12:52:36 +0200 Subject: luci-mod-admin-full: allow forced upgrade (revised) * allow 'forced' firmware upgrades, even if the image format check fails. Useful where flashing back to the OEM versions or switching between ar71xx and ath79 builds * option is only visible after first/failed image check * added warning info (see screenshots below) Signed-off-by: Dirk Brenken --- .../luci-mod-admin-full/luasrc/controller/admin/system.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'modules/luci-mod-admin-full/luasrc/controller') diff --git a/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua b/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua index 153615b58a..b278b21878 100644 --- a/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua +++ b/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua @@ -269,15 +269,17 @@ function action_sysupgrade() -- -- Initiate firmware flash -- - local step = tonumber(http.formvalue("step") or 1) + local step = tonumber(http.formvalue("step")) or 1 if step == 1 then - if image_supported(image_tmp) then + local force = http.formvalue("force") + if image_supported(image_tmp) or force then luci.template.render("admin_system/upgrade", { checksum = image_checksum(image_tmp), sha256ch = image_sha256_checksum(image_tmp), storage = storage_size(), size = (fs.stat(image_tmp, "size") or 0), - keep = (not not http.formvalue("keep")) + keep = (not not http.formvalue("keep")), + force = (not not http.formvalue("force")) }) else fs.unlink(image_tmp) @@ -287,17 +289,19 @@ function action_sysupgrade() image_invalid = true }) end + -- -- Start sysupgrade flash -- elseif step == 2 then local keep = (http.formvalue("keep") == "1") and "" or "-n" + local force = (http.formvalue("force") == "1") and "" or "-F" luci.template.render("admin_system/applyreboot", { title = luci.i18n.translate("Flashing..."), msg = luci.i18n.translate("The system is flashing now.
DO NOT POWER OFF THE DEVICE!
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."), - addr = (#keep > 0) and "192.168.1.1" or nil + addr = (#keep > 0) and (#force > 0) and "192.168.1.1" or nil }) - fork_exec("sleep 1; killall dropbear uhttpd; sleep 1; /sbin/sysupgrade %s %q" %{ keep, image_tmp }) + fork_exec("sleep 1; killall dropbear uhttpd; sleep 1; /sbin/sysupgrade %s %s %q" %{ keep, force, image_tmp }) end end -- cgit v1.2.3