1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Licensed to the public under the Apache License 2.0.
5 require("luci.sys.zoneinfo")
6 require("luci.tools.webadmin")
10 m = Map("system", translate("System"), translate("Here you can configure the basic aspects of your device like its hostname or the timezone."))
12 s = m:section(TypedSection, "system", "")
17 local sysinfo = luci.util.ubus("system", "info") or { }
18 local boardinfo = luci.util.ubus("system", "board") or { }
20 local uptime = sysinfo.uptime or 0
21 local loads = sysinfo.load or { 0, 0, 0 }
22 local memory = sysinfo.memory or {
29 s:option(DummyValue, "_system", translate("Model")).value = boardinfo.model or "?"
30 s:option(DummyValue, "_cpu", translate("System")).value = boardinfo.system or "?"
32 s:option(DummyValue, "_la", translate("Load")).value =
33 string.format("%.2f, %.2f, %.2f", loads[1] / 65535.0, loads[2] / 65535.0, loads[3] / 65535.0)
35 s:option(DummyValue, "_memtotal", translate("Memory")).value =
36 string.format("%.2f MB (%.0f%% %s, %.0f%% %s)",
37 tonumber(memory.total) / 1024 / 1024,
38 100 * memory.buffered / memory.total,
39 tostring(translate("buffered")),
40 100 * memory.free / memory.total,
41 tostring(translate("free"))
44 s:option(DummyValue, "_systime", translate("Local Time")).value =
47 s:option(DummyValue, "_uptime", translate("Uptime")).value =
48 luci.tools.webadmin.date_format(tonumber(uptime))
50 hn = s:option(Value, "hostname", translate("Hostname"))
52 function hn.write(self, section, value)
53 Value.write(self, section, value)
54 luci.sys.hostname(value)
58 tz = s:option(ListValue, "zonename", translate("Timezone"))
61 for i, zone in ipairs(luci.sys.zoneinfo.TZ) do
65 function tz.write(self, section, value)
66 local function lookup_zone(title)
67 for _, zone in ipairs(luci.sys.zoneinfo.TZ) do
68 if zone[1] == title then return zone[2] end
72 AbstractValue.write(self, section, value)
73 self.map.uci:set("system", section, "timezone", lookup_zone(value) or "GMT0")