Moved luci.sys.exec, luci.sys.execl and luci.sys.bigendian to luci.util
[project/luci.git] / modules / admin-full / luasrc / controller / admin / system.lua
index 01663a4c33afcb22d5ac402fb95bd4b05112d270..9abdb2ababf6a3626b146a9a8e1acac750def4a8 100644 (file)
@@ -155,7 +155,7 @@ function action_packages()
 end
 
 function action_backup()
-       local reset_avail = luci.sys.exec([[grep '"rootfs_data"' /proc/mtd >/dev/null 2>&1]]) == 0
+       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"
        
@@ -189,7 +189,7 @@ function action_backup()
                luci.ltn12.pump.all(luci.ltn12.source.file(backup_fpi), luci.http.write)
        elseif reset then
                luci.template.render("admin_system/applyreboot")
-               luci.sys.exec("mtd -r erase rootfs_data")
+               luci.util.exec("mtd -r erase rootfs_data")
        else
                luci.template.render("admin_system/backup", {reset_avail = reset_avail})
        end
@@ -242,7 +242,10 @@ function action_upgrade()
 
        local ret  = nil
        local plat = luci.fs.mtime("/lib/upgrade/platform.sh")
+       local broadcom = os.execute('grep brcm_ /lib/upgrade/platform.sh >/dev/null 2>&1') == 0
        local tmpfile = "/tmp/firmware.img"
+       
+       local keep_avail = not broadcom
 
        local file
        luci.http.setfilehandler(
@@ -260,13 +263,13 @@ function action_upgrade()
        )
 
        local fname   = luci.http.formvalue("image")
-       local keepcfg = luci.http.formvalue("keepcfg")
+       local keepcfg = keep_avail and luci.http.formvalue("keepcfg")
 
        if plat and fname then
                ret = luci.sys.flash(tmpfile, keepcfg and _keep_pattern())
        end
 
-       luci.template.render("admin_system/upgrade", {sysupgrade=plat, ret=ret})
+       luci.template.render("admin_system/upgrade", {sysupgrade=plat, ret=ret, keep_avail=keep_avail})
 end
 
 function _keep_pattern()