diff options
Diffstat (limited to 'lbu-model.lua')
-rw-r--r-- | lbu-model.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lbu-model.lua b/lbu-model.lua index ae91096..a5856d2 100644 --- a/lbu-model.lua +++ b/lbu-model.lua @@ -433,3 +433,30 @@ function selectbackupfile(selectfile) end return cmdresult end + +function getpackage() + -- create a temporary directory to store the file + require("session") + local tmp = "/tmp/"..session.random_hash(10) + while posix.stat( tmp ) do + tmp = "/tmp/"..session.random_hash(10) + end + posix.mkdir(tmp) + local f = io.popen("PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin lbu package "..tmp.." 2>&1") + local cmdresult = f:read("*a") + f:close() + + -- find and read the file + local package = cfe({ type="raw", label="error", option="application/x-gzip" }) + for name in fs.find(".*tar%.gz", tmp) do + package.label = basename(name) + package.value = fs.read_file(name) + break + end + + -- delete the temp directory and file + f = io.popen("rm -r "..tmp) + f:close() + + return package +end |