2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
16 require("luci.sys.zoneinfo")
17 require("luci.tools.webadmin")
21 m = Map("system", translate("System"), translate("Here you can configure the basic aspects of your device like its hostname or the timezone."))
23 s = m:section(TypedSection, "system", "")
28 local sysinfo = luci.util.ubus("system", "info") or { }
29 local boardinfo = luci.util.ubus("system", "board") or { }
31 local uptime = sysinfo.uptime or 0
32 local loads = sysinfo.load or { 0, 0, 0 }
33 local memory = sysinfo.memory or {
40 s:option(DummyValue, "_system", translate("Model")).value = boardinfo.model or "?"
41 s:option(DummyValue, "_cpu", translate("System")).value = boardinfo.system or "?"
43 s:option(DummyValue, "_la", translate("Load")).value =
44 string.format("%.2f, %.2f, %.2f", loads[1] / 65535.0, loads[2] / 65535.0, loads[3] / 65535.0)
46 s:option(DummyValue, "_memtotal", translate("Memory")).value =
47 string.format("%.2f MB (%.0f%% %s, %.0f%% %s)",
48 tonumber(memory.total) / 1024 / 1024,
49 100 * memory.buffered / memory.total,
50 tostring(translate("buffered")),
51 100 * memory.free / memory.total,
52 tostring(translate("free"))
55 s:option(DummyValue, "_systime", translate("Local Time")).value =
58 s:option(DummyValue, "_uptime", translate("Uptime")).value =
59 luci.tools.webadmin.date_format(tonumber(uptime))
61 hn = s:option(Value, "hostname", translate("Hostname"))
63 function hn.write(self, section, value)
64 Value.write(self, section, value)
65 luci.sys.hostname(value)
69 tz = s:option(ListValue, "zonename", translate("Timezone"))
72 for i, zone in ipairs(luci.sys.zoneinfo.TZ) do
76 function tz.write(self, section, value)
77 local function lookup_zone(title)
78 for _, zone in ipairs(luci.sys.zoneinfo.TZ) do
79 if zone[1] == title then return zone[2] end
83 AbstractValue.write(self, section, value)
84 self.map.uci:set("system", section, "timezone", lookup_zone(value) or "GMT0")