2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2011 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
17 if luci.http.formvalue("cbid.luci.1._list") then
18 luci.http.redirect(luci.dispatcher.build_url("admin/system/flashops/backupfiles") .. "?display=list")
19 elseif luci.http.formvalue("cbid.luci.1._edit") then
20 luci.http.redirect(luci.dispatcher.build_url("admin/system/flashops/backupfiles") .. "?display=edit")
24 m = SimpleForm("luci", "%s - %s - %s" %{ translate("System"), translate("Flash operations"), translate("Backup file list") })
25 m:append(Template("admin_system/backupfiles"))
27 if luci.http.formvalue("display") ~= "list" then
28 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."))
30 l = f:option(Button, "_list", translate("Show current backup file list"))
31 l.inputtitle = translate("Open list...")
32 l.inputstyle = "apply"
34 c = f:option(TextValue, "_custom")
39 c.cfgvalue = function(self, section)
40 return nixio.fs.readfile("/etc/sysupgrade.conf")
43 c.write = function(self, section, value)
44 value = value:gsub("\r\n?", "\n")
45 return nixio.fs.writefile("/etc/sysupgrade.conf", value)
51 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."))
53 l = f:option(Button, "_edit", translate("Back to configuration"))
54 l.inputtitle = translate("Close list...")
58 d = f:option(DummyValue, "_detected")
60 d.cfgvalue = function(s)
61 local list = io.popen(
62 "( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' /etc/sysupgrade.conf " ..
63 "/lib/upgrade/keep.d/* 2>/dev/null) -type f 2>/dev/null; " ..
64 "opkg list-changed-conffiles ) | sort -u"
68 local files = { "<ul>" }
71 local ln = list:read("*l")
75 files[#files+1] = "<li>"
76 files[#files+1] = luci.util.pcdata(ln)
77 files[#files+1] = "</li>"
82 files[#files+1] = "</ul>"
84 return table.concat(files, "")
87 return "<em>" .. translate("No files found") .. "</em>"