V6.5.8 修复偶现获取固件最新版本错误

This commit is contained in:
Hyy2001X 2021-10-01 12:37:57 +08:00
parent 87a5f73944
commit c081601e55
1 changed files with 18 additions and 11 deletions

View File

@ -3,7 +3,7 @@
# AutoUpdate for Openwrt # AutoUpdate for Openwrt
# Dependences: bash wget-ssl/wget/uclient-fetch curl openssl jsonfilter # Dependences: bash wget-ssl/wget/uclient-fetch curl openssl jsonfilter
Version=V6.5.7 Version=V6.5.8
function TITLE() { function TITLE() {
clear && echo "Openwrt-AutoUpdate Script by Hyy2001 ${Version}" clear && echo "Openwrt-AutoUpdate Script by Hyy2001 ${Version}"
@ -383,7 +383,7 @@ function CHECK_TIME() {
} }
function GET_API() { function GET_API() {
local url name size version local url name date size version
local API_Dump=${Running_Path}/API_Dump local API_Dump=${Running_Path}/API_Dump
[[ $(CHECK_TIME ${API_File} 1) == false ]] && { [[ $(CHECK_TIME ${API_File} 1) == false ]] && {
DOWNLOADER --path ${Running_Path} --file-name API_Dump --dl ${DOWNLOADERS} --url "$(URL_X ${Github_Release}/API G@@1 F@@1) ${Github_API}@@1 " --no-url-name --timeout 3 --type 固件信息 --quiet DOWNLOADER --path ${Running_Path} --file-name API_Dump --dl ${DOWNLOADERS} --url "$(URL_X ${Github_Release}/API G@@1 F@@1) ${Github_API}@@1 " --no-url-name --timeout 3 --type 固件信息 --quiet
@ -396,11 +396,15 @@ function GET_API() {
local i=1;while :;do local i=1;while :;do
url=$(jsonfilter -e '@["assets"]' < ${API_Dump} | jsonfilter -e '@['"""$i"""'].browser_download_url' 2> /dev/null) url=$(jsonfilter -e '@["assets"]' < ${API_Dump} | jsonfilter -e '@['"""$i"""'].browser_download_url' 2> /dev/null)
[[ ! $? == 0 ]] && break [[ ! $? == 0 ]] && break
if [[ ${url} =~ "AutoBuild" || ${url} =~ "${TARGET_PROFILE}" ]]
then
size=$(jsonfilter -e '@["assets"]' < ${API_Dump} | jsonfilter -e '@['"""$i"""'].size' 2> /dev/null) size=$(jsonfilter -e '@["assets"]' < ${API_Dump} | jsonfilter -e '@['"""$i"""'].size' 2> /dev/null)
name=${url##*/} name=${url##*/}
size=$(echo $size | awk '{a=$1/1048576} {printf("%.2f\n",a)}') size=$(echo ${size} | awk '{a=$1/1048576} {printf("%.2f\n",a)}')
version=$(echo $name | egrep -o "R[0-9.]+-[0-9]+") version=$(echo ${name} | egrep -o "R[0-9.]+-[0-9]+")
echo "${name} ${version} ${size}MB ${url}" | grep -v "API" >> ${API_File} date=$(echo ${version} | cut -d '-' -f2)
printf "%-75s %-20s %-10s %-15s %s\n" ${name} ${version} ${date} ${size}MB ${url} >> ${API_File}
fi
i=$(($i + 1)) i=$(($i + 1))
done done
} }
@ -415,10 +419,10 @@ function GET_CLOUD_INFO() {
local Info local Info
[[ ! -f ${API_File} ]] && return [[ ! -f ${API_File} ]] && return
if [[ $1 =~ (All|all|-a) ]];then if [[ $1 =~ (All|all|-a) ]];then
Info=$(grep "AutoBuild-${OP_REPO_NAME}-${TARGET_PROFILE}" ${API_File} | grep "${x86_Boot}" | sort | uniq) Info=$(grep "AutoBuild-${OP_REPO_NAME}-${TARGET_PROFILE}" ${API_File} | grep "${x86_Boot}" | uniq)
shift shift
else else
Info=$(grep "AutoBuild-${OP_REPO_NAME}-${TARGET_PROFILE}" ${API_File} | grep "${x86_Boot}" | sort | uniq | awk 'END {print}') Info=$(grep "AutoBuild-${OP_REPO_NAME}-${TARGET_PROFILE}" ${API_File} | grep "${x86_Boot}" | awk 'BEGIN {MAX = 0} {if ($3+0 > MAX+0) {MAX=$3 ;content=$0} } END {print content}')
fi fi
case "$1" in case "$1" in
name) name)
@ -427,12 +431,15 @@ function GET_CLOUD_INFO() {
version) version)
echo "${Info}" | awk '{print $2}' echo "${Info}" | awk '{print $2}'
;; ;;
size) date)
echo "${Info}" | awk '{print $3}' echo "${Info}" | awk '{print $3}'
;; ;;
url) size)
echo "${Info}" | awk '{print $4}' echo "${Info}" | awk '{print $4}'
;; ;;
url)
echo "${Info}" | awk '{print $5}'
;;
esac esac
} }