diff --git a/package/diy/luci-app-ota/Makefile b/package/diy/luci-app-ota/Makefile index 7c4a09e61b..515b099aad 100644 --- a/package/diy/luci-app-ota/Makefile +++ b/package/diy/luci-app-ota/Makefile @@ -3,7 +3,7 @@ include $(TOPDIR)/rules.mk LUCI_TITLE:=LuCI for OTA upgrade LUCI_PKGARCH:=all -PKG_VERSION:=1.2.2 +PKG_VERSION:=1.2.3 PKG_RELEASE:=1 PKG_MAINTAINER:=jjm2473 diff --git a/package/diy/luci-app-ota/luasrc/controller/admin/ota.lua b/package/diy/luci-app-ota/luasrc/controller/admin/ota.lua index 8b2bca4258..f18d15d5a5 100644 --- a/package/diy/luci-app-ota/luasrc/controller/admin/ota.lua +++ b/package/diy/luci-app-ota/luasrc/controller/admin/ota.lua @@ -83,11 +83,8 @@ function action_check() code = 500, msg = "Unknown" } - if r == 0 then - ret.code = 0 - ret.msg = o - elseif r == 1 then - ret.code = 1 + if r == 0 or r == 1 or r == 2 then + ret.code = r ret.msg = o else ret.code = 500 @@ -123,7 +120,7 @@ function action_progress() if r == 0 then ret.code = 0 ret.msg = "done" - elseif r == 1 or r == 2 then + elseif r == 1 or r == 2 or r == 254 then ret.code = r ret.msg = o else diff --git a/package/diy/luci-app-ota/luasrc/view/admin_system/ota.htm b/package/diy/luci-app-ota/luasrc/view/admin_system/ota.htm index 160e5dba48..883284bd18 100644 --- a/package/diy/luci-app-ota/luasrc/view/admin_system/ota.htm +++ b/package/diy/luci-app-ota/luasrc/view/admin_system/ota.htm @@ -41,6 +41,7 @@
+
Step 1/3: <%:Check update%>
@@ -51,6 +52,7 @@
+
Step 2/3: <%:Download firmware%>
@@ -61,6 +63,7 @@
+
Step 2/3: <%:Download firmware%>
@@ -74,6 +77,7 @@
+
Step 3/3: <%:Flash image...%>
@@ -90,7 +94,8 @@
- + +
Step 3/3: <%:Flash image%>
@@ -141,9 +146,18 @@ check.disabled = undefined; switch(d.code){ case 0: + case 2: check_result.innerText = ""; upgrade_log.innerHTML = d.msg; - state_switch("unchecked", "checked"); + if (d.code == 0) { + state_switch("unchecked", "checked"); + } else { + alert("<%:Found downloading firmware, will show progress%>"); + download_progress.innerText = "<%:Downloading%>: ..."; + cancel.disabled = 'disabled'; + state_switch("unchecked", "downloading"); + refresh_download_progress_timer = setTimeout(refresh_download_progress, 500); + } break; case 1: check_result.innerText = "<%:Already the latest firmware%>"; @@ -185,6 +199,9 @@ download_result.innerText = "<%:Download canceled%>"; state_switch("downloading", "checked"); break; + case 254: + state_switch("downloading", "unchecked"); + break; default: download_result.innerText = "<%:Download failed%>"; state_switch("downloading", "checked"); diff --git a/package/diy/luci-app-ota/po/en/ota.po b/package/diy/luci-app-ota/po/en/ota.po index e05d6f4cdf..55964e98db 100644 --- a/package/diy/luci-app-ota/po/en/ota.po +++ b/package/diy/luci-app-ota/po/en/ota.po @@ -25,6 +25,9 @@ msgstr "" msgid "Flash image..." msgstr "" +msgid "Flash image" +msgstr "" + msgid "Checking..." msgstr "" @@ -54,3 +57,6 @@ msgstr "" msgid "History Log" msgstr "" + +msgid "Found downloading firmware, will show progress" +msgstr "" diff --git a/package/diy/luci-app-ota/po/templates/ota.pot b/package/diy/luci-app-ota/po/templates/ota.pot index e05d6f4cdf..55964e98db 100644 --- a/package/diy/luci-app-ota/po/templates/ota.pot +++ b/package/diy/luci-app-ota/po/templates/ota.pot @@ -25,6 +25,9 @@ msgstr "" msgid "Flash image..." msgstr "" +msgid "Flash image" +msgstr "" + msgid "Checking..." msgstr "" @@ -54,3 +57,6 @@ msgstr "" msgid "History Log" msgstr "" + +msgid "Found downloading firmware, will show progress" +msgstr "" diff --git a/package/diy/luci-app-ota/po/zh-cn/ota.po b/package/diy/luci-app-ota/po/zh-cn/ota.po index eb0367b9d9..db49346130 100644 --- a/package/diy/luci-app-ota/po/zh-cn/ota.po +++ b/package/diy/luci-app-ota/po/zh-cn/ota.po @@ -25,6 +25,9 @@ msgstr "固件已下载" msgid "Flash image..." msgstr "刷写固件..." +msgid "Flash image" +msgstr "刷写固件" + msgid "Checking..." msgstr "检查中..." @@ -54,3 +57,6 @@ msgstr "镜像文件格式不支持或损坏。也许稍候再试试" msgid "History Log" msgstr "历史更新日志" + +msgid "Found downloading firmware, will show progress" +msgstr "发现下载中的固件,将显示当前进度" diff --git a/package/diy/luci-app-ota/root/bin/ota b/package/diy/luci-app-ota/root/bin/ota index b11c9fb8ef..df420a38de 100755 --- a/package/diy/luci-app-ota/root/bin/ota +++ b/package/diy/luci-app-ota/root/bin/ota @@ -94,24 +94,30 @@ prepare_check() { return $latest } -# 0: found newer fw, 1: already newest fw, *: err +# 0: found newer fw, 1: already newest fw, 2: found running task, *: err do_check() { local ret=0 local lock="$WRLOCK" exec 200>$lock - flock -n 200 || return 255 - prepare_check - ret=$? - flock -u 200 >/dev/null 2>&1 + if flock -n 200; then + prepare_check + ret=$? + flock -u 200 >/dev/null 2>&1 + elif [ -f /tmp/firmware.img.progress -o -f /tmp/firmware.img.sha256sum ]; then + ret=2 + else + echo "lock failed!" >&2 + return 255 + fi - if [ "$ret" -eq 0 ]; then + if [ "$ret" -eq 0 -o "$ret" -eq 2 ]; then # output echo "
"
         sed -E 's/.*\((.+)\).*/\1/' /var/run/ota/ota.latest
         echo "
" echo "

ChangeLog:

" fi - [ "$ret" -eq 0 -o "$ret" -eq 1 ] && cat /var/run/ota/ota.log + [ "$ret" -eq 0 -o "$ret" -eq 1 -o "$ret" -eq 2 ] && cat /var/run/ota/ota.log return $ret } @@ -124,7 +130,7 @@ do_download(){ return 0 } -# 0: done, 1: downloading, 2: failed, *: err +# 0: done, 1: downloading, 2: failed, 254: wrong state, *: err do_progress() { local sum=`grep 'SHA256: ' /var/run/ota/ota.latest | cut -d' ' -f2` [ -z "$sum" ] && { echo "do check first" >&2 ; return 254; }