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")
28 c.cfgvalue = function(self, section)
29 return nixio.fs.readfile("/etc/sysupgrade.conf")
32 m.handle = function(self, state, data)
33 if state == FORM_VALID then
35 nixio.fs.writefile("/etc/sysupgrade.conf", data._custom:gsub("\r\n", "\n"))
37 nixio.fs.writefile("/etc/sysupgrade.conf", "")
46 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."))
48 l = f:option(Button, "_edit", translate("Back to configuration"))
49 l.inputtitle = translate("Close list...")
53 d = f:option(DummyValue, "_detected")
55 d.cfgvalue = function(s)
56 local list = io.popen(
57 "( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' /etc/sysupgrade.conf " ..
58 "/lib/upgrade/keep.d/* 2>/dev/null) -type f 2>/dev/null; " ..
59 "opkg list-changed-conffiles ) | sort -u"
63 local files = { "<ul>" }
66 local ln = list:read("*l")
70 files[#files+1] = "<li>"
71 files[#files+1] = luci.xml.pcdata(ln)
72 files[#files+1] = "</li>"
77 files[#files+1] = "</ul>"
79 return table.concat(files, "")
82 return "<em>" .. translate("No files found") .. "</em>"