2008-06-08 08:14:31 +00:00
|
|
|
--[[
|
|
|
|
LuCI - Lua Configuration Interface
|
|
|
|
|
|
|
|
Copyright 2008 Steven Barth <steven@midlink.org>
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
]]--
|
2008-11-06 18:59:15 +00:00
|
|
|
|
2008-08-16 23:17:50 +00:00
|
|
|
require("luci.sys")
|
2008-11-06 18:59:15 +00:00
|
|
|
require("luci.sys.zoneinfo")
|
2008-08-16 23:17:50 +00:00
|
|
|
require("luci.tools.webadmin")
|
2010-03-25 13:42:54 +00:00
|
|
|
require("luci.fs")
|
2008-07-18 14:08:34 +00:00
|
|
|
|
2009-10-31 15:54:11 +00:00
|
|
|
m = Map("system", translate("System"), translate("Here you can configure the basic aspects of your device like its hostname or the timezone."))
|
2008-04-12 19:24:08 +00:00
|
|
|
|
2008-06-06 18:27:59 +00:00
|
|
|
s = m:section(TypedSection, "system", "")
|
2008-04-12 19:24:08 +00:00
|
|
|
s.anonymous = true
|
2009-08-27 17:53:52 +00:00
|
|
|
s.addremove = false
|
2008-04-12 19:24:08 +00:00
|
|
|
|
2008-08-16 23:17:50 +00:00
|
|
|
local system, model, memtotal, memcached, membuffers, memfree = luci.sys.sysinfo()
|
|
|
|
local uptime = luci.sys.uptime()
|
|
|
|
|
2009-10-31 15:54:11 +00:00
|
|
|
s:option(DummyValue, "_system", translate("System")).value = system
|
|
|
|
s:option(DummyValue, "_cpu", translate("Processor")).value = model
|
2008-08-16 23:17:50 +00:00
|
|
|
|
|
|
|
local load1, load5, load15 = luci.sys.loadavg()
|
2009-10-31 15:54:11 +00:00
|
|
|
s:option(DummyValue, "_la", translate("Load")).value =
|
2008-08-16 23:17:50 +00:00
|
|
|
string.format("%.2f, %.2f, %.2f", load1, load5, load15)
|
2009-02-01 17:08:40 +00:00
|
|
|
|
2009-10-31 15:54:11 +00:00
|
|
|
s:option(DummyValue, "_memtotal", translate("Memory")).value =
|
2008-08-16 23:17:50 +00:00
|
|
|
string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
|
|
|
|
tonumber(memtotal) / 1024,
|
|
|
|
100 * memcached / memtotal,
|
2009-11-01 01:37:03 +00:00
|
|
|
tostring(translate("cached")),
|
2008-08-16 23:17:50 +00:00
|
|
|
100 * membuffers / memtotal,
|
2009-11-01 01:37:03 +00:00
|
|
|
tostring(translate("buffered")),
|
2008-08-16 23:17:50 +00:00
|
|
|
100 * memfree / memtotal,
|
2009-11-01 01:37:03 +00:00
|
|
|
tostring(translate("free"))
|
2009-07-31 00:02:07 +00:00
|
|
|
)
|
2008-08-16 23:17:50 +00:00
|
|
|
|
2009-10-31 15:54:11 +00:00
|
|
|
s:option(DummyValue, "_systime", translate("Local Time")).value =
|
2008-08-16 23:17:50 +00:00
|
|
|
os.date("%c")
|
2009-02-01 17:08:40 +00:00
|
|
|
|
2009-10-31 15:54:11 +00:00
|
|
|
s:option(DummyValue, "_uptime", translate("Uptime")).value =
|
2008-08-16 23:17:50 +00:00
|
|
|
luci.tools.webadmin.date_format(tonumber(uptime))
|
|
|
|
|
2009-10-31 15:54:11 +00:00
|
|
|
hn = s:option(Value, "hostname", translate("Hostname"))
|
2009-02-01 17:08:40 +00:00
|
|
|
|
|
|
|
function hn.write(self, section, value)
|
|
|
|
Value.write(self, section, value)
|
|
|
|
luci.sys.hostname(value)
|
|
|
|
end
|
|
|
|
|
2008-04-12 19:24:08 +00:00
|
|
|
|
2009-10-31 15:54:11 +00:00
|
|
|
tz = s:option(ListValue, "zonename", translate("Timezone"))
|
2008-11-06 18:59:15 +00:00
|
|
|
tz:value("UTC")
|
|
|
|
|
|
|
|
for i, zone in ipairs(luci.sys.zoneinfo.TZ) do
|
|
|
|
tz:value(zone[1])
|
|
|
|
end
|
|
|
|
|
|
|
|
function tz.write(self, section, value)
|
|
|
|
local function lookup_zone(title)
|
|
|
|
for _, zone in ipairs(luci.sys.zoneinfo.TZ) do
|
|
|
|
if zone[1] == title then return zone[2] end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
AbstractValue.write(self, section, value)
|
2010-03-25 13:42:54 +00:00
|
|
|
local timezone = lookup_zone(value) or "GMT0"
|
|
|
|
self.map.uci:set("system", section, "timezone", timezone)
|
|
|
|
luci.fs.writefile("/etc/TZ", timezone .. "\n")
|
2008-07-18 14:08:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
s:option(Value, "log_size", nil, "kiB").optional = true
|
|
|
|
s:option(Value, "log_ip").optional = true
|
|
|
|
s:option(Value, "conloglevel").optional = true
|
2009-04-29 13:19:23 +00:00
|
|
|
s:option(Value, "cronloglevel").optional = true
|
2010-03-27 17:29:19 +00:00
|
|
|
|
|
|
|
s2 = m:section(TypedSection, "rdate", translate("Time Server (rdate)"))
|
|
|
|
s2.anonymous = true
|
|
|
|
s2.addremove = false
|
|
|
|
|
|
|
|
s2:option(DynamicList, "server", translate("Server"))
|
|
|
|
|
2008-07-20 17:07:54 +00:00
|
|
|
return m
|