<% local au = require 'valibox.autonta_util' local vu = require 'valibox.valibox_update' local mio = require 'valibox.mio' local current_version = vu.get_current_version() local currently_beta = false if current_version:find("beta") then currently_beta = true end local board_name = vu.get_board_name() local firmware_info = vu.get_firmware_board_info(currently_beta, "", true, board_name) local other_firmware_info = vu.get_firmware_board_info(not currently_beta, "", true, board_name) local update_check_failed = false local update_available = false local other_version = "" local update_version = vu.update_available(firmware_info) local update_info = "" if not firmware_info or not other_firmware_info then update_check_failed = true else if update_version and current_version ~= update_version then update_available = true update_info = vu.fetch_update_info_txt(firmware_info, "") else -- include changelog for current release local fr = mio.file_reader("/valibox_changelog.txt") if fr ~= nil then update_info = fr:read_lines_single_str() else update_info = "" end fr:close() end end -- CSRF protection; set a random string in the cookie and the form -- values must match for anything to be done after post local dst = au.randomstring(12) luci.http.header("Set-Cookie", "valibox_nta=" .. dst .."; SameSite=strict; Max-Age=3600") %> <%+header%>

<%:Check for updates%>

<%: SIDN Labs %> <%: Valibox %> <%: Update %>
<% if update_check_failed then %>

<%: Update check failed %>

<%: Current version %>: <%= current_version %>

Try again

<% else %> <% if update_available then %>

<%: Update available %>: <%= update_version %> <%: Current version %>: <%= current_version %>

<%: Keep settings %> <% if currently_beta then %>

<%: Update to latest beta %>

<%: Install latest release %> <%= other_version %>

<% else %>

<%: Update to latest release %>

<%: Install latest beta %> <%= other_version %>

<% end %>

                <%= update_info %>
            
<% else %>

<%: No updates available. Current version: %> <%= current_version %>

Try again

<%: Download and reinstall firmware %>

<%: Keep settings %> <% if currently_beta then %>

<%: Reinstall current version %>

<%: Install latest release %> <%= other_version %>

<% else %>

<%: Reinstall current version %>

<%: Install latest beta %> <%= other_version %>

<% end %>

                <%= update_info %>
            
<% end %> <% end %> <%+footer%>