luci-mod-admin-full: check backup.tar.gz on apply
If an uploaded backup.tar.gz is not valid we will not get a respond from LuCI. The system will perform a reboot without applying the "tar.gz" even though the backup import failed. To fix this check if the backup archive is valid with the command "gunzip -t <archive>" and if the validation fails render the flashops page with a hint. On the other hand apply the backup archive and perform a reboot as before. Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
parent
ddbde3caaa
commit
65ba4b8b8a
2 changed files with 15 additions and 4 deletions
|
@ -341,9 +341,17 @@ function action_restore()
|
||||||
|
|
||||||
local upload = http.formvalue("archive")
|
local upload = http.formvalue("archive")
|
||||||
if upload and #upload > 0 then
|
if upload and #upload > 0 then
|
||||||
luci.template.render("admin_system/applyreboot")
|
if os.execute("gunzip -t %q >/dev/null 2>&1" % archive_tmp) == 0 then
|
||||||
os.execute("tar -C / -xzf %q >/dev/null 2>&1" % archive_tmp)
|
luci.template.render("admin_system/applyreboot")
|
||||||
luci.sys.reboot()
|
os.execute("tar -C / -xzf %q >/dev/null 2>&1" % archive_tmp)
|
||||||
|
luci.sys.reboot()
|
||||||
|
else
|
||||||
|
luci.template.render("admin_system/flashops", {
|
||||||
|
reset_avail = supports_reset(),
|
||||||
|
upgrade_avail = supports_sysupgrade(),
|
||||||
|
backup_invalid = true
|
||||||
|
})
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -50,9 +50,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<% if backup_invalid then %>
|
||||||
|
<div class="cbi-section-error"><%:The backup archive does not appear to be a valid gzip file.%></div>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% if reset_avail then %>
|
<% if reset_avail then %>
|
||||||
<div class="alert-message warning"><%:Custom files (certificates, scripts) may remain on the system. To prevent this, perform a factory-reset first.%></div>
|
<div class="alert-message warning"><%:Custom files (certificates, scripts) may remain on the system. To prevent this, perform a factory-reset first.%></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue