From e36290cc32c9d9a7b70e1ce09127517be7aadf9a Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Wed, 25 Jun 2008 13:28:22 +0000 Subject: Updated lbu to use lbu list-backup and revert. git-svn-id: svn://svn.alpinelinux.org/acf/alpine-conf/trunk@1261 ab2d0c66-481e-0410-8bed-d214d4d58bed --- lbu-controller.lua | 4 ++-- lbu-listbackups-html.lsp | 12 +----------- lbu-model.lua | 36 ++++++++++++++++++++++++++++++++---- lbu.roles | 2 +- 4 files changed, 36 insertions(+), 18 deletions(-) diff --git a/lbu-controller.lua b/lbu-controller.lua index 4072740..d70dde7 100644 --- a/lbu-controller.lua +++ b/lbu-controller.lua @@ -123,12 +123,12 @@ end function listbackups(self) return self.model.getbackupfiles() end - +--[[ function deletebackup(self) self.model.deletebackupfile(self.clientdata.backup) redirect_to_referrer(self) end - +--]] function selectbackup(self) self.model.selectbackupfile(self.clientdata.backup) redirect_to_referrer(self) diff --git a/lbu-listbackups-html.lsp b/lbu-listbackups-html.lsp index ad26069..cfd6efc 100644 --- a/lbu-listbackups-html.lsp +++ b/lbu-listbackups-html.lsp @@ -13,27 +13,17 @@ io.write("")
No backup files - + - Warning!! Selecting a backup file will cause the current lbu overlay to be lost!! -
Action File
- - - selected - -
diff --git a/lbu-model.lua b/lbu-model.lua index 81236eb..3ae6c87 100644 --- a/lbu-model.lua +++ b/lbu-model.lua @@ -59,7 +59,7 @@ end local function getciphers() local opensslciphers = {} local watchdog = nil - local f = io.popen("/usr/bin/openssl -v 2>&1", "r") + local f = io.popen("PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin openssl -v 2>&1", "r") if not (f) then return ciphers end for line in f:lines() do if (watchdog) then @@ -168,7 +168,7 @@ local function validatefilecontent (filecontent) return filecontent end - +--[[ local was_mounted local mnt local function mount() @@ -192,7 +192,7 @@ local function unmount() g:close() end end - +--]] -- ################################################################################ -- PUBLIC FUNCTIONS @@ -387,7 +387,7 @@ function commit(input) return input end - +--[[ function getbackupfiles() mount() local files = {} @@ -422,3 +422,31 @@ function deletebackupfile(file) end unmount() end +--]] +function getbackupfiles() + local files = {} + local f = io.popen("PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin lbu lb 2>&1", "r") + for line in f:lines() do + files[#files + 1] = line + end + f:close() + return cfe({ type="list", value=files, label="Backup archive list"}) +end + +function selectbackupfile(selectfile) + local cmdresult = cfe({ value="Failed to select backup", errtxt="Backup not found", label="Select Backup result"}) + local files = getbackupfiles() + for i,file in ipairs(files.value) do + if file == selectfile then + local f = io.popen("PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin lbu revert "..file.." 2>&1", "r") + cmdresult.errtxt = f:read("*a") + if "" == cmdresult.errtxt then + cmdresult.errtxt = nil + cmdresult.value = "Selected backup "..file + end + f:close() + break + end + end + return cmdresult +end diff --git a/lbu.roles b/lbu.roles index 525df12..8aaeb48 100644 --- a/lbu.roles +++ b/lbu.roles @@ -1,2 +1,2 @@ -UPDATE=lbu:config,lbu:commit,lbu:expert,lbu:editincluded,lbu:editexcluded,lbu:listbackups,lbu:deletebackup,lbu:selectbackup +UPDATE=lbu:config,lbu:commit,lbu:expert,lbu:editincluded,lbu:editexcluded,lbu:listbackups,lbu:selectbackup ALL=lbu:basicstatus,lbu:status -- cgit v1.2.3