summaryrefslogtreecommitdiffhomepage
path: root/modules/admin-full/luasrc
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-09-18 21:26:34 +0000
committerSteven Barth <steven@midlink.org>2008-09-18 21:26:34 +0000
commit8f5d0d6ff5a1cbb40eccce5eeb99d5249bab5159 (patch)
tree51d8e1650322090f60ba37ff4cf2baa19b5c5a0e /modules/admin-full/luasrc
parent5067e2d185bbd1fdf029a8da2a84895bbccfad02 (diff)
new sysupgrade fixes part 2
Diffstat (limited to 'modules/admin-full/luasrc')
-rw-r--r--modules/admin-full/luasrc/controller/admin/system.lua21
-rw-r--r--modules/admin-full/luasrc/view/admin_system/upgrade.htm11
2 files changed, 23 insertions, 9 deletions
diff --git a/modules/admin-full/luasrc/controller/admin/system.lua b/modules/admin-full/luasrc/controller/admin/system.lua
index 35eca2a4f8..b99ca441b5 100644
--- a/modules/admin-full/luasrc/controller/admin/system.lua
+++ b/modules/admin-full/luasrc/controller/admin/system.lua
@@ -187,6 +187,8 @@ function action_upgrade()
local ltn12 = require "luci.ltn12"
local uploads = {}
local flash = {}
+
+ writer.COPY[#writer.COPY + 1] = "/sbin/reboot"
local ret
local filepat = "/tmp/mtdblock.%s"
@@ -195,8 +197,7 @@ function action_upgrade()
local keep_avail = false
if blocks then
for k, block in pairs(blocks) do
- if block.write == mtdow.WRITE_COMBINED
- or block.write == mtdow.WRITE_EMULATED then
+ if block.write ~= mtdow.WRITE_IMAGE then
keep_avail = true
end
end
@@ -242,10 +243,18 @@ function action_upgrade()
end
for name, file in pairs(uploads) do
- flash[name] = function()
+ local e = {name=name, func=function()
local imgstream = ltn12.source.file(io.open(file))
+ local kf = blocks[name].write ~= mtdow.WRITE_IMAGE
+ and keepcfg and _kfile()
return pcall(writer.write_block, writer,
- name, imgstream, keepcfg and _kfile())
+ name, imgstream, kf)
+ end}
+
+ if blocks[name].system then
+ flash[#flash+1] = e
+ else
+ table.insert(flash, 1, e)
end
end
@@ -256,8 +265,8 @@ function action_upgrade()
if reboot.exec then
local pid = posix.fork()
if pid == 0 then
- os.execute("sleep 1")
- posix.execp("reboot")
+ posix.sleep(1)
+ posix.exec("/tmp/reboot")
end
end
end
diff --git a/modules/admin-full/luasrc/view/admin_system/upgrade.htm b/modules/admin-full/luasrc/view/admin_system/upgrade.htm
index 693022f323..8fe658a427 100644
--- a/modules/admin-full/luasrc/view/admin_system/upgrade.htm
+++ b/modules/admin-full/luasrc/view/admin_system/upgrade.htm
@@ -38,17 +38,22 @@ $Id$
<p><%:a_s_flash_received%></p>
<% reboot.exec = false
- for name, func in pairs(flash) do %>
+ for i, entry in ipairs(flash) do
+ local name, func = entry.name, entry.func %>
<%:a_s_flash_inprogress%> <%=name%>...
- <%=string.rep(" ", 2048)%>
+ <%=string.rep(" ", 32*1024)%>
<%
local stat, code = func()
reboot.exec = reboot.exec or stat
if stat and code then %>
- <%:a_s_flash_flashed%><br />
+ <%:ok%><br />
<% else %>
<%:a_s_flash_flasherr%>! (<%:code%> <%=code%>)<br />
<% end %>
+ <% if reboot.exec then %>
+ <br />
+ <div><%:a_s_flash_flashed%></div>
+ <% end %>
<% end %>
<% else %>
<div class="error"><%:a_s_flash_notimplemented%></div>