diff options
Diffstat (limited to 'modules/luci-mod-admin-full')
11 files changed, 92 insertions, 41 deletions
diff --git a/modules/luci-mod-admin-full/luasrc/controller/admin/network.lua b/modules/luci-mod-admin-full/luasrc/controller/admin/network.lua index aa533cb70b..3b5f3eb8de 100644 --- a/modules/luci-mod-admin-full/luasrc/controller/admin/network.lua +++ b/modules/luci-mod-admin-full/luasrc/controller/admin/network.lua @@ -61,7 +61,7 @@ function index() page = entry({"admin", "network", "wireless_shutdown"}, post("wifi_shutdown"), nil) page.leaf = true - page = entry({"admin", "network", "wireless"}, arcombine(template("admin_network/wifi_overview"), cbi("admin_network/wifi")), _("Wifi"), 15) + page = entry({"admin", "network", "wireless"}, arcombine(template("admin_network/wifi_overview"), cbi("admin_network/wifi")), _("Wireless"), 15) page.leaf = true page.subindex = true 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 5b80f20783..cf8cfb5d2d 100644 --- a/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua +++ b/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua @@ -21,7 +21,7 @@ function index() entry({"admin", "system", "startup"}, form("admin_system/startup"), _("Startup"), 45) entry({"admin", "system", "crontab"}, form("admin_system/crontab"), _("Scheduled Tasks"), 46) - if fs.access("/sbin/block") then + if fs.access("/sbin/block") and fs.access("/etc/config/fstab") then entry({"admin", "system", "fstab"}, cbi("admin_system/fstab"), _("Mount Points"), 50) entry({"admin", "system", "fstab", "mount"}, cbi("admin_system/fstab/mount"), nil).leaf = true entry({"admin", "system", "fstab", "swap"}, cbi("admin_system/fstab/swap"), nil).leaf = true @@ -185,6 +185,10 @@ local function image_checksum(image) return (luci.sys.exec("md5sum %q" % image):match("^([^%s]+)")) end +local function image_sha256_checksum(image) + return (luci.sys.exec("sha256sum %q" % image):match("^([^%s]+)")) +end + local function supports_sysupgrade() return nixio.fs.access("/lib/upgrade/platform.sh") end @@ -268,6 +272,7 @@ function action_sysupgrade() if image_supported(image_tmp) 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")) diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/dhcp.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/dhcp.lua index aaf045ca2c..10636a491a 100644 --- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/dhcp.lua +++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/dhcp.lua @@ -251,7 +251,7 @@ o:depends("nonwildcard", true) o = s:taboption("general", DynamicList, "notinterface", translate("Exclude interfaces"), - translate("Prevent listening on thise interfaces.")) + translate("Prevent listening on these interfaces.")) o.optional = true o:depends("nonwildcard", true) 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 ce3c3ef325..902767c903 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 @@ -5,8 +5,13 @@ m = Map("network", translate("Switch"), translate("The network ports on this device can be combined to several <abbr title=\"Virtual Local Area Network\">VLAN</abbr>s in which computers can communicate directly with each other. <abbr title=\"Virtual Local Area Network\">VLAN</abbr>s are often used to separate different network segments. Often there is by default one Uplink port for a connection to the next greater network like the internet and other ports for a local network.")) local fs = require "nixio.fs" +local nw = require "luci.model.network" local switches = { } +nw.init(m.uci) + +local topologies = nw:get_switch_topologies() or {} + m.uci:foreach("network", "switch", function(x) local sid = x['.name'] @@ -19,12 +24,26 @@ m.uci:foreach("network", "switch", local min_vid = 0 local max_vid = 16 local num_vlans = 16 - local cpu_port = tonumber(fs.readfile("/proc/switch/eth0/cpuport") or 5) - local num_ports = cpu_port + 1 local switch_title local enable_vlan4k = false + local topo = topologies[switch_name] + + if not topo then + m.message = translatef("Switch %q has an unknown topology - the VLAN settings might not be accurate.", switch_name) + topo = { + ports = { + { num = 0, label = "Port 1" }, + { num = 1, label = "Port 2" }, + { num = 2, label = "Port 3" }, + { num = 3, label = "Port 4" }, + { num = 4, label = "Port 5" }, + { num = 5, label = "CPU (eth0)", tagged = false } + } + } + end + -- Parse some common switch properties from swconfig help output. local swc = io.popen("swconfig dev %q help 2>/dev/null" % switch_name) if swc then @@ -45,12 +64,7 @@ m.uci:foreach("network", "switch", elseif line:match("cpu @") then switch_title = line:match("^switch%d: %w+%((.-)%)") - num_ports, cpu_port, num_vlans = - line:match("ports: (%d+) %(cpu @ (%d+)%), vlans: (%d+)") - - num_ports = tonumber(num_ports) or 6 - num_vlans = tonumber(num_vlans) or 16 - cpu_port = tonumber(cpu_port) or 5 + num_vlans = tonumber(line:match("vlans: (%d+)")) or 16 min_vid = 1 elseif line:match(": pvid") or line:match(": tag") or line:match(": vid") then @@ -113,14 +127,10 @@ m.uci:foreach("network", "switch", mp:depends("enable_mirror_tx", "1") mp:depends("enable_mirror_rx", "1") - local pt - for pt = 0, num_ports - 1 do - local name - - name = (pt == cpu_port) and translate("CPU") or translatef("Port %d", pt) - - sp:value(pt, name) - mp:value(pt, name) + local _, pt + for _, pt in ipairs(topo.ports) do + sp:value(pt.num, pt.label) + mp:value(pt.num, pt.label) end end @@ -211,9 +221,9 @@ m.uci:foreach("network", "switch", if value == "u" then if not untagged[self.option] then untagged[self.option] = true - elseif min_vid > 0 or tonumber(self.option) ~= cpu_port then -- enable multiple untagged cpu ports due to weird broadcom default setup + else return nil, - translatef("Port %d is untagged in multiple VLANs!", tonumber(self.option) + 1) + translatef("%s is untagged in multiple VLANs!", self.title) end end return value @@ -276,20 +286,16 @@ m.uci:foreach("network", "switch", or m:get(section, "vlan") end - -- Build per-port off/untagged/tagged choice lists. - local pt - for pt = 0, num_ports - 1 do - local title - if pt == cpu_port then - title = translate("CPU") - else - title = translatef("Port %d", pt) - end - - local po = s:option(ListValue, tostring(pt), title) + local _, pt + for _, pt in ipairs(topo.ports) do + local po = s:option(ListValue, tostring(pt.num), pt.label, '<div id="portstatus-%s-%d"></div>' %{ switch_name, pt.num }) po:value("", translate("off")) - po:value("u", translate("untagged")) + + if not pt.tagged then + po:value("u", translate("untagged")) + end + po:value("t", translate("tagged")) po.cfgvalue = portvalue @@ -299,6 +305,7 @@ m.uci:foreach("network", "switch", port_opts[#port_opts+1] = po end + table.sort(port_opts, function(a, b) return a.option < b.option end) switches[#switches+1] = switch_name end ) diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/system.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/system.lua index 2874b5607e..c7fdfcddba 100644 --- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/system.lua +++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/system.lua @@ -80,6 +80,14 @@ o.optional = true o.placeholder = 514 o.datatype = "port" +o = s:taboption("logging", ListValue, "log_proto", translate("External system log server protocol")) +o:value("udp", "UDP") +o:value("tcp", "TCP") + +o = s:taboption("logging", Value, "log_file", translate("Write system log to file")) +o.optional = true +o.placeholder = "/tmp/system.log" + o = s:taboption("logging", ListValue, "conloglevel", translate("Log output level")) o:value(8, translate("Debug")) o:value(7, translate("Info")) diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_network/diagnostics.htm b/modules/luci-mod-admin-full/luasrc/view/admin_network/diagnostics.htm index 685082a335..f4adb26069 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_network/diagnostics.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_network/diagnostics.htm @@ -9,6 +9,10 @@ local fs = require "nixio.fs" local has_ping6 = fs.access("/bin/ping6") or fs.access("/usr/bin/ping6") local has_traceroute6 = fs.access("/usr/bin/traceroute6") + +local dns_host = luci.config.diag and luci.config.diag.dns or "dev.openwrt.org" +local ping_host = luci.config.diag and luci.config.diag.ping or "dev.openwrt.org" +local route_host = luci.config.diag and luci.config.diag.route or "dev.openwrt.org" %> <script type="text/javascript" src="<%=resource%>/cbi.js"></script> @@ -63,7 +67,7 @@ local has_traceroute6 = fs.access("/usr/bin/traceroute6") <br /> <div style="width:30%; float:left"> - <input style="margin: 5px 0" type="text" value="dev.openwrt.org" name="ping" /><br /> + <input style="margin: 5px 0" type="text" value="<%=ping_host%>" name="ping" /><br /> <% if has_ping6 then %> <select name="ping_proto" style="width:auto"> <option value="" selected="selected"><%:IPv4%></option> @@ -76,7 +80,7 @@ local has_traceroute6 = fs.access("/usr/bin/traceroute6") </div> <div style="width:33%; float:left"> - <input style="margin: 5px 0" type="text" value="dev.openwrt.org" name="traceroute" /><br /> + <input style="margin: 5px 0" type="text" value="<%=route_host%>" name="traceroute" /><br /> <% if has_traceroute6 then %> <select name="traceroute_proto" style="width:auto"> <option value="" selected="selected"><%:IPv4%></option> @@ -93,7 +97,7 @@ local has_traceroute6 = fs.access("/usr/bin/traceroute6") </div> <div style="width:33%; float:left;"> - <input style="margin: 5px 0" type="text" value="dev.openwrt.org" name="nslookup" /><br /> + <input style="margin: 5px 0" type="text" value="<%=dns_host%>" name="nslookup" /><br /> <input type="button" value="<%:Nslookup%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.nslookup)" /> </div> diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_network/switch_status.htm b/modules/luci-mod-admin-full/luasrc/view/admin_network/switch_status.htm index 53c35ae59c..96fbffdb02 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_network/switch_status.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_network/switch_status.htm @@ -15,7 +15,10 @@ for (var j = 0; j < ports.length; j++) { - var th = th0.parentNode.parentNode.childNodes[j+1]; + var th = document.getElementById('portstatus-' + switches[i] + '-' + j); + + if (!th) + continue; if (ports[j].link) { diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview.htm b/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview.htm index 1df6b28846..9c351d3933 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview.htm @@ -427,7 +427,7 @@ <td class="cbi-value-field" style="width:310px;text-align:right"> <input id="<%=net:id()%>-iw-toggle" type="button" class="cbi-button cbi-button-reload" style="width:100px" onclick="wifi_shutdown('<%=net:id()%>', this)" title="<%:Delete this network%>" value="<%:Enable%>" /> <input type="button" class="cbi-button cbi-button-edit" style="width:100px" onclick="location.href='<%=net:adminlink()%>'" title="<%:Edit this network%>" value="<%:Edit%>" /> - <input type="button" class="cbi-button cbi-button-remove" style="width:100px" onclick="wifi_delete('<%=net:ifname()%>')" title="<%:Delete this network%>" value="<%:Remove%>" /> + <input type="button" class="cbi-button cbi-button-remove" style="width:100px" onclick="wifi_delete('<%=net:id()%>')" title="<%:Delete this network%>" value="<%:Remove%>" /> </td> </tr> <% end %> 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 8c3e01e603..eb46488062 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 @@ -471,7 +471,7 @@ '<strong><%:Bitrate%>:</strong> %s <%:Mbit/s%><br />', icon, net.signal, net.noise, net.quality, - net.link, net.ssid, + net.link, net.ssid || '?', net.mode, net.channel, net.frequency, net.bitrate || '?' @@ -482,7 +482,7 @@ s += String.format( '<strong><%:BSSID%>:</strong> %s<br />' + '<strong><%:Encryption%>:</strong> %s', - net.bssid, + net.bssid || '?', net.encryption ); } 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 5ca0398e13..7175248dbb 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 @@ -24,7 +24,9 @@ <fieldset class="cbi-section"> <ul> - <li><%:Checksum%>: <code><%=checksum%></code></li> + <li><%:Checksum%><br /> + <%:MD5%>: <code><%=checksum%></code><br /> + <%:SHA256%>: <code><%=sha256ch%></code></li> <li><%:Size%>: <% local w = require "luci.tools.webadmin" write(w.byte_format(size)) diff --git a/modules/luci-mod-admin-full/root/etc/uci-defaults/50_luci-mod-admin-full b/modules/luci-mod-admin-full/root/etc/uci-defaults/50_luci-mod-admin-full new file mode 100755 index 0000000000..372eb15122 --- /dev/null +++ b/modules/luci-mod-admin-full/root/etc/uci-defaults/50_luci-mod-admin-full @@ -0,0 +1,22 @@ +#!/bin/sh + +if [ "$(uci -q get luci.diag)" != "internal" ]; then + host="" + + if [ -s /etc/os-release ]; then + . /etc/os-release + host="${HOME_URL:-${BUG_URL:-$LEDE_DEVICE_MANUFACTURER_URL}}" + host="${host#*://}" + host="${host%%/*}" + fi + + uci -q batch <<-EOF >/dev/null + set luci.diag=internal + set luci.diag.dns='${host:-openwrt.org}' + set luci.diag.ping='${host:-openwrt.org}' + set luci.diag.route='${host:-openwrt.org}' + commit luci + EOF +fi + +exit 0 |