modules/admin-full/system: Add option for log_port
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_system / system.lua
index 99ab64d..891e48e 100644 (file)
@@ -15,9 +15,26 @@ $Id$
 require("luci.sys")
 require("luci.sys.zoneinfo")
 require("luci.tools.webadmin")
+require("luci.fs")
 
 m = Map("system", translate("System"), translate("Here you can configure the basic aspects of your device like its hostname or the timezone."))
 
+function m.on_parse()
+       local has_rdate = false
+
+       m.uci:foreach("system", "rdate",
+               function()
+                       has_rdate = true
+                       return false
+               end)
+
+       if not has_rdate then
+               m.uci:section("system", "rdate", nil, { })
+               m.uci:save("system")
+       end
+end
+
+
 s = m:section(TypedSection, "system", "")
 s.anonymous = true
 s.addremove = false
@@ -36,11 +53,11 @@ s:option(DummyValue, "_memtotal", translate("Memory")).value =
  string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
   tonumber(memtotal) / 1024,
   100 * memcached / memtotal,
-  tostring(translate("mem_cached", "")),
+  tostring(translate("cached")),
   100 * membuffers / memtotal,
-  tostring(translate("mem_buffered", "")),
+  tostring(translate("buffered")),
   100 * memfree / memtotal,
-  tostring(translate("mem_free", ""))
+  tostring(translate("free"))
 )
 
 s:option(DummyValue, "_systime", translate("Local Time")).value =
@@ -72,11 +89,21 @@ function tz.write(self, section, value)
        end
 
        AbstractValue.write(self, section, value)
-       self.map.uci:set("system", section, "timezone", lookup_zone(value) or "GMT0")
+       local timezone = lookup_zone(value) or "GMT0"
+       self.map.uci:set("system", section, "timezone", timezone)
+       luci.fs.writefile("/etc/TZ", timezone .. "\n")
 end
 
-s:option(Value, "log_size", nil, "kiB").optional = true
-s:option(Value, "log_ip").optional = true
-s:option(Value, "conloglevel").optional = true
-s:option(Value, "cronloglevel").optional = true
+s:option(Value, "log_size", translate("System log buffer size"), "kiB").optional = true
+s:option(Value, "log_ip", translate("External system log server")).optional = true
+s:option(Value, "log_port", translate("External system log server port")).optional = true
+s:option(Value, "conloglevel", translate("Log output level")).optional = true
+s:option(Value, "cronloglevel", translate("Cron Log Level")).optional = true
+
+s2 = m:section(TypedSection, "rdate", translate("Time Server (rdate)"))
+s2.anonymous = true
+s2.addremove = false
+
+s2:option(DynamicList, "server", translate("Server"))
+
 return m