luci-0.11: merge r9559 - r9569
[project/luci.git] / modules / admin-mini / luasrc / controller / mini / system.lua
index e562af0283f53fb13aa011b79e50a6fb49c7ddb1..71b5b63519b19a8bc4c4fdfa38882a7d8611f7e3 100644 (file)
@@ -16,15 +16,12 @@ $Id$
 module("luci.controller.mini.system", package.seeall)
 
 function index()
-       luci.i18n.loadc("base")
-       local i18n = luci.i18n.translate
-
-       entry({"mini", "system"}, alias("mini", "system", "index"), i18n("System"), 40).index = true
-       entry({"mini", "system", "index"}, cbi("mini/system", {autoapply=true}), i18n("General"), 1)
-       entry({"mini", "system", "passwd"}, form("mini/passwd"), i18n("Admin Password"), 10)
-       entry({"mini", "system", "backup"}, call("action_backup"), i18n("Backup / Restore"), 80)
-       entry({"mini", "system", "upgrade"}, call("action_upgrade"), i18n("Flash Firmware"), 90)
-       entry({"mini", "system", "reboot"}, call("action_reboot"), i18n("Reboot"), 100)
+       entry({"mini", "system"}, alias("mini", "system", "index"), _("System"), 40).index = true
+       entry({"mini", "system", "index"}, cbi("mini/system", {autoapply=true}), _("General"), 1)
+       entry({"mini", "system", "passwd"}, form("mini/passwd"), _("Admin Password"), 10)
+       entry({"mini", "system", "backup"}, call("action_backup"), _("Backup / Restore"), 80)
+       entry({"mini", "system", "upgrade"}, call("action_upgrade"), _("Flash Firmware"), 90)
+       entry({"mini", "system", "reboot"}, call("action_reboot"), _("Reboot"), 100)
 end
 
 function action_backup()
@@ -55,12 +52,11 @@ function action_backup()
                luci.template.render("mini/applyreboot")
                luci.sys.reboot()
        elseif backup then
-               luci.util.perror(backup_cmd:format(_keep_pattern()))
-               local backup_fpi = io.popen(backup_cmd:format(_keep_pattern()), "r")
+               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(luci.ltn12.source.file(backup_fpi), luci.http.write)
+               luci.ltn12.pump.all(reader, luci.http.write)
        elseif reset then
                luci.template.render("mini/applyreboot")
                luci.util.exec("mtd -r erase rootfs_data")
@@ -85,7 +81,7 @@ function action_upgrade()
        local function image_supported()
                -- XXX: yay...
                return ( 0 == os.execute(
-                       ". /etc/functions.sh; " ..
+                       ". /lib/functions.sh; " ..
                        "include /lib/upgrade; " ..
                        "platform_check_image %q >/dev/null"
                                % tmpfile
@@ -179,7 +175,7 @@ function action_upgrade()
                        nixio.fs.unlink(tmpfile)
                end
                        
-               luci.template.render("admin_system/upgrade", {
+               luci.template.render("mini/upgrade", {
                        step=1,
                        bad_image=(has_image and not has_support or false),
                        keepavail=keep_avail,
@@ -188,7 +184,7 @@ function action_upgrade()
 
        -- Step 2: present uploaded file, show checksum, confirmation
        elseif step == 2 then
-               luci.template.render("admin_system/upgrade", {
+               luci.template.render("mini/upgrade", {
                        step=2,
                        checksum=image_checksum(),
                        filesize=nixio.fs.stat(tmpfile).size,
@@ -198,7 +194,7 @@ function action_upgrade()
        
        -- Step 3: load iframe which calls the actual flash procedure
        elseif step == 3 then
-               luci.template.render("admin_system/upgrade", {
+               luci.template.render("mini/upgrade", {
                        step=3,
                        keepconfig=(keep_avail and luci.http.formvalue("keepcfg") == "1")
                } )