modules/admin-full: create rdate section in /e/c/system if there is none
[oweals/luci.git] / modules / admin-full / luasrc / model / cbi / admin_system / system.lua
index a2bbf29b6732fbce17011db27c1b33adb53f6103..c55ec0497e72d4a12cdea2590c982da3f56d3a04 100644 (file)
@@ -19,6 +19,22 @@ 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
@@ -82,4 +98,11 @@ 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
+
+s2 = m:section(TypedSection, "rdate", translate("Time Server (rdate)"))
+s2.anonymous = true
+s2.addremove = false
+
+s2:option(DynamicList, "server", translate("Server"))
+
 return m