NIU: More restructuring, Add: change password, hostname
authorSteven Barth <steven@midlink.org>
Thu, 12 Nov 2009 17:45:08 +0000 (17:45 +0000)
committerSteven Barth <steven@midlink.org>
Thu, 12 Nov 2009 17:45:08 +0000 (17:45 +0000)
modules/niu/luasrc/model/cbi/niu/network/lan1.lua
modules/niu/luasrc/model/cbi/niu/system/general.lua
modules/niu/luasrc/model/cbi/niu/system/general1.lua

index 19f8230..77b0fa7 100644 (file)
@@ -17,11 +17,11 @@ local nw = require "luci.model.network"
 
 local has_ipv6 = nw:has_ipv6()
 
 
 local has_ipv6 = nw:has_ipv6()
 
-m = Map("network", translate("m_n_lan"))
+m = Map("network", "Local Network")
 
 nw.init(m.uci)
 
 
 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"))
 s.addremove = false
 
 s:tab("general", translate("General Settings"))
@@ -80,9 +80,9 @@ for _, d in ipairs(nw:get_interfaces()) do
 end
 
 
 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
 s.anonymous = true
 s.addremove = false
 s.dynamic = false
@@ -91,7 +91,7 @@ s:tab("general", translate("General Settings"))
 
 s:depends("interface", "lan")
 
 
 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"))
 
 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"), "")
 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
 
 
 return m, m2
index df438e8..046691c 100644 (file)
@@ -7,11 +7,28 @@ d.allow_cancel = true
 d:add("general1", load("niu/system/general1"))
 
 function d.on_cancel()
 d:add("general1", load("niu/system/general1"))
 
 function d.on_cancel()
-       cursor:revert("system")
+       cursor:revert("luci")
 end
 
 function d.on_done()
 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
\ No newline at end of file
 end
 
 return d
\ No newline at end of file
index 5325838..8348188 100644 (file)
@@ -17,22 +17,16 @@ local i18n = require "luci.i18n"
 local util = require "luci.util"
 local config = require "luci.config"
 
 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"))
-
-
-
-m2 = Map("luci", translate("Web <abbr title=\"User Interface\">UI</abbr>"))
-
-
-c = m2:section(NamedSection, "main", "core")
+hn = c:option(Value, "_uniquename", translate("Unique Devicename"))
+function hn:cfgvalue(self)
+       return require "nixio.fs".readfile("/proc/sys/kernel/hostname")
+end
 
 
-l = c:option(ListValue, "lang", translate("Language"))
+l = c:option(ListValue, "lang", translate("System Language"))
 l:value("auto")
 
 local i18ndir = i18n.i18ndir .. "default."
 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
                l:value(k, v)
        end
 end
-return m, m2
+
+pw1 = c:option(Value, "_pw1", translate("Administrator Password"))
+pw1.password = true
+pw1.default = "**********"
+
+
+return m