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")
20 m = Map("system", translate("System"), translate("Here you can configure the basic aspects of your device like its hostname or the timezone."))
23 local has_rdate = false
25 m.uci:foreach("system", "rdate",
33 s = m:section(TypedSection, "system", "")
37 local system, model, memtotal, memcached, membuffers, memfree = luci.sys.sysinfo()
38 local uptime = luci.sys.uptime()
40 s:option(DummyValue, "_system", translate("System")).value = system
41 s:option(DummyValue, "_cpu", translate("Processor")).value = model
43 local load1, load5, load15 = luci.sys.loadavg()
44 s:option(DummyValue, "_la", translate("Load")).value =
45 string.format("%.2f, %.2f, %.2f", load1, load5, load15)
47 s:option(DummyValue, "_memtotal", translate("Memory")).value =
48 string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
49 tonumber(memtotal) / 1024,
50 100 * memcached / memtotal,
51 tostring(translate("cached")),
52 100 * membuffers / memtotal,
53 tostring(translate("buffered")),
54 100 * memfree / memtotal,
55 tostring(translate("free"))
58 s:option(DummyValue, "_systime", translate("Local Time")).value =
61 s:option(DummyValue, "_uptime", translate("Uptime")).value =
62 luci.tools.webadmin.date_format(tonumber(uptime))
64 hn = s:option(Value, "hostname", translate("Hostname"))
66 function hn.write(self, section, value)
67 Value.write(self, section, value)
68 luci.sys.hostname(value)
72 tz = s:option(ListValue, "zonename", translate("Timezone"))
75 for i, zone in ipairs(luci.sys.zoneinfo.TZ) do
79 function tz.write(self, section, value)
80 local function lookup_zone(title)
81 for _, zone in ipairs(luci.sys.zoneinfo.TZ) do
82 if zone[1] == title then return zone[2] end
86 AbstractValue.write(self, section, value)
87 local timezone = lookup_zone(value) or "GMT0"
88 self.map.uci:set("system", section, "timezone", timezone)
89 luci.fs.writefile("/etc/TZ", timezone .. "\n")
92 s:option(Value, "log_size", translate("System log buffer size"), "kiB").optional = true
93 s:option(Value, "log_ip", translate("External system log server")).optional = true
94 s:option(Value, "log_port", translate("External system log server port")).optional = true
95 s:option(Value, "conloglevel", translate("Log output level")).optional = true
96 s:option(Value, "cronloglevel", translate("Cron Log Level")).optional = true
99 s2 = m:section(TypedSection, "rdate", translate("Time Server (rdate)"))
103 s2:option(DynamicList, "server", translate("Server"))