modules/admin-*: Fixes for firmware upgrade and system reset
authorSteven Barth <steven@midlink.org>
Sun, 3 Aug 2008 16:33:49 +0000 (16:33 +0000)
committerSteven Barth <steven@midlink.org>
Sun, 3 Aug 2008 16:33:49 +0000 (16:33 +0000)
contrib/package/luci-addons/dist/sbin/luci-flash
modules/admin-full/luasrc/controller/admin/system.lua
modules/admin-full/luasrc/view/admin_system/upgrade.htm
modules/admin-mini/luasrc/controller/mini/system.lua
modules/admin-mini/luasrc/view/mini/upgrade.htm

index d58561e6f141271219bc44a2b27f539cef350943..07434b5073d30e7619535a8a43411be15070149a 100755 (executable)
@@ -2,7 +2,7 @@
 . /etc/functions.sh
 
 # initialize defaults
-RAMFS_COPY_BIN=""       # extra programs for temporary ramfs root
+RAMFS_COPY_BIN="/usr/bin/awk"       # extra programs for temporary ramfs root
 RAMFS_COPY_DATA=""      # extra data files
 export KEEP_PATTERN=""
 export VERBOSE=1
index 01663a4c33afcb22d5ac402fb95bd4b05112d270..8e3a3d79999da1f4f1a1a507d6b7842cf44a19ff 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"
        
@@ -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()
index 350d6a8db70a2e9b8a62b23bbdbce3b309aa5f10..e0fbb933262a41dd72d6de56fe9dfc8f823e1f66 100644 (file)
@@ -24,8 +24,10 @@ $Id$
                <input type="file" size="30" name="image" />
                <br />
                <br />
+               <% if keep_avail then -%>
                <input type="checkbox" name="keepcfg" value="1" checked="checked" />
                <span class="bold"><%:a_s_flash_keepcfg%></span>
+               <% end -%>
        </div>
        <div>
                <input type="submit" value="<%:a_s_flash_fwupgrade%>" />
index e272a1fc7720ccd1a7015fe3ca1183ee090b3edd..ef1489b9b13644ad2491a2cac99d64f1ed1490cc 100644 (file)
@@ -28,7 +28,7 @@ function index()
 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"
        
@@ -81,7 +81,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(
@@ -99,13 +102,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("mini/upgrade", {sysupgrade=plat, ret=ret})
+       luci.template.render("mini/upgrade", {sysupgrade=plat, ret=ret, keep_avail=keep_avail})
 end
 
 function action_passwd()
index 350d6a8db70a2e9b8a62b23bbdbce3b309aa5f10..e0fbb933262a41dd72d6de56fe9dfc8f823e1f66 100644 (file)
@@ -24,8 +24,10 @@ $Id$
                <input type="file" size="30" name="image" />
                <br />
                <br />
+               <% if keep_avail then -%>
                <input type="checkbox" name="keepcfg" value="1" checked="checked" />
                <span class="bold"><%:a_s_flash_keepcfg%></span>
+               <% end -%>
        </div>
        <div>
                <input type="submit" value="<%:a_s_flash_fwupgrade%>" />