Redesigned firmware upgrade process

This commit is contained in:
Steven Barth
2008-09-12 11:53:08 +00:00
parent e0cfb49235
commit fade8edd2d
10 changed files with 47 additions and 45 deletions

View File

@@ -79,7 +79,7 @@ end
function action_upgrade()
require("luci.model.uci")
local ret = nil
local ret, err
local plat = luci.fs.mtime("/lib/upgrade/platform.sh")
local tmpfile = "/tmp/firmware.img"
local broadcom = os.execute('grep brcm_ /lib/upgrade/platform.sh >/dev/null 2>&1') == 0
@@ -105,12 +105,11 @@ function action_upgrade()
local keepcfg = keep_avail and luci.http.formvalue("keepcfg")
if plat and fname then
ret = function()
return luci.sys.flash(tmpfile, keepcfg and _keep_pattern())
end
ret, err = luci.sys.flash(tmpfile, keepcfg and _keep_pattern())
end
luci.template.render("mini/upgrade", {sysupgrade=plat, ret=ret, keep_avail=keep_avail})
luci.template.render("admin_system/upgrade", {sysupgrade=plat,
ret=ret, err=err, keep_avail=keep_avail})
end
function _keep_pattern()

View File

@@ -17,7 +17,7 @@ $Id$
<h2><%:a_s_flash%></h2>
<p><%:a_s_flash_upgrade1%></p>
<br />
<% if sysupgrade and not ret then %>
<% if sysupgrade and ret == nil then %>
<form method="post" action="<%=REQUEST_URI%>" enctype="multipart/form-data">
<div class="left"><%:a_s_flash_fwimage%>:</div>
<div>
@@ -33,20 +33,14 @@ $Id$
<input type="submit" value="<%:a_s_flash_fwupgrade%>" />
</div>
</form>
<% elseif ret then %>
<p><%:a_s_flash_received%></p>
<p><%:a_s_flash_inprogress%></p>
<!-- <%=string.rep(" ", 2048)%> -->
<% %>
<% local ret = ret()
if ret == 0 then %>
<div class="ok"><%:a_s_flash_flashed%></div>
<% elseif ret ~= nil then %>
<% if ret then %>
<p><%:a_s_flash_received%></p>
<p><%:a_s_flash_inprogress%></p>
<% else %>
<div class="error"><%:a_s_flash_flasherr%>! (<%:code%> <%=ret%>)</div>
<div class="error"><%:a_s_flash_flasherr%>! (<%=err%>)</div>
<% end %>
<% else %>
<div class="error"><%:a_s_flash_notimplemented%></div>
<% end %>
<%+footer%>
<% if ret == 0 then luci.sys.reboot() end %>