diff options
Diffstat (limited to 'modules/luci-mod-admin-full')
8 files changed, 161 insertions, 93 deletions
diff --git a/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua b/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua index 153615b58a..46d2e36c32 100644 --- a/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua +++ b/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua @@ -35,6 +35,7 @@ function index() entry({"admin", "system", "flashops"}, call("action_flashops"), _("Backup / Flash Firmware"), 70) entry({"admin", "system", "flashops", "reset"}, post("action_reset")) entry({"admin", "system", "flashops", "backup"}, post("action_backup")) + entry({"admin", "system", "flashops", "backupmtdblock"}, post("action_backupmtdblock")) entry({"admin", "system", "flashops", "backupfiles"}, form("admin_system/backupfiles")) -- call() instead of post() due to upload handling! @@ -269,15 +270,17 @@ function action_sysupgrade() -- -- Initiate firmware flash -- - local step = tonumber(http.formvalue("step") or 1) + local step = tonumber(http.formvalue("step")) or 1 if step == 1 then - if image_supported(image_tmp) then + local force = http.formvalue("force") + if image_supported(image_tmp) or force then luci.template.render("admin_system/upgrade", { checksum = image_checksum(image_tmp), sha256ch = image_sha256_checksum(image_tmp), storage = storage_size(), size = (fs.stat(image_tmp, "size") or 0), - keep = (not not http.formvalue("keep")) + keep = (not not http.formvalue("keep")), + force = (not not http.formvalue("force")) }) else fs.unlink(image_tmp) @@ -287,17 +290,19 @@ function action_sysupgrade() image_invalid = true }) end + -- -- Start sysupgrade flash -- elseif step == 2 then local keep = (http.formvalue("keep") == "1") and "" or "-n" + local force = (http.formvalue("force") == "1") and "-F" or "" luci.template.render("admin_system/applyreboot", { title = luci.i18n.translate("Flashing..."), msg = luci.i18n.translate("The system is flashing now.<br /> DO NOT POWER OFF THE DEVICE!<br /> Wait a few minutes before you try to reconnect. It might be necessary to renew the address of your computer to reach the device again, depending on your settings."), - addr = (#keep > 0) and "192.168.1.1" or nil + addr = (#keep > 0) and (#force > 0) and "192.168.1.1" or nil }) - fork_exec("sleep 1; killall dropbear uhttpd; sleep 1; /sbin/sysupgrade %s %q" %{ keep, image_tmp }) + fork_exec("sleep 1; killall dropbear uhttpd; sleep 1; /sbin/sysupgrade %s %s %q" %{ keep, force, image_tmp }) end end @@ -314,6 +319,23 @@ function action_backup() luci.ltn12.pump.all(reader, luci.http.write) end +function action_backupmtdblock() + local http = require "luci.http" + local mv = http.formvalue("mtdblockname") + local m, s, n = mv:match('^([^%s]+)/([^%s]+)/([^%s]+)') + + local reader = ltn12_popen("dd if=/dev/mtd%s conv=fsync,notrunc 2>/dev/null" % n) + + luci.http.header( + 'Content-Disposition', 'attachment; filename="backup-%s-%s-%s.bin"' %{ + luci.sys.hostname(), m, + os.date("%Y-%m-%d") + }) + + luci.http.prepare_content("application/octet-stream") + luci.ltn12.pump.all(reader, luci.http.write) +end + function action_restore() local fs = require "nixio.fs" local http = require "luci.http" diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/ifaces.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/ifaces.lua index 06bce01fc4..8be354b448 100644 --- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/ifaces.lua +++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/ifaces.lua @@ -53,7 +53,7 @@ local function get_ifstate(name, option) m.uci:foreach("luci", "ifstate", function (s) if s.interface == name then - val = m.uci:get("luci", s[".name"], option) + val = s[option] return false end end) diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/vlan.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/vlan.lua index 3e46628d3f..d79b3c4704 100644 --- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/vlan.lua +++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/vlan.lua @@ -17,7 +17,7 @@ local update_interfaces = function(old_ifname, new_ifname) local info = { } m.uci:foreach("network", "interface", function(section) - local old_ifnames = m.uci:get("network", section[".name"], "ifname") + local old_ifnames = section.ifname local new_ifnames = { } local cur_ifname local changed = false diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm b/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm index a56d904d9f..29a03f2554 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm @@ -237,10 +237,10 @@ '<%:Data Rate%>', '%s/s / %s/s'.format(info.dsl.data_rate_down_s, info.dsl.data_rate_up_s), '<%:Max. Attainable Data Rate (ATTNDR)%>', '%s/s / %s/s'.format(info.dsl.max_data_rate_down_s, info.dsl.max_data_rate_up_s), '<%:Latency%>', '%s / %s'.format(info.dsl.latency_num_down, info.dsl.latency_num_up), - '<%:Line Attenuation (LATN)%>', '%d dB / %d dB'.format(info.dsl.line_attenuation_down, info.dsl.line_attenuation_up), - '<%:Signal Attenuation (SATN)%>', '%d dB / %d dB'.format(info.dsl.signal_attenuation_down, info.dsl.signal_attenuation_up), - '<%:Noise Margin (SNR)%>', '%d dB / %d dB'.format(info.dsl.noise_margin_down, info.dsl.noise_margin_up), - '<%:Aggregate Transmit Power(ACTATP)%>', '%d dB / %d dB'.format(info.dsl.actatp_down, info.dsl.actatp_up), + '<%:Line Attenuation (LATN)%>', '%.1f dB / %.1f dB'.format(info.dsl.line_attenuation_down, info.dsl.line_attenuation_up), + '<%:Signal Attenuation (SATN)%>', '%.1f dB / %.1f dB'.format(info.dsl.signal_attenuation_down, info.dsl.signal_attenuation_up), + '<%:Noise Margin (SNR)%>', '%.1f dB / %.1f dB'.format(info.dsl.noise_margin_down, info.dsl.noise_margin_up), + '<%:Aggregate Transmit Power(ACTATP)%>', '%.1f dB / %.1f dB'.format(info.dsl.actatp_down, info.dsl.actatp_up), '<%:Forward Error Correction Seconds (FECS)%>', '%d / %d'.format(info.dsl.errors_fec_near, info.dsl.errors_fec_far), '<%:Errored seconds (ES)%>', '%d / %d'.format(info.dsl.errors_es_near, info.dsl.errors_es_far), '<%:Severely Errored Seconds (SES)%>', '%d / %d'.format(info.dsl.errors_ses_near, info.dsl.errors_ses_far), diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_system/applyreboot.htm b/modules/luci-mod-admin-full/luasrc/view/admin_system/applyreboot.htm index e722a48096..e235bd4679 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_system/applyreboot.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_system/applyreboot.htm @@ -6,36 +6,48 @@ <html> <head> - <title><%=luci.sys.hostname()%> - <% if title then %><%=title%><% else %><%:Rebooting...%><% end %></title> + <title><%=luci.sys.hostname()%> - <%= title or translate("Rebooting...") %></title> <link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/cascade.css" /> <script type="text/javascript" src="<%=resource%>/xhr.js"></script> <script type="text/javascript">//<![CDATA[ var interval = window.setInterval(function() { var img = new Image(); - + var target = ('https:' == document.location.protocol ? 'https://' : 'http://') + <%=addr and "'%s'" % addr or "window.location.host"%>; + img.onload = function() { window.clearInterval(interval); - location.href = ('https:' == document.location.protocol ? 'https://' : 'http://') + '<%=addr or luci.http.getenv("SERVER_NAME")%>/'; + window.location.replace(target); }; - - img.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + '<%=addr or luci.http.getenv("SERVER_NAME")%><%=resource%>/icons/loading.gif?' + Math.random(); + + img.src = target + '<%=resource%>/icons/loading.gif?' + Math.random(); + }, 5000); //]]></script> </head> <body> - <div id="maincontainer"> - <div id="maincontent"> - <h2 name="content"><%:System%> - <% if title then %><%=title%><% else %><%:Rebooting...%><% end %></h2> - <fieldset class="cbi-section"> - <p> - <% if msg then %><%=msg%><% else %><%:Changes applied.%><% end %> - </p> - <p> - <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> - <%:Waiting for changes to be applied...%> - </p> - </fieldset> + <header> + <div class="fill"> + <div class="container"> + <p class="brand"><%=luci.sys.hostname() or "?"%></p> + </div> + </div> + </header> +   + <div class="main"> + <div id="maincontainer"> + <div id="maincontent" class="container"> + <h2 name="content" id="applyreboot-container" ><%:System%> - <%= title or translate("Rebooting...") %></h2> + <div class="cbi-section" id="applyreboot-section"> + <div> + <%= msg or translate("Changes applied.") %> + </div> + <div> + <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> + <%:Waiting for changes to be applied...%> + </div> + </div> + </div> </div> </div> </body> -</html> +</html>
\ No newline at end of file diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm b/modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm index ee9c2f8fd3..8204d38e34 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm @@ -20,7 +20,7 @@ <form class="inline" method="post" action="<%=url('admin/system/flashops/backup')%>"> <input type="hidden" name="token" value="<%=token%>" /> <div class="cbi-value<% if not reset_avail then %> cbi-value-last<% end %>"> - <label class="cbi-value-title" for="image"><%:Download backup%>:</label> + <label class="cbi-value-title" for="image"><%:Download backup%></label> <div class="cbi-value-field"> <input class="cbi-button cbi-button-action important" type="submit" name="backup" value="<%:Generate archive%>" /> </div> @@ -35,7 +35,7 @@ <form class="inline" method="post" action="<%=url('admin/system/flashops/reset')%>"> <input type="hidden" name="token" value="<%=token%>" /> <div class="cbi-value cbi-value-last"> - <label class="cbi-value-title"><%:Reset to defaults%>:</label> + <label class="cbi-value-title"><%:Reset to defaults%></label> <div class="cbi-value-field"> <input onclick="return confirm('<%:Really reset all changes?%>')" class="cbi-button cbi-button-reset" type="submit" name="reset" value="<%:Perform reset%>" /> </div> @@ -44,7 +44,7 @@ <% end %> <form class="inline" method="post" action="<%=url('admin/system/flashops/restore')%>" enctype="multipart/form-data"> <div class="cbi-value cbi-value-last"> - <label class="cbi-value-title" for="archive"><%:Restore backup%>:</label> + <label class="cbi-value-title" for="archive"><%:Restore backup%></label> <div class="cbi-value-field"> <input type="hidden" name="token" value="<%=token%>" /> <input type="file" name="archive" id="archive" /> @@ -59,6 +59,40 @@ <div class="cbi-section-error"><%:The backup archive does not appear to be a valid gzip file.%></div> <% end %> </div> + + <% local mtds = require("luci.sys").mtds(); if #mtds > 0 then -%> + <h3><%:Save mtdblock contents%></h3> + <div class="cbi-section-descr"><%:Click "Save mtdblock" to download specified mtdblock file. (NOTE: THIS FEATURE IS FOR PROFESSIONALS! )%></div> + <div class="cbi-section-node"> + <form class="inline" method="post" action="<%=url('admin/system/flashops/backupmtdblock')%>"> + <input type="hidden" name="token" value="<%=token%>" /> + <div class="cbi-value"> + <label class="cbi-value-title" for="mtdblockname"><%:Choose mtdblock%></label> + <div class="cbi-value-field"> + <select class="cbi-input-select" data-update="change" name="mtdblockname" id="mtdblockname"> + <% for i, key in ipairs(mtds) do + if key and key.name ~= "rootfs_data" then -%> + <option<%= + attr("id", "mtdblockname-" .. key.name) .. + attr("value", key.name .. '/'.. key.size .. '/' .. i - 1) .. + attr("data-index", i) .. + ifattr(key.name == "linux" or key.name == "firmware", "selected", "selected") + %>><%=pcdata(key.name)%></option> + <% end + end -%> + </select> + </div> + </div> + <div class="cbi-value cbi-value-last<% if reset_avail then %> cbi-value-error<% end %>"> + <label class="cbi-value-title" for="image"><%:Download mtdblock%></label> + <div class="cbi-value-field"> + <input type="submit" class="cbi-button cbi-button-action important" value="<%:Save mtdblock%>" /> + </div> + </div> + </form> + </div> + <% end %> + </div> <div class="cbi-section"> @@ -69,22 +103,31 @@ <div class="cbi-section-descr"><%:Upload a sysupgrade-compatible image here to replace the running firmware. Check "Keep settings" to retain the current configuration (requires a compatible firmware image).%></div> <div class="cbi-section-node"> <div class="cbi-value"> - <label class="cbi-value-title" for="keep"><%:Keep settings%>:</label> + <label class="cbi-value-title" for="keep"><%:Keep settings%></label> <div class="cbi-value-field"> <input type="checkbox" name="keep" id="keep" checked="checked" /> </div> </div> + <% if image_invalid then %> + <div class="cbi-value"> + <label class="cbi-value-title" for="force"><%:Force upgrade%></label> + <div class="cbi-value-field"> + <input type="checkbox" name="force" id="force" /> + </div> + <div class="cbi-section-error"> + <%:The uploaded image file does not contain a supported format. Make sure that you choose the generic image format for your platform. %> + <%:Select 'Force upgrade' to flash the image even if the image format check fails. Use only if you are sure that the firmware is correct and meant for your device! %> + </div> + </div> + <% end %> <div class="cbi-value cbi-value-last<% if image_invalid then %> cbi-value-error<% end %>"> - <label class="cbi-value-title" for="image"><%:Image%>:</label> + <label class="cbi-value-title" for="image"><%:Image%></label> <div class="cbi-value-field"> <input type="file" name="image" id="image" /> <input type="submit" class="cbi-button cbi-button-action important" value="<%:Flash image...%>" /> </div> </div> </div> - <% if image_invalid then %> - <div class="cbi-section-error"><%:The uploaded image file does not contain a supported format. Make sure that you choose the generic image format for your platform. %></div> - <% end %> </form> <% else %> <div class="cbi-section-descr"><%:Sorry, there is no sysupgrade support present; a new firmware image must be flashed manually. Please refer to the wiki for device specific install instructions.%></div> diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_system/upgrade.htm b/modules/luci-mod-admin-full/luasrc/view/admin_system/upgrade.htm index 7175248dbb..597ddfd6bf 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_system/upgrade.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_system/upgrade.htm @@ -22,7 +22,7 @@ </p> -<fieldset class="cbi-section"> +<div class="cbi-section"> <ul> <li><%:Checksum%><br /> <%:MD5%>: <code><%=checksum%></code><br /> @@ -39,18 +39,24 @@ end %></li> <li><% if keep then %> - <%:Configuration files will be kept.%> + <%:Configuration files will be kept%> <% else %> - <%:Note: Configuration files will be erased.%> + <%:Caution: Configuration files will be erased%> <% end %></li> + <% if force then %> + <li> + <%:Caution: System upgrade will be forced%> + </li> + <% end %> </ul> -</fieldset> +</div> <div class="cbi-page-actions right"> <form class="inline" action="<%=REQUEST_URI%>" method="post"> <input type="hidden" name="token" value="<%=token%>" /> <input type="hidden" name="step" value="2" /> <input type="hidden" name="keep" value="<%=keep and "1" or ""%>" /> + <input type="hidden" name="force" value="<%=force and "1" or ""%>" /> <input class="cbi-button cbi-button-reset" name="cancel" type="submit" value="<%:Cancel%>" /> <input class="cbi-button cbi-button-apply" type="submit" value="<%:Proceed%>" /> </form> diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_uci/changelog.htm b/modules/luci-mod-admin-full/luasrc/view/admin_uci/changelog.htm index e05ccdece3..8a162c88b6 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_uci/changelog.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_uci/changelog.htm @@ -1,5 +1,5 @@ <%# - Copyright 2010 Jo-Philipp Wich <jow@openwrt.org> + Copyright 2010 Jo-Philipp Wich <jo@mein.io> Licensed to the public under the Apache License 2.0. -%> @@ -17,65 +17,50 @@ <div class="uci-change-list"><% local util = luci.util - local ret = { } + local tpl = { + ["add-3"] = "<ins>uci add %0 <strong>%3</strong> # =%2</ins>", + ["set-3"] = "<ins>uci set %0.<strong>%2</strong></ins>=%3", + ["set-4"] = "<var><ins>uci set %0.%2.%3=<strong>%4</strong></ins></var>", + ["remove-2"] = "<del>uci del %0.<strong>%2</strong></del>", + ["remove-3"] = "<var><del>uci del %0.%2.<strong>%3</strong></del></var>", + ["order-3"] = "<var>uci reorder %0.%2=<strong>%3</strong></var>", + ["list-add-4"] = "<var><ins>uci add_list %0.%2.%3=<strong>%4</strong></ins></var>", + ["list-del-4"] = "<var><del>uci del_list %0.%2.%3=<strong>%4</strong></del></var>", + ["rename-3"] = "<var>uci rename %0.%2=<strong>%3</strong></var>", + ["rename-4"] = "<var>uci rename %0.%2.%3=<strong>%4</strong></var>" + } - for r, tbl in pairs(changes) do - for s, os in pairs(tbl) do - -- section add - if os['.type'] and os['.type'] ~= "" then - ret[#ret+1] = "<ins>%s.%s=<strong>%s</strong>" %{ r, s, os['.type'] } - for o, v in util.kspairs(os) do - if o:sub(1,1) ~= "." then - if type(v) == "table" then - local i - for i = 1, #v do - ret[#ret+1] = "<br />%s.%s.%s+=<strong>%s</strong>" - %{ r, s, o, util.pcdata(v[i]) } - end - elseif v ~= "" then - ret[#ret+1] = "<br />%s.%s.%s=<strong>%s</strong>" - %{ r, s, o, util.pcdata(v) } - else - ret[#ret+1] = "<br /><del>%s.%s.<strong>%s</strong></del>" %{ r, s, o } - end - end - end - ret[#ret+1] = "</ins><br />" - - -- section delete - elseif os['.type'] and os['.type'] == "" then - ret[#ret+1] = "<del>%s.<strong>%s</strong></del><br />" %{ r, s } + local conf, deltas + for conf, deltas in util.kspairs(changes) do + write("<h3># /etc/config/%s</h3>" % conf) - -- modifications - else - ret[#ret+1] = "<var>%s.%s<br />" %{ r, s } - for o, v in util.kspairs(os) do - if o:sub(1,1) ~= "." then - if v and #v > 0 then - ret[#ret+1] = "<ins>" - if type(v) == "table" then - local i - for i = 1, #v do - ret[#ret+1] = "%s.%s.%s+=<strong>%s</strong><br />" - %{ r, s, o, util.pcdata(v[i]) } - end + local _, delta, added + for _, delta in pairs(deltas) do + local t = tpl["%s-%d" %{ delta[1], #delta }] - else - ret[#ret+1] = "%s.%s.%s=<strong>%s</strong><br />" - %{ r, s, o, util.pcdata(v) } - end - ret[#ret+1] = "</ins>" - else - ret[#ret+1] = "<del>%s.%s.<strong>%s</strong><br /></del>" %{ r, s, o } - end + write(t:gsub("%%(%d)", function(n) + if n == "0" then + return conf + elseif n == "2" then + if added and delta[2] == added[1] then + return "@%s[-1]" % added[2] + else + return delta[2] end + elseif n == "4" then + return util.shellquote(delta[4]) + else + return delta[tonumber(n)] end - ret[#ret+1] = "</var><br />" + end)) + + if delta[1] == "add" then + added = { delta[2], delta[3] } end end - end - write(table.concat(ret)) + write("<br />") + end %></div> </div> <%- end) %> |