🌴 Sync 2026-03-05 23:51:42

This commit is contained in:
github-actions[bot] committed 2026-03-05 23:51:42 +08:00
1 parent 97c049ed0a
commit 0acff03804
14253 files changed
+3893239

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
# Copyright (C) 2016 Openwrt.org
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI support for EasyUpdate From sundaqiang
LUCI_DEPENDS:=+bash +curl
LUCI_PKGARCH:=all
PKG_VERSION:=1.0
PKG_RELEASE:=1
PKG_MAINTAINER:=sundaqiang
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature
+61
View File
@@ -0,0 +1,61 @@
# luci-app-easyupdate(简易更新)
主要用于使用P3TERX/Actions-OpenWrt自动编译固件后的一键更新
### 使用方法
#### 需在下方步骤后
```yaml
- name: Install feeds
run: cd openwrt && ./scripts/feeds install -a -f
```
#### 添加如下步骤
```yaml
- name: Openwrt AutoUpdate
run: |
TEMP=$(date +"OpenWrt_%Y%m%d_%H%M%S_")$(git rev-parse --short HEAD)
echo "RELEASE_TAG=$TEMP" >> $GITHUB_ENV
#required>>add "DISTRIB_GITHUB" to "zzz-default-settings"
sed -i "/DISTRIB_DESCRIPTION=/a\sed -i '/DISTRIB_GITHUB/d' /etc/openwrt_release" openwrt/package/lean/default-settings/files/zzz-default-settings
sed -i "/DISTRIB_GITHUB/a\echo \"DISTRIB_GITHUB=\'https://github.com/${{github.repository}}\'\" >> /etc/openwrt_release" openwrt/package/lean/default-settings/files/zzz-default-settings
#required>>add "DISTRIB_VERSIONS" to "zzz-default-settings"
sed -i "/DISTRIB_DESCRIPTION=/a\sed -i '/DISTRIB_VERSIONS/d' /etc/openwrt_release" openwrt/package/lean/default-settings/files/zzz-default-settings
sed -i "/DISTRIB_VERSIONS/a\echo \"DISTRIB_VERSIONS=\'${TEMP:8}\'\" >> /etc/openwrt_release" openwrt/package/lean/default-settings/files/zzz-default-settings
#nonessential>>add "github.actor" to "DISTRIB_DESCRIPTION" in "zzz-default-settings"
sed -i "s/OpenWrt /${{github.actor}} compiled (${TEMP:8}) \/ OpenWrt /g" openwrt/package/lean/default-settings/files/zzz-default-settings
```
#### 将如下步骤的`tag_name`的值`${{ steps.tag.outputs.release_tag }}`
```yaml
- name: Upload firmware to release
uses: softprops/action-gh-release@v1
if: steps.tag.outputs.status == 'success' && !cancelled()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.release_tag }}
body_path: release.txt
files: ${{ env.FIRMWARE }}/*
```
#### 更换为`${{ env.RELEASE_TAG }}`
```yaml
- name: Upload firmware to release
uses: softprops/action-gh-release@v1
if: steps.tag.outputs.status == 'success' && !cancelled()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_TAG }}
body_path: release.txt
files: ${{ env.FIRMWARE }}/*
```
#### 也可以直接使用我修改好的actions
[Actions-OpenWrt](https://github.com/sundaqiang/Actions-OpenWrt)
### 效果展示
![easyupdate][1]
[1]: https://raw.githubusercontent.com/sundaqiang/openwrt-packages/master/img/easyupdate.png
@@ -0,0 +1,101 @@
module("luci.controller.easyupdate",package.seeall)
function index()
if not nixio.fs.access("/etc/config/easyupdate") then
return
end
local c=luci.model.uci.cursor()
local r=0
if not c:get("easyupdate", "main", "mirror") then
r=1
c:set("easyupdate", "main", "mirror", "")
end
if not c:get("easyupdate", "main", "keepconfig") then
r=1
c:set("easyupdate", "main", "keepconfig", "1")
end
if not c:get("easyupdate", "main", "github") then
r=1
local pcall, dofile, _G = pcall, dofile, _G
pcall(dofile, "/etc/openwrt_release")
c:set("easyupdate", "main", "github", _G.DISTRIB_GITHUB)
end
if r then
c:commit("easyupdate")
end
entry({"admin", "services", "easyupdate"}, cbi("easyupdate"),_("EasyUpdate"), 99).dependent = true
entry({"admin", "services", "easyupdate", "getver"}, call("getver")).leaf = true
entry({"admin", "services", "easyupdate", "download"}, call("download")).leaf = true
entry({"admin", "services", "easyupdate", "getlog"}, call("getlog")).leaf = true
entry({"admin", "services", "easyupdate", "check"}, call("check")).leaf = true
entry({"admin", "services", "easyupdate", "flash"}, call("flash")).leaf = true
end
function Split(str, delim, maxNb)
-- Eliminate bad cases...
if string.find(str, delim) == nil then
return { str }
end
if maxNb == nil or maxNb < 1 then
maxNb = 0 -- No limit
end
local result = {}
local pat = "(.-)" .. delim .. "()"
local nb = 0
local lastPos
for part, pos in string.gfind(str, pat) do
nb = nb + 1
result[nb] = part
lastPos = pos
if nb == maxNb then break end
end
-- Handle the last field
if nb ~= maxNb then
result[nb + 1] = string.sub(str, lastPos)
end
return result
end
function getver()
local e={}
e.newver=luci.sys.exec("/usr/bin/easyupdate.sh -c")
e.newver=e.newver:sub(0,-2)
e.newverint=os.time({day=e.newver:sub(7,8), month=e.newver:sub(5,6), year=e.newver:sub(1,4), hour=e.newver:sub(10,11), min=e.newver:sub(12,13), sec=e.newver:sub(14,15)})
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
function download()
local e={}
ret=luci.sys.exec("/usr/bin/easyupdate.sh -d")
e.data=ret:match("openwrt.+%.img%.gz")
e.code=1
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
function getlog()
local e = {}
e.code=1
e.data=nixio.fs.readfile ("/tmp/easyupdate.log")
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
function check()
local e = {}
local f = luci.http.formvalue('file')
e.code=1
e.data=luci.sys.exec("/usr/bin/easyupdate.sh -k " .. f)
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
function flash()
local e={}
local f = luci.http.formvalue('file')
luci.sys.exec("/usr/bin/easyupdate.sh -f /tmp/" .. f)
e.code=1
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
@@ -0,0 +1,89 @@
local pcall, dofile, _G = pcall, dofile, _G
pcall(dofile, "/etc/openwrt_release")
local fs = require "nixio.fs"
m=Map("easyupdate",translate("EasyUpdate"),translate("EasyUpdate LUCI supports scheduled upgrade & one-click firmware upgrade.") .. [[<br />]] .. translate("Update may cause the restart failure, Exercise caution when selecting automatic update.") .. [[<br /><br /><a href="https://github.com/sundaqiang/openwrt-packages" target="_blank">Powered by sundaqiang</a>]])
s=m:section(TypedSection,"easyupdate")
s.anonymous=true
e=s:option(Flag, "enable", translate("Enable"),translate("When selected, firmware upgrade will be automatically at the specified time."))
e.default=0
e.optional=false
p=s:option(Value,"mirror",translate("Mirror Url"),translate("Once configured, the mirror URL will be used when accessing Github."))
p.default=''
k= s:option(Flag, "keepconfig", translate("KEEP CONFIG"),translate("When selected, configuration is retained when firmware upgrade."))
k.default=1
k.optional=false
f=s:option(Flag, "forceflash", translate("Preference Force Flashing"),translate("When selected, Preference Force Flashing while firmware upgrading."))
f.default=0
f.optional=false
w=s:option(ListValue,"week",translate("Update Time"),translate("Advised to set the automatic update time to idle time."))
w:value(7,translate("Everyday"))
w:value(1,translate("Monday"))
w:value(2,translate("Tuesday"))
w:value(3,translate("Wednesday"))
w:value(4,translate("Thursday"))
w:value(5,translate("Friday"))
w:value(6,translate("Saturday"))
w:value(0,translate("Sunday"))
w.default=1
w:depends("enable", "1")
h=s:option(Value,"hour",translate("Hour"),translate("Only 0 to 23 can be entered."))
h.datatype="range(0,23)"
h.rmempty=true
h.default=0
h:depends("enable", "1")
n=s:option(Value,"minute",translate("Minute"),translate("Only 0 to 59 can be entered."))
n.datatype="range(0,59)"
n.rmempty=true
n.default=30
n:depends("enable", "1")
g=s:option(Value,"github",translate("Github Url"),translate("Your Github project address."))
g.default=''
g.rmempty=false
l=s:option(TextValue,"",translate("Log"))
l.rmempty = true
l.rows = 15
function l.cfgvalue()
return fs.readfile("/tmp/easyupdatemain.log") or ""
end
l.readonly="readonly"
b=s:option(Button,"",translate("Firmware Upgrade"))
b.template="easyupdate/button"
b.versions=_G.DISTRIB_VERSIONS
local apply = luci.http.formvalue("cbi.apply")
if apply then
local enable = luci.http.formvalue("cbid.easyupdate.main.enable")
crontabs=fs.readfile("/etc/crontabs/root")
if enable then
crontabs=crontabs:gsub('[%d%* ]+/usr/bin/easyupdate%.sh %-u # EasyUpdate\n', '')
if crontabs:sub(-1) == '\n' then
n=''
else
n='\n'
end
local week = luci.http.formvalue("cbid.easyupdate.main.week")
if week == '7' then
week='*'
end
local hour = luci.http.formvalue("cbid.easyupdate.main.hour")
local minute = luci.http.formvalue("cbid.easyupdate.main.minute")
crontabs=crontabs .. n .. minute .. ' ' .. hour .. ' ' .. '* * ' .. week .. ' /usr/bin/easyupdate.sh -u # EasyUpdate\n'
else
crontabs=crontabs:gsub('[%d%* ]+/usr/bin/easyupdate%.sh %-u # EasyUpdate\n', '')
end
fs.writefile ("/etc/crontabs/root", crontabs)
end
return m
@@ -0,0 +1,200 @@
<%+cbi/valueheader%>
<input class="cbi-button cbi-input-reload" id="update" type="button" value="<%:Collecting data...%>" size="0" disabled onclick="check_version()">
<br>
<div class="cbi-value-description">
<span class="cbi-value-helpicon"><img src="/luci-static/resources/cbi/help.gif" alt="帮助"></span>
<span>
<%:Local Firmware Version%>:<%=self.versions%>
</span>
<br>
<span class="cbi-value-helpicon"><img src="/luci-static/resources/cbi/help.gif" alt="帮助"></span>
<span id="cloudver">
<%:Cloud Firmware Version%>:<%:Collecting data...%>
</span>
</div>
<%+cbi/valuefooter%>
<style type="text/css">
#update_apply_overlay {
white-space: pre-line;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
display: none;
z-index: 20000;
}
#update_apply_overlay .alert-message {
overflow: auto;
position: relative;
top: 10%;
width: 60%;
margin: auto;
display: flex;
flex-wrap: wrap;
min-height: 10%;
align-items: center;
max-height: 80%;
}
#update_apply_overlay .alert-message > h4,
#update_apply_overlay .alert-message > p,
#update_apply_overlay .alert-message > div {
flex-basis: 100%;
}
#update_apply_overlay .alert-message > img {
margin-right: 1em;
flex-basis: 32px;
}
body.apply-overlay-active {
overflow: hidden;
height: 100vh;
}
body.apply-overlay-active #update_apply_overlay {
display: block;
}
.cbi-input-textarea {
width: 45VW!important;
}
</style>
<script type="text/javascript">
function update_status_message(type, content) {
document.getElementById('update_apply_overlay') || document.body.insertAdjacentHTML("beforeend",'<div id="update_apply_overlay"><div class="alert-message"></div></div>')
var overlay = document.getElementById('update_apply_overlay')
message = overlay.querySelector('.alert-message');
if (message && type) {
if (!message.classList.contains(type)) {
message.classList.remove('notice');
message.classList.remove('warning');
message.classList.add(type);
}
if (content)
message.innerHTML = content;
message.scrollTop = message.scrollHeight;
document.body.classList.add('apply-overlay-active');
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
else {
document.body.classList.remove('apply-overlay-active');
}
}
function getver() {
XHR.get('<%=url([[admin]], [[services]], [[easyupdate]], [[getver]])%>', null,
function(x, data) {
const tb = document.getElementById('cloudver');
const up = document.getElementById('update');
if (data && tb) {
if (data.newver) {
tb.innerHTML = '<%:Cloud Firmware Version%>:' + data.newver;
nowverint=<%=os.time({day=self.versions:sub(7,8), month=self.versions:sub(5,6), year=self.versions:sub(1,4), hour=self.versions:sub(10,11), min=self.versions:sub(12,13), sec=self.versions:sub(14,15)})%>
if (data.newverint > nowverint){
up.value = '<%:Download Firmware%>'
up.disabled = false
up.setAttribute('newver', data.newver);
}else{
up.value = '<%:Is the latest%>'
up.disabled = true
}
}else{
tb.innerHTML = '<%:Cloud Firmware Version%>:<%:Collecting data...%>';
up.value = '<%:Retry Firmware Check%>'
up.disabled = false
}
}
}
);
XHR.get('<%=url([[admin]], [[services]], [[easyupdate]], [[check]])%>', {file: ''}, (x, r) => {
if (r.code == 1 && r.data.indexOf("OK") > -1) {
const tb = document.getElementById('update');
tb.setAttribute('file', r.data.slice(0,r.data.indexOf(".img.gz")) + ".img.gz");
tb.value = '<%:Firmware Upgrade%>'
tb.setAttribute('flash', 1);
}
});
}
getver()
function check_version() {
const tb = document.getElementById('update');
const flash= tb.getAttribute("flash")
if (flash){
XHR.get('<%=url([[admin]], [[services]], [[easyupdate]], [[flash]])%>', {file: tb.getAttribute("file")}, (x, r) => {
if (r.code == 1) {
XHR.poll(1, '<%=url([[admin]], [[services]], [[easyupdate]], [[getlog]])%>', null,(x, r) => {
update_status_message('notice', r.data);
if (r.data.indexOf("Image check failed.") > -1){
XHR.halt()
update_status_message('warning', r.data);
document.getElementById('update_apply_overlay').addEventListener("click", (e)=>{
update_status_message()
})
}else{
if (r.data.indexOf("Commencing upgrade") > -1 ){
XHR.halt()
setTimeout(() => {
location.replace(document.location.origin)
},180000);
}else{
update_status_message('notice', r.data);
}
}
})
} else {
tb.disabled = false;
tb.value = '<%:Retry Firmware Upgrade%>';
}
});
return
}
const newver= tb.getAttribute("newver")
if (newver){
tb.disabled = true;
XHR.get('<%=url([[admin]], [[services]], [[easyupdate]], [[download]])%>', null, (x, r) => {
if (r.code == 1) {
tb.setAttribute('file', r.data);
XHR.poll(1, '<%=url([[admin]], [[services]], [[easyupdate]], [[getlog]])%>', null,(x, r) => {
if (r.data.indexOf("transfer closed") > -1 || r.data.indexOf("Could not resolve host") > -1){
XHR.halt()
update_status_message('warning', r.data);
document.getElementById('update_apply_overlay').addEventListener("click", (e)=>{
update_status_message()
})
}else{
if (/100\s.+M\s+100.+--:--:--/.test(r.data)){
XHR.get('<%=url([[admin]], [[services]], [[easyupdate]], [[check]])%>', {file: tb.getAttribute("file")}, (x, r) => {
XHR.halt()
if (r.code == 1 && r.data.indexOf("OK") > -1) {
setTimeout(() => {
update_status_message();
tb.value = '<%:Firmware Upgrade%>'
tb.setAttribute('flash', 1);
},3000);
}else{
update_status_message('warning', r.data);
document.getElementById('update_apply_overlay').addEventListener("click", (e)=>{
update_status_message()
})
}
});
}else{
update_status_message('notice', r.data);
}
}
tb.disabled = false;
})
} else {
tb.disabled = false;
tb.value = '<%:Retry Firmware Download%>';
}
});
}else{
getver()
}
}
</script>
@@ -0,0 +1,80 @@
msgid "EasyUpdate"
msgstr "简易更新"
msgid "EasyUpdate LUCI supports scheduled upgrade & one-click firmware upgrade."
msgstr "EasyUpdate 支持LUCI定时升级和一键式固件升级"
msgid "Update may cause the restart failure, Exercise caution when selecting automatic update."
msgstr "升级可能导致重启失败,请谨慎选择自动升级"
msgid "When selected, firmware upgrade will be automatically at the specified time."
msgstr "选中后,系统将在指定的时间自动升级固件。"
msgid "Mirror Url"
msgstr "镜像网址"
msgid "Once configured, the mirror URL will be used when accessing Github."
msgstr "配置后,在访问Github时将使用镜像网址。"
msgid "KEEP CONFIG"
msgstr "保留配置"
msgid "When selected, configuration is retained when firmware upgrade."
msgstr "选中后,固件升级时配置将保留。"
msgid "Preference Force Flashing"
msgstr "强制刷入"
msgid "When selected, Preference Force Flashing while firmware upgrading."
msgstr "选中时,升级固件时将强制刷入。"
msgid "Update Time"
msgstr "更新时机"
msgid "Advised to set the automatic update time to idle time."
msgstr "建议将自动更新时间设置为空闲时间。"
msgid "Everyday"
msgstr "每天"
msgid "Hour"
msgstr "小时"
msgid "Only 0 to 23 can be entered."
msgstr "只能输入0 ~ 23"
msgid "Minute"
msgstr "分钟"
msgid "Only 0 to 59 can be entered."
msgstr "只能输入0 ~ 59"
msgid "Github Url"
msgstr "Github网址"
msgid "Your Github project address."
msgstr "你的Github项目地址"
msgid "Firmware Upgrade"
msgstr "固件升级"
msgid "Local Firmware Version"
msgstr "本地的固件版本"
msgid "Cloud Firmware Version"
msgstr "云端的固件版本"
msgid "Download Firmware"
msgstr "下载固件"
msgid "Is the latest"
msgstr "已是最新"
msgid "Retry Firmware Check"
msgstr "重试固件检查"
msgid "Retry Firmware Upgrade"
msgstr "重试固件升级"
msgid "Retry Firmware Download"
msgstr "重试固件下载"
+1
View File
@@ -0,0 +1 @@
zh-cn
@@ -0,0 +1,2 @@
config easyupdate 'main'
option enable '0'
@@ -0,0 +1,19 @@
#!/bin/sh
[ ! -f "/usr/share/ucitrack/luci-app-easyupdate.json" ] && {
cat > /usr/share/ucitrack/luci-app-easyupdate.json << EEOF
{
"config": "easyupdate",
"init": "easyupdate"
}
EEOF
}
uci -q batch <<-EOF >/dev/null
delete ucitrack.@easyupdate[-1]
add ucitrack easyupdate
set ucitrack.@easyupdate[-1].init=easyupdate
commit ucitrack
EOF
rm -f /tmp/luci-indexcache
exit 0
+186
View File
@@ -0,0 +1,186 @@
#!/bin/bash
# https://github.com/sundaqiang/openwrt-packages
# EasyUpdate for Openwrt
function checkEnv() {
if !type sysupgrade >/dev/null 2>&1; then
writeLog 'Your firmware does not contain sysupgrade and does not support automatic updates(您的固件未包含sysupgrade,暂不支持自动更新)'
exit
fi
}
function writeLog() {
now_time='['$(date +"%Y-%m-%d %H:%M:%S")']'
echo ${now_time} $1 | tee -a '/tmp/easyupdatemain.log'
}
function shellHelp() {
checkEnv
cat <<EOF
Openwrt-EasyUpdate Script by sundaqiang
Your firmware already includes Sysupgrade and supports automatic updates(您的固件已包含sysupgrade,支持自动更新)
参数:
-c Get the cloud firmware version(获取云端固件版本)
-d Download cloud Firmware(下载云端固件)
-f filename Flash firmware(刷写固件)
-u One-click firmware update(一键更新固件)
EOF
}
function getCloudVer() {
checkEnv
github=$(uci get easyupdate.main.github)
github=(${github//// })
curl "https://api.github.com/repos/${github[2]}/${github[3]}/releases/latest" | jsonfilter -e '@.tag_name' | sed -e 's/OpenWrt_//'
}
function downCloudVer() {
checkEnv
writeLog 'Get github project address(读取github项目地址)'
github=$(uci get easyupdate.main.github)
writeLog "Github project address(github项目地址):$github"
github=(${github//// })
writeLog 'Check whether EFI firmware is available(判断是否EFI固件)'
if [ -d "/sys/firmware/efi/" ]; then
suffix="combined-efi.img.gz"
else
suffix="combined.img.gz"
fi
writeLog "Whether EFI firmware is available(是否EFI固件):$suffix"
writeLog 'Get the cloud firmware link(获取云端固件链接)'
url=$(curl "https://api.github.com/repos/${github[2]}/${github[3]}/releases/latest" | jsonfilter -e '@.assets[*].browser_download_url' | sed -n "/$suffix/p")
writeLog "Cloud firmware link(云端固件链接):$url"
mirror=$(uci get easyupdate.main.mirror)
writeLog "Use mirror URL(使用镜像网站):$mirror"
fileName=(${url//// })
curl -o "/tmp/${fileName[7]}-sha256" -L "$mirror${url/${fileName[7]}/sha256sums}"
curl -o "/tmp/${fileName[7]}" -L "$mirror$url" >/tmp/easyupdate.log 2>&1 &
writeLog 'Start downloading firmware, log output in /tmp/easyupdate.log(开始下载固件,日志输出在/tmp/easyupdate.log)'
}
function flashFirmware() {
checkEnv
if [[ -z "$file" ]]; then
writeLog 'Please specify the file name(请指定文件名)'
else
writeLog 'Get whether to save the configuration(读取是否保存配置)'
keepconfig=$(uci get easyupdate.main.keepconfig)
if [ $keepconfig -eq 1 ]; then
keepconfig=' '
res='yes'
else
keepconfig='-n '
res='no'
fi
writeLog "Whether to save the configuration(读取是否保存配置):$res"
writeLog 'Start flash firmware, log output in /tmp/easyupdate.log(开始刷写固件,日志输出在/tmp/easyupdate.log)'
sysupgrade $keepconfig$file >/tmp/easyupdate.log 2>&1 &
fi
}
function checkSha() {
if [[ -z "$file" ]]; then
for filename in $(ls /tmp)
do
if [[ "${filename#*.}" = "img.gz" && "${filename:0:7}" = "openwrt" ]]; then
file=$filename
fi
done
fi
cd /tmp && sha256sum -c <(grep $file $file-sha256)
}
function updateCloud() {
checkEnv
writeLog 'Get the local firmware version(获取本地固件版本)'
lFirVer=$(cat /etc/openwrt_release | sed -n "s/DISTRIB_VERSIONS='\(.*\)'/\1/p")
writeLog "Local firmware version(本地固件版本):$lFirVer"
writeLog 'Get the cloud firmware version(获取云端固件版本)'
cFirVer=$(getCloudVer)
writeLog "Cloud firmware version(云端固件版本):$cFirVer"
lFirVer=$(date -d "${lFirVer:0:4}-${lFirVer:4:2}-${lFirVer:6:2} ${lFirVer:9:2}:${lFirVer:11:2}:${lFirVer:13:2}" +%s)
cFirVer=$(date -d "${cFirVer:0:4}-${cFirVer:4:2}-${cFirVer:6:2} ${cFirVer:9:2}:${cFirVer:11:2}:${cFirVer:13:2}" +%s)
if [ $cFirVer -gt $lFirVer ]; then
writeLog 'Need to be updated(需要更新)'
checkShaRet=$(checkSha)
if [[ $checkShaRet =~ 'OK' ]]; then
writeLog 'Check completes(检查完成)'
file=${checkShaRet:0:-4}
flashFirmware
else
downCloudVer
i=0
while [ $i -le 100 ]; do
log=$(cat /tmp/easyupdate.log)
str='transfer closed'
if [[ $log =~ $str ]]; then
writeLog 'Download error(下载出错)'
i=101
break
else
str='Could not resolve host'
if [[ $log =~ $str ]]; then
writeLog 'Download error(下载出错)'
i=101
break
else
str='100\s.+M\s+100.+--:--:--'
if [[ $log =~ $str ]]; then
writeLog 'Download completes(下载完成)'
i=100
break
else
echo $log | sed -n '$p'
if [[ $i -eq 99 ]]; then
writeLog 'Download the timeout(下载超时)'
break
fi
fi
fi
fi
let i++
sleep 3
done
if [[ $i -eq 100 ]]; then
writeLog 'Prepare flash firmware(准备刷写固件)'
checkShaRet=$(checkSha)
if [[ $checkShaRet =~ 'OK' ]]; then
writeLog 'Check completes(检查完成)'
file=${checkShaRet:0:-4}
flashFirmware
else
writeLog 'Check error(检查出错)'
fi
fi
fi
else
writeLog "Is the latest(已是最新)"
fi
}
if [[ -z "$1" ]]; then
shellHelp
else
case $1 in
-c)
getCloudVer
;;
-d)
downCloudVer
;;
-f)
file=$2
flashFirmware
;;
-k)
file=$2
checkSha
;;
-u)
updateCloud
;;
*)
shellHelp
;;
esac
fi
@@ -0,0 +1,11 @@
{
"luci-app-easyupdate": {
"description": "Grant UCI access for luci-app-easyupdate",
"read": {
"uci": [ "easyupdate" ]
},
"write": {
"uci": [ "easyupdate" ]
}
}
}