summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-admin-full/luasrc
diff options
context:
space:
mode:
Diffstat (limited to 'modules/luci-mod-admin-full/luasrc')
-rw-r--r--modules/luci-mod-admin-full/luasrc/controller/admin/index.lua14
-rw-r--r--modules/luci-mod-admin-full/luasrc/controller/admin/system.lua2
-rw-r--r--modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/ifaces.lua3
-rw-r--r--modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua1
-rw-r--r--modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/fstab.lua92
-rw-r--r--modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/fstab/mount.lua112
-rw-r--r--modules/luci-mod-admin-full/luasrc/view/admin_network/diagnostics.htm6
7 files changed, 172 insertions, 58 deletions
diff --git a/modules/luci-mod-admin-full/luasrc/controller/admin/index.lua b/modules/luci-mod-admin-full/luasrc/controller/admin/index.lua
index 74a3fd9adc..d00d546b64 100644
--- a/modules/luci-mod-admin-full/luasrc/controller/admin/index.lua
+++ b/modules/luci-mod-admin-full/luasrc/controller/admin/index.lua
@@ -28,13 +28,17 @@ end
function action_logout()
local dsp = require "luci.dispatcher"
local utl = require "luci.util"
- if dsp.context.authsession then
- utl.ubus("session", "destroy", {
- ubus_rpc_session = dsp.context.authsession
- })
+ local sid = dsp.context.authsession
+
+ if sid then
+ utl.ubus("session", "destroy", { ubus_rpc_session = sid })
+
dsp.context.urltoken.stok = nil
+
+ luci.http.header("Set-Cookie", "sysauth=%s; expires=%s; path=%s/" %{
+ sid, 'Thu, 01 Jan 1970 01:00:00 GMT', dsp.build_url()
+ })
end
- luci.http.header("Set-Cookie", "sysauth=; path=" .. dsp.build_url())
luci.http.redirect(luci.dispatcher.build_url())
end
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 52e347d07b..1b38c6783c 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("/etc/config/fstab") then
+ if fs.access("/sbin/block") 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
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 eabb257680..e092be6c38 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
@@ -14,6 +14,7 @@ local has_dnsmasq = fs.access("/etc/config/dhcp")
local has_firewall = fs.access("/etc/config/firewall")
m = Map("network", translate("Interfaces") .. " - " .. arg[1]:upper(), translate("On this page you can configure the network interfaces. You can bridge several interfaces by ticking the \"bridge interfaces\" field and enter the names of several network interfaces separated by spaces. You can also use <abbr title=\"Virtual Local Area Network\">VLAN</abbr> notation <samp>INTERFACE.VLANNR</samp> (<abbr title=\"for example\">e.g.</abbr>: <samp>eth0.1</samp>)."))
+m.redirect = luci.dispatcher.build_url("admin", "network", "network")
m:chain("wireless")
if has_firewall then
@@ -134,7 +135,7 @@ end
-- dhcp setup was requested, create section and reload page
if m:formvalue("cbid.dhcp._enable._enable") then
- m.uci:section("dhcp", "dhcp", nil, {
+ m.uci:section("dhcp", "dhcp", arg[1], {
interface = arg[1],
start = "100",
limit = "150",
diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua
index fff8b2f30a..dd619b3143 100644
--- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua
+++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua
@@ -17,6 +17,7 @@ m = Map("wireless", "",
m:chain("network")
m:chain("firewall")
+m.redirect = luci.dispatcher.build_url("admin/network/wireless")
local ifsection
diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/fstab.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/fstab.lua
index 06e1e07980..d4e834daff 100644
--- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/fstab.lua
+++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/fstab.lua
@@ -5,18 +5,33 @@ require("luci.tools.webadmin")
local fs = require "nixio.fs"
local util = require "nixio.util"
+local tp = require "luci.template.parser"
-local devices = {}
-util.consume((fs.glob("/dev/sd*")), devices)
-util.consume((fs.glob("/dev/hd*")), devices)
-util.consume((fs.glob("/dev/scd*")), devices)
-util.consume((fs.glob("/dev/mmc*")), devices)
+local block = io.popen("block info", "r")
+local ln, dev, devices = nil, nil, {}
-local size = {}
-for i, dev in ipairs(devices) do
- local s = tonumber((fs.readfile("/sys/class/block/%s/size" % dev:sub(6))))
- size[dev] = s and math.floor(s / 2048)
-end
+repeat
+ ln = block:read("*l")
+ dev = ln and ln:match("^/dev/(.-):")
+
+ if dev then
+ local e, s, key, val = { }
+
+ for key, val in ln:gmatch([[(%w+)="(.-)"]]) do
+ e[key:lower()] = val
+ devices[val] = e
+ end
+
+ s = tonumber((fs.readfile("/sys/class/block/%s/size" % dev)))
+
+ e.dev = "/dev/%s" % dev
+ e.size = s and math.floor(s / 2048)
+
+ devices[e.dev] = e
+ end
+until not ln
+
+block:close()
m = Map("fstab", translate("Mount Points"))
@@ -66,17 +81,39 @@ end
mount:option(Flag, "enabled", translate("Enabled")).rmempty = false
dev = mount:option(DummyValue, "device", translate("Device"))
+dev.rawhtml = true
dev.cfgvalue = function(self, section)
- local v
+ local v, e
v = m.uci:get("fstab", section, "uuid")
- if v then return "UUID: %s" % v end
+ e = v and devices[v:lower()]
+ if v and e and e.size then
+ return "UUID: %s (%s, %d MB)" %{ tp.pcdata(v), e.dev, e.size }
+ elseif v and e then
+ return "UUID: %s (%s)" %{ tp.pcdata(v), e.dev }
+ elseif v then
+ return "UUID: %s (<em>%s</em>)" %{ tp.pcdata(v), translate("not present") }
+ end
v = m.uci:get("fstab", section, "label")
- if v then return "Label: %s" % v end
+ e = v and devices[v]
+ if v and e and e.size then
+ return "Label: %s (%s, %d MB)" %{ tp.pcdata(v), e.dev, e.size }
+ elseif v and e then
+ return "Label: %s (%s)" %{ tp.pcdata(v), e.dev }
+ elseif v then
+ return "Label: %s (<em>%s</em>)" %{ tp.pcdata(v), translate("not present") }
+ end
v = Value.cfgvalue(self, section) or "?"
- return size[v] and "%s (%s MB)" % {v, size[v]} or v
+ e = v and devices[v]
+ if v and e and e.size then
+ return "%s (%d MB)" %{ tp.pcdata(v), e.size }
+ elseif v and e then
+ return tp.pcdata(v)
+ elseif v then
+ return "%s (<em>%s</em>)" %{ tp.pcdata(v), translate("not present") }
+ end
end
mp = mount:option(DummyValue, "target", translate("Mount Point"))
@@ -90,7 +127,15 @@ end
fs = mount:option(DummyValue, "fstype", translate("Filesystem"))
fs.cfgvalue = function(self, section)
- return Value.cfgvalue(self, section) or "?"
+ local v, e
+
+ v = m.uci:get("fstab", section, "uuid")
+ v = v and v:lower() or m.uci:get("fstab", section, "label")
+ v = v or m.uci:get("fstab", section, "device")
+
+ e = v and devices[v]
+
+ return e and e.type or m.uci:get("fstab", section, "fstype") or "?"
end
op = mount:option(DummyValue, "options", translate("Options"))
@@ -100,8 +145,14 @@ end
rf = mount:option(DummyValue, "is_rootfs", translate("Root"))
rf.cfgvalue = function(self, section)
- return Value.cfgvalue(self, section) == "1"
- and translate("yes") or translate("no")
+ local target = m.uci:get("fstab", section, "target")
+ if target == "/" then
+ return translate("yes")
+ elseif target == "/overlay" then
+ return translate("overlay")
+ else
+ return translate("no")
+ end
end
ck = mount:option(DummyValue, "enabled_fsck", translate("Check"))
@@ -139,7 +190,12 @@ dev.cfgvalue = function(self, section)
if v then return "Label: %s" % v end
v = Value.cfgvalue(self, section) or "?"
- return size[v] and "%s (%s MB)" % {v, size[v]} or v
+ e = v and devices[v]
+ if v and e and e.size then
+ return "%s (%s MB)" % {v, e.size}
+ else
+ return v
+ end
end
return m
diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/fstab/mount.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/fstab/mount.lua
index 3944690071..2652e00f25 100644
--- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/fstab/mount.lua
+++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/fstab/mount.lua
@@ -4,20 +4,32 @@
local fs = require "nixio.fs"
local util = require "nixio.util"
-local has_extroot = fs.access("/sbin/block")
local has_fscheck = fs.access("/usr/sbin/e2fsck")
-local devices = {}
-util.consume((fs.glob("/dev/sd*")), devices)
-util.consume((fs.glob("/dev/hd*")), devices)
-util.consume((fs.glob("/dev/scd*")), devices)
-util.consume((fs.glob("/dev/mmc*")), devices)
+local block = io.popen("block info", "r")
+local ln, dev, devices = nil, nil, {}
-local size = {}
-for i, dev in ipairs(devices) do
- local s = tonumber((fs.readfile("/sys/class/block/%s/size" % dev:sub(6))))
- size[dev] = s and math.floor(s / 2048)
-end
+repeat
+ ln = block:read("*l")
+ dev = ln and ln:match("^/dev/(.-):")
+
+ if dev then
+ local e, s, key, val = { }
+
+ for key, val in ln:gmatch([[(%w+)="(.-)"]]) do
+ e[key:lower()] = val
+ end
+
+ s = tonumber((fs.readfile("/sys/class/block/%s/size" % dev)))
+
+ e.dev = "/dev/%s" % dev
+ e.size = s and math.floor(s / 2048)
+
+ devices[#devices+1] = e
+ end
+until not ln
+
+block:close()
m = Map("fstab", translate("Mount Points - Mount Entry"))
@@ -41,29 +53,79 @@ mount:tab("advanced", translate("Advanced Settings"))
mount:taboption("general", Flag, "enabled", translate("Enable this mount")).rmempty = false
-o = mount:taboption("general", Value, "device", translate("Device"),
- translate("The device file of the memory or partition (<abbr title=\"for example\">e.g.</abbr> <code>/dev/sda1</code>)"))
+o = mount:taboption("general", Value, "uuid", translate("UUID"),
+ translate("If specified, mount the device by its UUID instead of a fixed device node"))
for i, d in ipairs(devices) do
- o:value(d, size[d] and "%s (%s MB)" % {d, size[d]})
+ if d.uuid and d.size then
+ o:value(d.uuid, "%s (%s, %d MB)" %{ d.uuid, d.dev, d.size })
+ elseif d.uuid then
+ o:value(d.uuid, "%s (%s)" %{ d.uuid, d.dev })
+ end
end
-o = mount:taboption("advanced", Value, "uuid", translate("UUID"),
- translate("If specified, mount the device by its UUID instead of a fixed device node"))
+o:value("", translate("-- match by label --"))
+
-o = mount:taboption("advanced", Value, "label", translate("Label"),
+o = mount:taboption("general", Value, "label", translate("Label"),
translate("If specified, mount the device by the partition label instead of a fixed device node"))
+o:depends("uuid", "")
+
+for i, d in ipairs(devices) do
+ if d.label and d.size then
+ o:value(d.label, "%s (%s, %d MB)" %{ d.label, d.dev, d.size })
+ elseif d.label then
+ o:value(d.label, "%s (%s)" %{ d.label, d.dev })
+ end
+end
+
+o:value("", translate("-- match by device --"))
+
+
+o = mount:taboption("general", Value, "device", translate("Device"),
+ translate("The device file of the memory or partition (<abbr title=\"for example\">e.g.</abbr> <code>/dev/sda1</code>)"))
+
+o:depends({ uuid = "", label = "" })
+
+for i, d in ipairs(devices) do
+ if d.size then
+ o:value(d.dev, "%s (%d MB)" %{ d.dev, d.size })
+ else
+ o:value(d.dev)
+ end
+end
+
o = mount:taboption("general", Value, "target", translate("Mount point"),
translate("Specifies the directory the device is attached to"))
-o:depends("is_rootfs", "")
+o:value("/", translate("Use as root filesystem (/)"))
+o:value("/overlay", translate("Use as external overlay (/overlay)"))
+
+
+o = mount:taboption("general", DummyValue, "__notice", translate("Root preparation"))
+o:depends("target", "/")
+o.rawhtml = true
+o.default = [[
+<p>%s</p><pre>mkdir -p /tmp/introot
+mkdir -p /tmp/extroot
+mount --bind / /tmp/introot
+mount /dev/sda1 /tmp/extroot
+tar -C /tmp/intproot -cvf - . | tar -C /tmp/extroot -xf -
+umount /tmp/introot
+umount /tmp/extroot</pre>
+]] %{
+ translate("Make sure to clone the root filesystem using something like the commands below:"),
+
+}
-o = mount:taboption("general", Value, "fstype", translate("Filesystem"),
+o = mount:taboption("advanced", Value, "fstype", translate("Filesystem"),
translate("The filesystem that was used to format the memory (<abbr title=\"for example\">e.g.</abbr> <samp><abbr title=\"Third Extended Filesystem\">ext3</abbr></samp>)"))
+o:value("", "auto")
+
local fs
for fs in io.lines("/proc/filesystems") do
fs = fs:match("%S+")
@@ -79,18 +141,8 @@ o = mount:taboption("advanced", Value, "options", translate("Mount options"),
o.placeholder = "defaults"
-if has_extroot then
- o = mount:taboption("general", Flag, "is_rootfs", translate("Use as root filesystem"),
- translate("Configures this mount as overlay storage for block-extroot"))
-
- o:depends("fstype", "jffs")
- o:depends("fstype", "ext2")
- o:depends("fstype", "ext3")
- o:depends("fstype", "ext4")
-end
-
if has_fscheck then
- o = mount:taboption("general", Flag, "enabled_fsck", translate("Run filesystem check"),
+ o = mount:taboption("advanced", Flag, "enabled_fsck", translate("Run filesystem check"),
translate("Run a filesystem check before mounting the device"))
end
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 e0a04a7f8f..05c866128d 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
@@ -63,7 +63,7 @@ local has_traceroute6 = fs.access("/usr/bin/traceroute6")
<br />
<div style="width:30%; float:left">
- <input style="margin: 5px 0" type="text" value="openwrt.org" name="ping" /><br />
+ <input style="margin: 5px 0" type="text" value="dev.openwrt.org" name="ping" /><br />
<% if has_ping6 then %>
<select name="ping_proto" style="width:auto">
<option value="" selected="selected"><%:IPv4%></option>
@@ -76,7 +76,7 @@ local has_traceroute6 = fs.access("/usr/bin/traceroute6")
</div>
<div style="width:33%; float:left">
- <input style="margin: 5px 0" type="text" value="openwrt.org" name="traceroute" /><br />
+ <input style="margin: 5px 0" type="text" value="dev.openwrt.org" name="traceroute" /><br />
<% if has_traceroute6 then %>
<select name="traceroute_proto" style="width:auto">
<option value="" selected="selected"><%:IPv4%></option>
@@ -93,7 +93,7 @@ local has_traceroute6 = fs.access("/usr/bin/traceroute6")
</div>
<div style="width:33%; float:left;">
- <input style="margin: 5px 0" type="text" value="openwrt.org" name="nslookup" /><br />
+ <input style="margin: 5px 0" type="text" value="dev.openwrt.org" name="nslookup" /><br />
<input type="button" value="<%:Nslookup%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.nslookup)" />
</div>