From: Dirk Brenken Date: Fri, 17 Aug 2018 10:52:36 +0000 (+0200) Subject: luci-mod-admin-full: allow forced upgrade (revised) X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=refs%2Fpull%2F2075%2Fhead;p=oweals%2Fluci.git 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 --- 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 153615b58..b278b2187 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 diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm b/modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm index ee9c2f8fd..f3d2e8d7b 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm @@ -20,7 +20,7 @@
- +
@@ -35,7 +35,7 @@
- +
@@ -44,7 +44,7 @@ <% end %>
- +
@@ -69,22 +69,31 @@
<%:Upload a sysupgrade-compatible image here to replace the running firmware. Check "Keep settings" to retain the current configuration (requires a compatible firmware image).%>
- +
+ <% if image_invalid then %> +
+ +
+ +
+
+ <%:The uploaded image file does not contain a supported format. Make sure that you choose the generic image format for your platform. %> + <%:Select 'Force upgrade' to flash the image even if the image format check fails. Use only if you are sure that the firmware is correct and meant for your device! %> +
+
+ <% end %>
- +
- <% if image_invalid then %> -
<%:The uploaded image file does not contain a supported format. Make sure that you choose the generic image format for your platform. %>
- <% end %> <% else %>
<%:Sorry, there is no sysupgrade support present; a new firmware image must be flashed manually. Please refer to the wiki for device specific install instructions.%>
diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_system/upgrade.htm b/modules/luci-mod-admin-full/luasrc/view/admin_system/upgrade.htm index 7175248db..597ddfd6b 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_system/upgrade.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_system/upgrade.htm @@ -22,7 +22,7 @@

-
+
  • <%:Checksum%>
    <%:MD5%>: <%=checksum%>
    @@ -39,18 +39,24 @@ end %>
  • <% if keep then %> - <%:Configuration files will be kept.%> + <%:Configuration files will be kept%> <% else %> - <%:Note: Configuration files will be erased.%> + <%:Caution: Configuration files will be erased%> <% end %>
  • + <% if force then %> +
  • + <%:Caution: System upgrade will be forced%> +
  • + <% end %>
-
+
" /> + " />