NIU: More restructuring, Add: change password, hostname
This commit is contained in:
parent
e8255eab66
commit
7da7ada00b
3 changed files with 39 additions and 22 deletions
|
@ -17,11 +17,11 @@ local nw = require "luci.model.network"
|
|||
|
||||
local has_ipv6 = nw:has_ipv6()
|
||||
|
||||
m = Map("network", translate("m_n_lan"))
|
||||
m = Map("network", "Local Network")
|
||||
|
||||
nw.init(m.uci)
|
||||
|
||||
s = m:section(NamedSection, "lan", "interface")
|
||||
s = m:section(NamedSection, "lan", "interface", "Network Settings")
|
||||
s.addremove = false
|
||||
|
||||
s:tab("general", translate("General Settings"))
|
||||
|
@ -80,9 +80,9 @@ for _, d in ipairs(nw:get_interfaces()) do
|
|||
end
|
||||
|
||||
|
||||
m2 = Map("dhcp", "DHCP")
|
||||
m2 = Map("dhcp")
|
||||
|
||||
s = m2:section(TypedSection, "dhcp", "DHCP-Server")
|
||||
s = m2:section(TypedSection, "dhcp", "DHCP")
|
||||
s.anonymous = true
|
||||
s.addremove = false
|
||||
s.dynamic = false
|
||||
|
@ -91,7 +91,7 @@ s:tab("general", translate("General Settings"))
|
|||
|
||||
s:depends("interface", "lan")
|
||||
|
||||
enable = s:taboption("general", ListValue, "ignore", translate("enable"), "")
|
||||
enable = s:taboption("general", ListValue, "ignore", "Automatic address assignment for network devices", "")
|
||||
enable:value(0, translate("enable"))
|
||||
enable:value(1, translate("disable"))
|
||||
|
||||
|
@ -99,7 +99,7 @@ enable:value(1, translate("disable"))
|
|||
s:tab("expert", translate("Expert Settings"))
|
||||
start = s:taboption("expert", Value, "start", translate("First leased address"))
|
||||
limit = s:taboption("expert", Value, "limit", translate("Number of leased addresses"), "")
|
||||
time = s:taboption("expert", Value, "leasetime")
|
||||
time = s:taboption("expert", Value, "leasetime", "Lease Time")
|
||||
|
||||
|
||||
return m, m2
|
||||
|
|
|
@ -7,11 +7,28 @@ d.allow_cancel = true
|
|||
d:add("general1", load("niu/system/general1"))
|
||||
|
||||
function d.on_cancel()
|
||||
cursor:revert("system")
|
||||
cursor:revert("luci")
|
||||
end
|
||||
|
||||
function d.on_done()
|
||||
cursor:commit("system")
|
||||
local pw1 = cursor:get("luci", "main", "_pw1")
|
||||
if pw1 and pw1 ~= "**********" then
|
||||
cursor:delete("luci", "main", "_pw1")
|
||||
require "luci.sys".user.setpasswd("root", pw1)
|
||||
end
|
||||
|
||||
local hn = cursor:get("luci", "main", "_uniquename")
|
||||
if hn then
|
||||
cursor:foreach("system", "system", function(s)
|
||||
cursor:set("system", s[".name"], "hostname", hn)
|
||||
end)
|
||||
cursor:commit("system")
|
||||
|
||||
require "nixio.fs".writefile("/proc/sys/kernel/hostname", hn)
|
||||
cursor:delete("luci", "main", "_uniquename")
|
||||
end
|
||||
|
||||
cursor:commit("luci")
|
||||
end
|
||||
|
||||
return d
|
|
@ -17,22 +17,16 @@ local i18n = require "luci.i18n"
|
|||
local util = require "luci.util"
|
||||
local config = require "luci.config"
|
||||
|
||||
m = Map("system", translate("System"))
|
||||
m = Map("luci", "Device Settings")
|
||||
|
||||
s = m:section(TypedSection, "system", "")
|
||||
s.anonymous = true
|
||||
s.addremove = false
|
||||
c = m:section(NamedSection, "main", "core", translate("Local Settings"))
|
||||
|
||||
hn = s:option(Value, "hostname", translate("Hostname"))
|
||||
hn = c:option(Value, "_uniquename", translate("Unique Devicename"))
|
||||
function hn:cfgvalue(self)
|
||||
return require "nixio.fs".readfile("/proc/sys/kernel/hostname")
|
||||
end
|
||||
|
||||
|
||||
|
||||
m2 = Map("luci", translate("Web <abbr title=\"User Interface\">UI</abbr>"))
|
||||
|
||||
|
||||
c = m2:section(NamedSection, "main", "core")
|
||||
|
||||
l = c:option(ListValue, "lang", translate("Language"))
|
||||
l = c:option(ListValue, "lang", translate("System Language"))
|
||||
l:value("auto")
|
||||
|
||||
local i18ndir = i18n.i18ndir .. "default."
|
||||
|
@ -42,4 +36,10 @@ for k, v in util.kspairs(config.languages) do
|
|||
l:value(k, v)
|
||||
end
|
||||
end
|
||||
return m, m2
|
||||
|
||||
pw1 = c:option(Value, "_pw1", translate("Administrator Password"))
|
||||
pw1.password = true
|
||||
pw1.default = "**********"
|
||||
|
||||
|
||||
return m
|
||||
|
|
Loading…
Reference in a new issue