summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2012-12-14 16:11:07 +0000
committerTed Trask <ttrask01@yahoo.com>2012-12-14 16:11:07 +0000
commit289e53106336ac2e578d769881527549bbdf40ec (patch)
tree07e2ec121561670d1414f9dc55486b358f174202
parent85e1efcc212616b3b15b6f45a66969d45bf53a17 (diff)
downloadacf-alpine-conf-289e53106336ac2e578d769881527549bbdf40ec.tar.bz2
acf-alpine-conf-289e53106336ac2e578d769881527549bbdf40ec.tar.xz
Fix commit error reporting and change backup to use a select
-rw-r--r--lbu-model.lua34
1 files changed, 11 insertions, 23 deletions
diff --git a/lbu-model.lua b/lbu-model.lua
index 6cdd254..f6c9d2a 100644
--- a/lbu-model.lua
+++ b/lbu-model.lua
@@ -54,19 +54,6 @@ local function availablemedias()
return medias
end
-local function getLbuCommit(flag)
- local err = {}
- local ret = ""
- local f = modelfunctions.run_executable({"lbu", "commit", flag}, true)
- for line in string.gmatch(f, "[^\n]+") do
- ret = ret .. line .. "\n"
- --Look for error messages in output
- local searchrow, search = string.match(line, "^(lbu.*(%-%a).*)")
- if (search) then err[search] = searchrow end
- end
- return ret, err
-end
-
local function getciphers()
local opensslciphers = {}
local watchdog = nil
@@ -361,7 +348,7 @@ function commit(self, input)
local flag = "-v"
if input.value.simulate.value then flag=flag.." -n" end
if input.value.delete.value then flag=flag.." -d" end
- input.descr = getLbuCommit(flag)
+ input.descr, input.errtxt = modelfunctions.run_executable({"lbu", "commit", flag}, true)
end
return input
@@ -380,20 +367,21 @@ end
function get_selectbackup(self, clientdata)
local result = {}
- result.backup = cfe({ value=clientdata.backup or "", label="Backup" })
+ result.backup = cfe({ type="select", value=clientdata.backup or "", label="Backup" })
+ local files = getbackupfiles()
+ result.backup.option = files.value
return cfe({ type="group", value=result, label="Revert to Backup" })
end
function selectbackupfile(self, backuprequest)
- local files = getbackupfiles()
- for i,file in ipairs(files.value) do
- if file == backuprequest.value.backup.value then
- backuprequest.descr, backuprequest.errtxt = modelfunctions.run_executable({"lbu", "revert", file})
- if not backuprequest.errtxt and backuprequest.descr == "" then
- backuprequest.descr = "Reverted to backup "..file
- end
- break
+ local success = modelfunctions.validate_select(backuprequest.value.backup)
+ if success then
+ backuprequest.descr, backuprequest.errtxt = modelfunctions.run_executable({"lbu", "revert", backuprequest.value.backup.value})
+ if not backuprequest.errtxt and backuprequest.descr == "" then
+ backuprequest.descr = "Reverted to backup "..file
end
+ else
+ backuprequest.errtxt = "Failed to revert to backup"
end
return backuprequest
end