1
0
mirror of https://github.com/kenzok8/small-package synced 2025-09-18 18:51:16 +08:00

update-12.04

This commit is contained in:
github-actions[bot]
2021-12-04 09:01:13 +08:00
parent d9bed163f5
commit 96e6f38956
110 changed files with 14091 additions and 382 deletions

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
LUCI_PKGARCH:=all
PKG_VERSION:=1.0
PKG_RELEASE:=20211125
PKG_MAINTAINER:=sundaqiang
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -0,0 +1,61 @@
# luci-app-easyupdate<74><65><EFBFBD><EFBFBD><EFBFBD>׸<EFBFBD><D7B8>£<EFBFBD>
<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD>P3TERX/Actions-OpenWrt<72>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̼<EFBFBD><CCBC><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
### ʹ<>÷<EFBFBD><C3B7><EFBFBD>
#### <20><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
```yaml
- name: Install feeds
run: cd openwrt && ./scripts/feeds install -a -f
```
#### <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>²<EFBFBD><C2B2><EFBFBD>
```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
```
#### <20><><EFBFBD><EFBFBD><EFBFBD>²<EFBFBD><C2B2><EFBFBD><EFBFBD><EFBFBD>`tag_name`<60><>ֵ`${{ 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 }}/*
```
#### <20><><EFBFBD><EFBFBD>Ϊ`${{ 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 }}/*
```
#### Ҳ<><D2B2><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD>޸ĺõ<C4BA>actions
[Actions-OpenWrt](https://github.com/sundaqiang/Actions-OpenWrt)
### Ч<><D0A7>չʾ
![easyupdate][1]
[1]: https://raw.githubusercontent.com/sundaqiang/openwrt-packages/master/img/easyupdate.png

View File

@ -0,0 +1,116 @@
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", "proxy") then
r=1
c:set("easyupdate", "main", "proxy", "1")
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", "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={}
local c=luci.model.uci.cursor()
local l=Split(c:get("easyupdate", "main", "github"), "/")
e.newver=luci.sys.exec("uclient-fetch -qO- 'https://api.github.com/repos/" .. l[4] .. "/" .. l[5] .. "/releases/latest' | jsonfilter -e '@.tag_name'")
e.newver=e.newver:sub(e.newver:find('_')+1,-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={}
local c=luci.model.uci.cursor()
local l=Split(c:get("easyupdate", "main", "github"), "/")
local sedd
if nixio.fs.access("/sys/firmware/efi") then
sedd="combined-efi.img.gz"
else
sedd="combined.img.gz"
end
local url=luci.sys.exec("uclient-fetch -qO- 'https://api.github.com/repos/" .. l[4] .. "/" .. l[5] .. "/releases/latest' | jsonfilter -e '@.assets[*].browser_download_url' | sed -n '/" .. sedd .. "/p'")
url=url:gsub("\n","")
local u=c:get("easyupdate", "main", "proxy")
if u then
u="https://ghproxy.com/"
else
u=""
end
local l=Split(url, "/")
luci.sys.exec("uclient-fetch -O '/tmp/" .. l[9] .. "' '" .. u .. url .. "' > /tmp/easyupdate.log 2>&1 &")
e.code=1
e.data=l[9]
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
function getlog()
local e = {}
e.data=nixio.fs.readfile ("/tmp/easyupdate.log")
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
function flash()
local e={}
local f = luci.http.formvalue('file')
local c=luci.model.uci.cursor()
local k=c:get("easyupdate", "main", "keepconfig")
if k then
k=""
else
k="-n"
end
luci.sys.exec("sysupgrade " .. k .. " '/tmp/" .. f .. "' > /tmp/easyupdate.log 2>&1 &")
e.code=1
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end

View File

@ -0,0 +1,57 @@
local pcall, dofile, _G = pcall, dofile, _G
pcall(dofile, "/etc/openwrt_release")
m=Map("easyupdate",translate("EasyUpdate"),translate("EasyUpdate LUCI supports scheduled upgrade & one-click firmware upgrade") .. [[<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(Flag, "proxy", translate("Use China Mirror"),translate("When selected, will use the China mirror when accessing Github."))
p.default=1
p.optional=false
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=0
w:depends("enable", "1")
h=s:option(Value,"hour",translate("Hour"))
h.datatype="range(0,23)"
h.rmempty=true
h.default=0
h:depends("enable", "1")
n=s:option(Value,"minute",translate("Minute"))
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
b=s:option(Button,"",translate("Firmware Upgrade"))
b.template="easyupdate/button"
b.versions=_G.DISTRIB_VERSIONS
return m

View File

@ -0,0 +1,168 @@
<%+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;
}
</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
}
}
}
);
}
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("Commencing upgrade") > -1 ){
XHR.halt()
setTimeout(() => {
location.replace(document.location.origin)
},180000);
}
})
} 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(" error") > -1 || r.data.indexOf("Connection reset") > -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("Download completed") > -1 ){
XHR.halt()
setTimeout(() => {
update_status_message();
tb.value = '<%:Firmware Upgrade%>'
tb.setAttribute('flash', 1);
},3000);
}else{
update_status_message('notice', r.data);
}
}
tb.disabled = false;
})
} else {
tb.disabled = false;
tb.value = '<%:Retry Firmware Download%>';
}
});
}else{
getver()
}
}
</script>

View File

@ -0,0 +1,68 @@
msgid "EasyUpdate"
msgstr "简易更新"
msgid "EasyUpdate LUCI supports scheduled upgrade & one-click firmware upgrade"
msgstr "EasyUpdate 支持LUCI定时升级和一键式固件升级"
msgid "When selected, firmware upgrade will be automatically at the specified time."
msgstr "选中后,系统将在指定的时间自动升级固件。"
msgid "When selected, will use the China mirror 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 "Minute"
msgstr "分钟"
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 "重试固件下载"

View File

@ -0,0 +1 @@
zh-cn

View File

@ -0,0 +1,2 @@
config easyupdate 'main'
option enable '0'

View File

@ -0,0 +1,11 @@
#!/bin/sh
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

View File

@ -0,0 +1,11 @@
{
"luci-app-easyupdate": {
"description": "Grant UCI access for luci-app-easyupdate",
"read": {
"uci": [ "easyupdate" ]
},
"write": {
"uci": [ "easyupdate" ]
}
}
}