1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
3 -- Licensed to the public under the Apache License 2.0.
5 if luci.http.formvalue("cbid.luci.1._list") then
6 luci.http.redirect(luci.dispatcher.build_url("admin/system/flashops/backupfiles") .. "?display=list")
7 elseif luci.http.formvalue("cbid.luci.1._edit") then
8 luci.http.redirect(luci.dispatcher.build_url("admin/system/flashops/backupfiles") .. "?display=edit")
12 m = SimpleForm("luci", translate("Backup file list"))
13 m:append(Template("admin_system/backupfiles"))
15 if luci.http.formvalue("display") ~= "list" then
16 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."))
18 l = f:option(Button, "_list", translate("Show current backup file list"))
19 l.inputtitle = translate("Open list...")
20 l.inputstyle = "apply"
22 c = f:option(TextValue, "_custom")
27 c.cfgvalue = function(self, section)
28 return nixio.fs.readfile("/etc/sysupgrade.conf")
31 c.write = function(self, section, value)
32 value = value:gsub("\r\n?", "\n")
33 return nixio.fs.writefile("/etc/sysupgrade.conf", value)
39 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."))
41 l = f:option(Button, "_edit", translate("Back to configuration"))
42 l.inputtitle = translate("Close list...")
46 d = f:option(DummyValue, "_detected")
48 d.cfgvalue = function(s)
49 local list = io.popen(
50 "( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' /etc/sysupgrade.conf " ..
51 "/lib/upgrade/keep.d/* 2>/dev/null) -type f 2>/dev/null; " ..
52 "opkg list-changed-conffiles ) | sort -u"
56 local files = { "<ul>" }
59 local ln = list:read("*l")
63 files[#files+1] = "<li>"
64 files[#files+1] = luci.util.pcdata(ln)
65 files[#files+1] = "</li>"
70 files[#files+1] = "</ul>"
72 return table.concat(files, "")
75 return "<em>" .. translate("No files found") .. "</em>"