From 15facd92800b6e89bbaaf262bf23c9c6328b2dfd Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Sun, 3 Aug 2008 16:33:49 +0000 Subject: [PATCH 1/1] modules/admin-*: Fixes for firmware upgrade and system reset --- contrib/package/luci-addons/dist/sbin/luci-flash | 2 +- modules/admin-full/luasrc/controller/admin/system.lua | 9 ++++++--- modules/admin-full/luasrc/view/admin_system/upgrade.htm | 2 ++ modules/admin-mini/luasrc/controller/mini/system.lua | 9 ++++++--- modules/admin-mini/luasrc/view/mini/upgrade.htm | 2 ++ 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/contrib/package/luci-addons/dist/sbin/luci-flash b/contrib/package/luci-addons/dist/sbin/luci-flash index d58561e6f..07434b507 100755 --- a/contrib/package/luci-addons/dist/sbin/luci-flash +++ b/contrib/package/luci-addons/dist/sbin/luci-flash @@ -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 diff --git a/modules/admin-full/luasrc/controller/admin/system.lua b/modules/admin-full/luasrc/controller/admin/system.lua index 01663a4c3..8e3a3d799 100644 --- a/modules/admin-full/luasrc/controller/admin/system.lua +++ b/modules/admin-full/luasrc/controller/admin/system.lua @@ -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() diff --git a/modules/admin-full/luasrc/view/admin_system/upgrade.htm b/modules/admin-full/luasrc/view/admin_system/upgrade.htm index 350d6a8db..e0fbb9332 100644 --- a/modules/admin-full/luasrc/view/admin_system/upgrade.htm +++ b/modules/admin-full/luasrc/view/admin_system/upgrade.htm @@ -24,8 +24,10 @@ $Id$

+ <% if keep_avail then -%> <%:a_s_flash_keepcfg%> + <% end -%>
diff --git a/modules/admin-mini/luasrc/controller/mini/system.lua b/modules/admin-mini/luasrc/controller/mini/system.lua index e272a1fc7..ef1489b9b 100644 --- a/modules/admin-mini/luasrc/controller/mini/system.lua +++ b/modules/admin-mini/luasrc/controller/mini/system.lua @@ -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() diff --git a/modules/admin-mini/luasrc/view/mini/upgrade.htm b/modules/admin-mini/luasrc/view/mini/upgrade.htm index 350d6a8db..e0fbb9332 100644 --- a/modules/admin-mini/luasrc/view/mini/upgrade.htm +++ b/modules/admin-mini/luasrc/view/mini/upgrade.htm @@ -24,8 +24,10 @@ $Id$

+ <% if keep_avail then -%> <%:a_s_flash_keepcfg%> + <% end -%>
-- 2.11.0