diff options
-rw-r--r-- | lbu-controller.lua | 4 | ||||
-rw-r--r-- | lbu-listbackups-html.lsp | 12 | ||||
-rw-r--r-- | lbu-model.lua | 36 | ||||
-rw-r--r-- | 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("</span>") <DL> <? if #view.value == 0 then ?> No backup files -<? else - local selected = false ?> +<? else ?> <table><tr> <td class="header">Action</td> <td class="header">File</td> </tr> <? for i,name in ipairs(view.value) do ?> <tr><td> - <?= html.link{value="deletebackup?backup="..name, label="Delete "} ?> - <? if name == view.selected then - selected = true ?> - selected - <? else ?> <?= html.link{value="selectbackup?backup="..name, label="Select "} ?> - <? end ?> </td> <td><?= name ?></td></tr> <? end - if not selected then ?> - Warning!! Selecting a backup file will cause the current lbu overlay to be lost!! - <? end end ?> </table> </DL> 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 @@ -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 |