X-Git-Url: https://git.archive.openwrt.org/?a=blobdiff_plain;f=modules%2Fadmin-mini%2Fluasrc%2Fcontroller%2Fmini%2Fsystem.lua;h=c7bacb2489f144f2382caef4ef591368990c2ee2;hb=6088f2b3fe5384f8f0bae1a7842ff8ed98a0f1ee;hp=ad15b076b0639fd9e3fb5c933411c477610d2fbd;hpb=9136ac1fcf5696df0a680107ed260919eb6ff01a;p=project%2Fluci.git diff --git a/modules/admin-mini/luasrc/controller/mini/system.lua b/modules/admin-mini/luasrc/controller/mini/system.lua index ad15b076b..c7bacb248 100644 --- a/modules/admin-mini/luasrc/controller/mini/system.lua +++ b/modules/admin-mini/luasrc/controller/mini/system.lua @@ -106,6 +106,14 @@ function action_upgrade() break end end + elseif luci.fs.access("/proc/partitions") then + for l in io.lines("/proc/partitions") do + local x, y, b, n = l:match('^%s*(%d+)%s+(%d+)%s+([^%s]+)%s+([^%s]+)') + if b and n and not n:match('[0-9]') then + size = tonumber(b) * 1024 + break + end + end end return size end @@ -141,15 +149,24 @@ function action_upgrade() -- previous pages should arrange the stuff as required. if step == 4 then if has_platform and has_image and has_support then - -- Next line is to bypass luci.http layer - luci.http.context.eoh = true + -- Mimetype text/plain + luci.http.prepare_content("text/plain") -- Now invoke sysupgrade local keepcfg = keep_avail and luci.http.formvalue("keepcfg") == "1" - os.execute("/sbin/luci-flash %s %q" %{ + local fd = io.popen("/sbin/luci-flash %s %q" %{ keepcfg and "-k %q" % _keep_pattern() or "", tmpfile }) + if fd then + while true do + local ln = fd:read("*l") + if not ln then break end + luci.http.write(ln) + end + fd:close() + end + -- Make sure the device is rebooted luci.sys.reboot() end