2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2010 Jo-Philipp Wich <xm@subsignal.org>
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
16 require("luci.config")
17 m = Map("luci", translate("Web <abbr title=\"User Interface\">UI</abbr>"), translate("Here you can customize the settings and the functionality of <abbr title=\"Lua Configuration Interface\">LuCI</abbr>."))
19 local fs = require "nixio.fs"
21 -- force reload of global luci config namespace to reflect the changes
22 function m.commit_handler(self)
23 package.loaded["luci.config"] = nil
24 require("luci.config")
28 c = m:section(NamedSection, "main", "core", translate("General"))
30 l = c:option(ListValue, "lang", translate("Language"))
33 local i18ndir = luci.i18n.i18ndir .. "base."
34 for k, v in luci.util.kspairs(luci.config.languages) do
35 local file = i18ndir .. k:gsub("_", "-")
36 if k:sub(1, 1) ~= "." and fs.access(file .. ".lmo") then
41 t = c:option(ListValue, "mediaurlbase", translate("Design"))
42 for k, v in pairs(luci.config.themes) do
43 if k:sub(1, 1) ~= "." then
48 u = m:section(NamedSection, "uci_oncommit", "event", translate("Post-commit actions"),
49 translate("These commands will be executed automatically when a given <abbr title=\"Unified Configuration Interface\">UCI</abbr> configuration is committed allowing changes to be applied instantly."))
53 f = m:section(NamedSection, "main", "core", translate("Files to be kept when flashing a new firmware"))
55 f:tab("detected", translate("Detected Files"),
56 translate("The following files are detected by the system and will be kept automatically during sysupgrade"))
58 f:tab("custom", translate("Custom Files"),
59 translate("This is a list of shell glob patterns for matching files and directories to include during sysupgrade"))
61 d = f:taboption("detected", DummyValue, "_detected", translate("Detected files"))
63 d.cfgvalue = function(s)
64 local list = io.popen(
65 "( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' /etc/sysupgrade.conf " ..
66 "/lib/upgrade/keep.d/* 2>/dev/null) -type f 2>/dev/null; " ..
67 "opkg list-changed-conffiles ) | sort -u"
71 local files = { "<ul>" }
74 local ln = list:read("*l")
78 files[#files+1] = "<li>"
79 files[#files+1] = luci.util.pcdata(ln)
80 files[#files+1] = "</li>"
85 files[#files+1] = "</ul>"
87 return table.concat(files, "")
90 return "<em>" .. translate("No files found") .. "</em>"
93 c = f:taboption("custom", TextValue, "_custom", translate("Custom files"))
98 c.cfgvalue = function(self, section)
99 return nixio.fs.readfile("/etc/sysupgrade.conf")
102 c.write = function(self, section, value)
103 return nixio.fs.writefile("/etc/sysupgrade.conf", value)