<% local mio = require 'valibox.mio' local update_download_success = false local dst_cookie = luci.http.getcookie("valibox_nta") local keep_settings = luci.http.formvalue("keepsettings") == "on" local beta = luci.http.formvalue("version") == "beta" local dst_form = luci.http.formvalue("dst") local xsrf_passed = false if (dst_form == dst_cookie) then xsrf_passed = true local cmd = "/usr/lib/lua/valibox/update_system.lua" local args = {} table.insert(args, "-i") table.insert(args, "-w") if beta then table.insert(args, "-b") end if keep_settings then table.insert(args, "-k") end local result = mio.subprocess(cmd, args, 3) if result.rcode == nil or result.rcode == 0 then update_download_success = true luci.http.header("Location", "update_done") end end %> <%+header%> <% if xsrf_passed then %>

<%:Installing firmware%>

<% if update_download_success then %>

<%: Installing valibox firmware %>

<%: Do not turn off the ValiBox, and wait for 5 to 10 minutes until the update has been installed and the ValiBox has restarted. %>

<% else %>

<%: Error installing Valibox firmware. %>

<%: Click this link to go back and try again %>

<% end %>
<% else %> <%: XSRF cookie mismatch, aborting update %> <% end %> <%+footer%>