2 LuCI - Lua Development Framework
4 Copyright 2009 Steven Barth <steven@midlink.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
15 local require, pairs, unpack = require, pairs, unpack
16 module "luci.controller.niu.system"
19 entry({"niu", "system"}, nil, "System").dbtemplate = "niu/system"
21 entry({"niu", "system", "general"},
22 cbi("niu/system/general", {on_success_to={"niu"}}), "General", 10)
24 entry({"niu", "system", "backup"}, call("backup"), "Backup Settings", 20)
28 local os = require "os"
29 local uci = require "luci.model.uci".cursor()
30 local nixio, nutl = require "nixio", require "nixio.util"
31 local fs = require "nixio.fs"
32 local http = require "luci.http"
35 local call = {"/bin/tar", "-cz"}
36 for k, v in pairs(uci:get_all("luci", "flash_keep")) do
37 if k:byte() ~= 46 then -- k[1] ~= "."
38 nutl.consume(fs.glob(v), call)
44 'Content-Disposition', 'attachment; filename="backup-%s-%s.tar.gz"' % {
45 nixio.uname().nodename, os.date("%Y-%m-%d")
48 http.prepare_content("application/x-targz")
51 local fdin, fdout = nixio.pipe()
52 local devnull = nixio.open("/dev/null", "r+")
53 local proc = nixio.fork()
57 nixio.dup(devnull, nixio.stdin)
58 nixio.dup(devnull, nixio.stderr)
59 nixio.dup(fdout, nixio.stdout)
60 nixio.exec(unpack(call))