diff options
Diffstat (limited to 'modules/admin-full/luasrc/model')
3 files changed, 104 insertions, 93 deletions
diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/backupfiles.lua b/modules/admin-full/luasrc/model/cbi/admin_system/backupfiles.lua new file mode 100644 index 0000000000..22258a9372 --- /dev/null +++ b/modules/admin-full/luasrc/model/cbi/admin_system/backupfiles.lua @@ -0,0 +1,92 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2008 Steven Barth <steven@midlink.org> +Copyright 2011 Jo-Philipp Wich <xm@subsignal.org> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- + + +if luci.http.formvalue("cbid.luci.1._list") then + luci.http.redirect(luci.dispatcher.build_url("admin/system/flashops/backupfiles") .. "?display=list") +elseif luci.http.formvalue("cbid.luci.1._edit") then + luci.http.redirect(luci.dispatcher.build_url("admin/system/flashops/backupfiles") .. "?display=edit") + return +end + +m = SimpleForm("luci", "%s - %s - %s" %{ translate("System"), translate("Flash operations"), translate("Backup file list") }) +m:append(Template("admin_system/backupfiles")) + +if luci.http.formvalue("display") ~= "list" then + f = m:section(SimpleSection, nil, translate("This is a list of shell glob patterns for matching files and directories to include during sysupgrade. Modified files in /etc/config/ and certain other configurations are automatically preserved.")) + + l = f:option(Button, "_list", translate("Show current backup file list")) + l.inputtitle = translate("Open list...") + l.inputstyle = "apply" + + c = f:option(TextValue, "_custom") + c.rmempty = false + c.cols = 70 + c.rows = 30 + + c.cfgvalue = function(self, section) + return nixio.fs.readfile("/etc/sysupgrade.conf") + end + + c.write = function(self, section, value) + value = value:gsub("\r\n?", "\n") + return nixio.fs.writefile("/etc/sysupgrade.conf", value) + end +else + m.submit = false + m.reset = false + + f = m:section(SimpleSection, nil, translate("Below is the determined list of files to backup. It consists of changed configuration files marked by opkg, essential base files and the user defined backup patterns.")) + + l = f:option(Button, "_edit", translate("Back to configuration")) + l.inputtitle = translate("Close list...") + l.inputstyle = "link" + + + d = f:option(DummyValue, "_detected") + d.rawhtml = true + d.cfgvalue = function(s) + local list = io.popen( + "( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' /etc/sysupgrade.conf " .. + "/lib/upgrade/keep.d/* 2>/dev/null) -type f 2>/dev/null; " .. + "opkg list-changed-conffiles ) | sort -u" + ) + + if list then + local files = { "<ul>" } + + while true do + local ln = list:read("*l") + if not ln then + break + else + files[#files+1] = "<li>" + files[#files+1] = luci.util.pcdata(ln) + files[#files+1] = "</li>" + end + end + + list:close() + files[#files+1] = "</ul>" + + return table.concat(files, "") + end + + return "<em>" .. translate("No files found") .. "</em>" + end + +end + +return m diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/ipkg.lua b/modules/admin-full/luasrc/model/cbi/admin_system/ipkg.lua index 1db0f11748..e9ff5b1460 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_system/ipkg.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_system/ipkg.lua @@ -2,7 +2,7 @@ LuCI - Lua Configuration Interface Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> +Copyright 2008-2011 Jo-Philipp Wich <xm@subsignal.org> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,10 +12,13 @@ You may obtain a copy of the License at $Id$ ]]-- -local ipkgfile = "/etc/opkg.conf" + +local ipkgfile = "/etc/opkg.conf" f = SimpleForm("ipkgconf", translate("OPKG-Configuration")) +f:append(Template("admin_system/ipkg")) + t = f:field(TextValue, "lines") t.rows = 10 function t.cfgvalue() @@ -26,8 +29,6 @@ function t.write(self, section, data) return nixio.fs.writefile(ipkgfile, data:gsub("\r\n", "\n")) end -f:append(Template("admin_system/ipkg")) - function f.handle(self, state, data) return true end diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/system.lua b/modules/admin-full/luasrc/model/cbi/admin_system/system.lua index f2e83401e0..ed7701222e 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_system/system.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_system/system.lua @@ -44,38 +44,13 @@ s:tab("language", translate("Language and Style")) -- System Properties -- -local system, model, memtotal, memcached, membuffers, memfree = luci.sys.sysinfo() -local uptime = luci.sys.uptime() +clock = s:taboption("general", DummyValue, "_systime", translate("Local Time")) +clock.template = "admin_system/clock_status" -s:taboption("general", DummyValue, "_system", translate("System")).value = system -s:taboption("general", DummyValue, "_cpu", translate("Processor")).value = model - -s:taboption("general", DummyValue, "_kernel", translate("Kernel")).value = - luci.util.exec("uname -r") or "?" - -local load1, load5, load15 = luci.sys.loadavg() -s:taboption("general", DummyValue, "_la", translate("Load")).value = - string.format("%.2f, %.2f, %.2f", load1, load5, load15) - -s:taboption("general", DummyValue, "_memtotal", translate("Memory")).value = - string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)", - tonumber(memtotal) / 1024, - 100 * memcached / memtotal, - tostring(translate("cached")), - 100 * membuffers / memtotal, - tostring(translate("buffered")), - 100 * memfree / memtotal, - tostring(translate("free")) -) - -s:taboption("general", DummyValue, "_systime", translate("Local Time")).value = - os.date("%c") - -s:taboption("general", DummyValue, "_uptime", translate("Uptime")).value = - luci.tools.webadmin.date_format(tonumber(uptime)) hn = s:taboption("general", Value, "hostname", translate("Hostname")) hn.datatype = "hostname" + function hn.write(self, section, value) Value.write(self, section, value) luci.sys.hostname(value) @@ -184,8 +159,8 @@ end -- if has_rdate then - m3= Map("timeserver", translate("Time Server (rdate)")) - s = m3:section(TypedSection, "timeserver") + m2 = Map("timeserver", translate("Time Server (rdate)")) + s = m2:section(TypedSection, "timeserver") s.anonymous = true s.addremove = true s.template = "cbi/tblsection" @@ -196,7 +171,7 @@ if has_rdate then i = s:option(ListValue, "interface", translate("Interface")) i.rmempty = true i:value("", translate("Default")) - m3.uci:foreach("network", "interface", + m2.uci:foreach("network", "interface", function (section) local ifc = section[".name"] if ifc ~= "loopback" then @@ -207,61 +182,4 @@ if has_rdate then end -m2 = Map("luci") - -f = m2:section(NamedSection, "main", "core", translate("Files to be kept when flashing a new firmware")) - -f:tab("detected", translate("Detected Files"), - translate("The following files are detected by the system and will be kept automatically during sysupgrade")) - -f:tab("custom", translate("Custom Files"), - translate("This is a list of shell glob patterns for matching files and directories to include during sysupgrade")) - -d = f:taboption("detected", DummyValue, "_detected", translate("Detected files")) -d.rawhtml = true -d.cfgvalue = function(s) - local list = io.popen( - "( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' /etc/sysupgrade.conf " .. - "/lib/upgrade/keep.d/* 2>/dev/null) -type f 2>/dev/null; " .. - "opkg list-changed-conffiles ) | sort -u" - ) - - if list then - local files = { "<ul>" } - - while true do - local ln = list:read("*l") - if not ln then - break - else - files[#files+1] = "<li>" - files[#files+1] = luci.util.pcdata(ln) - files[#files+1] = "</li>" - end - end - - list:close() - files[#files+1] = "</ul>" - - return table.concat(files, "") - end - - return "<em>" .. translate("No files found") .. "</em>" -end - -c = f:taboption("custom", TextValue, "_custom", translate("Custom files")) -c.rmempty = false -c.cols = 70 -c.rows = 30 - -c.cfgvalue = function(self, section) - return nixio.fs.readfile("/etc/sysupgrade.conf") -end - -c.write = function(self, section, value) - value = value:gsub("\r\n?", "\n") - return nixio.fs.writefile("/etc/sysupgrade.conf", value) -end - - -return m, m3 or m2, m3 and m2 +return m, m2 |