gluon-luci-admin: remove backup/restore

This commit is contained in:
Nils Schneider 2014-02-18 23:13:42 +01:00
parent 08bc198e36
commit 3712f8795c
3 changed files with 0 additions and 132 deletions

View File

@ -17,51 +17,9 @@ module("luci.controller.admin.system", package.seeall)
function index()
entry({"admin", "passwd"}, cbi("admin/passwd"), "Admin Password", 10)
entry({"admin", "backup"}, call("action_backup"), "Backup / Restore", 80)
entry({"admin", "upgrade"}, call("action_upgrade"), "Flash Firmware", 90)
end
function action_backup()
local reset_avail = os.execute([[grep '"rootfs_data"' /proc/mtd >/dev/null 2>&1]]) == 0
local restore_cmd = "gunzip | tar -xC/ >/dev/null 2>&1"
local backup_cmd = "tar -c %s | gzip 2>/dev/null"
local restore_fpi
luci.http.setfilehandler(
function(meta, chunk, eof)
if not restore_fpi then
restore_fpi = io.popen(restore_cmd, "w")
end
if chunk then
restore_fpi:write(chunk)
end
if eof then
restore_fpi:close()
end
end
)
local upload = luci.http.formvalue("archive")
local backup = luci.http.formvalue("backup")
local reset = reset_avail and luci.http.formvalue("reset")
if upload and #upload > 0 then
luci.template.render("admin/applyreboot")
luci.sys.reboot()
elseif backup then
local reader = ltn12_popen(backup_cmd:format(_keep_pattern()))
luci.http.header('Content-Disposition', 'attachment; filename="backup-%s-%s.tar.gz"' % {
luci.sys.hostname(), os.date("%Y-%m-%d")})
luci.http.prepare_content("application/x-targz")
luci.ltn12.pump.all(reader, luci.http.write)
elseif reset then
luci.template.render("admin/applyreboot")
luci.util.exec("mtd -r erase rootfs_data")
else
luci.template.render("admin/backup", {reset_avail = reset_avail})
end
end
function action_upgrade()
require("luci.model.uci")
@ -187,36 +145,6 @@ function _keep_pattern()
return kpattern
end
function ltn12_popen(command)
local fdi, fdo = nixio.pipe()
local pid = nixio.fork()
if pid > 0 then
fdo:close()
local close
return function()
local buffer = fdi:read(2048)
local wpid, stat = nixio.waitpid(pid, "nohang")
if not close and wpid and stat == "exited" then
close = true
end
if buffer and #buffer > 0 then
return buffer
elseif close then
fdi:close()
return nil
end
end
elseif pid == 0 then
nixio.dup(fdo, nixio.stdout)
fdi:close()
fdo:close()
nixio.exec("/bin/sh", "-c", command)
end
end
function fork_exec(command)
local pid = nixio.fork()
if pid > 0 then

View File

@ -1,21 +0,0 @@
<%#
LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id$
-%>
<%+header%>
<h2><a id="content" name="content">System</a></h2>
<br />
<p><% if msg then %><%=msg%><% else %>Changes applied.<% end %></p>
<p>Please wait: Device rebooting...</p>
<script type="text/javascript">setTimeout("location='<%=controller%>'", 60000)</script>
<%+footer%>

View File

@ -1,39 +0,0 @@
<%#
LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id$
-%>
<%+header%>
<h2><a id="content" name="content">Backup / Restore</a></h2>
<p>Here you can backup and restore your configuration and - if possible - reset this device to the default settings.</p>
<br />
<div>
<ul>
<li><a href="<%=REQUEST_URI%>?backup=kthxbye">Create backup</a></li>
<% if reset_avail then -%>
<li><a href="<%=REQUEST_URI%>?reset=yarly" onclick="return confirm('Proceed reverting all settings and resetting to firmware defaults?')">Reset this device to defaults</a></li>
<% end -%>
</ul>
</div>
<br />
<form method="post" action="<%=REQUEST_URI%>" enctype="multipart/form-data">
<div class="left">Backup Archive:</div>
<div>
<input type="file" size="30" name="archive" />
</div>
<div>
<input type="submit" class="cbi-button cbi-input-apply" value="Restore backup" />
</div>
</form>
<%+footer%>