X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=modules%2Fadmin-full%2Fluasrc%2Fcontroller%2Fadmin%2Fsystem.lua;h=9071bfdfe4c9cc65bba0a09aa00bdc7709f00795;hp=55087a01774d7b5414a21da2f45f468ec5683fd9;hb=04b52469506f0bbc49fd1edebeb7567c3d12b873;hpb=fade8edd2dfe39ae579256d04220aba9da2ff074 diff --git a/modules/admin-full/luasrc/controller/admin/system.lua b/modules/admin-full/luasrc/controller/admin/system.lua index 55087a017..9071bfdfe 100644 --- a/modules/admin-full/luasrc/controller/admin/system.lua +++ b/modules/admin-full/luasrc/controller/admin/system.lua @@ -17,7 +17,7 @@ function index() luci.i18n.loadc("admin-core") local i18n = luci.i18n.translate - entry({"admin", "system"}, alias("admin", "system", "system"), i18n("system"), 30) + entry({"admin", "system"}, alias("admin", "system", "system"), i18n("system"), 30).index = true entry({"admin", "system", "system"}, cbi("admin_system/system"), i18n("system"), 1) entry({"admin", "system", "packages"}, call("action_packages"), i18n("a_s_packages"), 10) entry({"admin", "system", "packages", "ipkg"}, form("admin_system/ipkg"), i18n("a_s_p_ipkg")) @@ -25,7 +25,11 @@ function index() entry({"admin", "system", "sshkeys"}, form("admin_system/sshkeys"), i18n("a_s_sshkeys"), 30) entry({"admin", "system", "processes"}, form("admin_system/processes"), i18n("process_head"), 45) entry({"admin", "system", "fstab"}, cbi("admin_system/fstab"), i18n("a_s_fstab"), 50) - entry({"admin", "system", "leds"}, cbi("admin_system/leds"), i18n("leds", "LEDs"), 60) + + if luci.fs.isdirectory("/sys/class/leds") then + entry({"admin", "system", "leds"}, cbi("admin_system/leds"), i18n("leds", "LEDs"), 60) + end + entry({"admin", "system", "backup"}, call("action_backup"), i18n("a_s_backup"), 70) entry({"admin", "system", "upgrade"}, call("action_upgrade"), i18n("a_s_flash"), 80) entry({"admin", "system", "reboot"}, call("action_reboot"), i18n("reboot"), 90) @@ -144,7 +148,8 @@ function action_backup() elseif backup then luci.util.perror(backup_cmd:format(_keep_pattern())) local backup_fpi = io.popen(backup_cmd:format(_keep_pattern()), "r") - luci.http.header('Content-Disposition', 'attachment; filename="backup.tar.gz"') + 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) elseif reset then @@ -182,12 +187,10 @@ end function action_upgrade() require("luci.model.uci") - local ret, err + local ret local plat = luci.fs.mtime("/lib/upgrade/platform.sh") local tmpfile = "/tmp/firmware.img" - local broadcom = os.execute('grep brcm_ /lib/upgrade/platform.sh >/dev/null 2>&1') == 0 - - local keep_avail = not broadcom + local keep_avail = true local file luci.http.setfilehandler( @@ -208,11 +211,13 @@ function action_upgrade() local keepcfg = keep_avail and luci.http.formvalue("keepcfg") if plat and fname then - ret, err = luci.sys.flash(tmpfile, keepcfg and _keep_pattern()) + ret = function() + return luci.sys.flash(tmpfile, keepcfg and _keep_pattern()) + end end - luci.template.render("admin_system/upgrade", {sysupgrade=plat, - ret=ret, err=err, keep_avail=keep_avail}) + luci.http.prepare_content("text/html") + luci.template.render("admin_system/upgrade", {sysupgrade=plat, ret=ret, keep_avail=keep_avail}) end function _keep_pattern() @@ -220,8 +225,10 @@ function _keep_pattern() local files = luci.model.uci.cursor():get_all("luci", "flash_keep") if files then kpattern = "" - for k,v in pairs(files) do - kpattern = kpattern .. " " .. v + for k, v in pairs(files) do + if k:sub(1,1) ~= "." and luci.fs.glob(v) then + kpattern = kpattern .. " " .. v + end end end return kpattern