From 6b23c6ef894760bea3a43b1360b02cd130c6874b Mon Sep 17 00:00:00 2001 From: Hyy2001X <1804430051@qq.com> Date: Thu, 1 Jul 2021 22:39:50 +0800 Subject: [PATCH] =?UTF-8?q?V6.3.1=20=E6=96=B0=E5=A2=9E=E5=8F=82=E6=95=B0?= =?UTF-8?q?=20--skip=20=E8=B7=B3=E8=BF=87=E6=9C=AC=E5=9C=B0=E5=9B=BA?= =?UTF-8?q?=E4=BB=B6=20SHA256=20=E9=AA=8C=E8=AF=81=20(=E5=8D=B1=E9=99=A9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/AutoUpdate.sh | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/Scripts/AutoUpdate.sh b/Scripts/AutoUpdate.sh index e7ab05d..c8c1677 100755 --- a/Scripts/AutoUpdate.sh +++ b/Scripts/AutoUpdate.sh @@ -37,6 +37,7 @@ SHELL_HELP() { -L,--list 打印当前系统信息 -U 仅检查版本更新 -F 强制刷写固件 + --skip 跳过固件 SHA256 比对校验 (危险) --corn-rm 删除所有 AutoUpdate 定时任务 --bak 备份 Openwrt 配置文件到用户指定的目录 --clean 清理固件下载缓存 @@ -150,7 +151,7 @@ RANDOM() { GET_SHA256SUM() { [[ ! -f $1 && ! -s $1 ]] && { - ECHO r "未检测到文件: [$1] 或该文件为空,无法计算 sha256 值!" + ECHO r "未检测到文件: [$1] 或该文件为空,无法计算 SHA256 值!" EXIT 1 } sha256sum $1 | cut -c1-$2 @@ -385,6 +386,10 @@ PREPARE_UPGRADES() { ECHO g "自定义固件保存目录: ${AutoUpdate_Path}" } [[ $1 == -F ]] && Only_Force_Write=1 + [[ $1 == --skip ]] && { + Skip_SHA256=1 + MSG_3=" [跳过验证]" + } case "$1" in -n | -f | -u) Option="$1" @@ -417,7 +422,7 @@ PREPARE_UPGRADES() { MSG_2=" [强制刷写]" Upgrade_Option="${Upgrade_Option} -F" } - ECHO g "执行: ${Proxy_Echo}${MSG}${MSG_1}${MSG_2}" + ECHO g "执行: ${Proxy_Echo}${MSG}${MSG_1}${MSG_2}${MSG_3}" if [[ $(CHECK_PKG curl) == true && ${Proxy_Mode} != 1 ]];then Google_Check=$(curl -I -s --connect-timeout 3 google.com -w %{http_code} | tail -n1) [[ ${Google_Check} != 301 ]] && { @@ -482,21 +487,23 @@ EOF Retry_Times=$((${Retry_Times} - 1)) ECHO r "固件下载失败,剩余尝试次数: ${Retry_Times} 次" done - CURRENT_SHA256=$(GET_SHA256SUM ${AutoUpdate_Path}/${FW_Name} 5) - CLOUD_SHA256=$(echo ${FW_Name} | egrep -o "[0-9a-z]+.${Firmware_Type}" | sed -r "s/(.*).${Firmware_Type}/\1/") - [[ ${CURRENT_SHA256} != ${CLOUD_SHA256} ]] && { - ECHO r "本地固件 SHA256 与云端对比不通过,请检查网络后重试!" - EXIT 1 - } + if [[ ! ${Skip_SHA256} == 1 ]];then + CURRENT_SHA256=$(GET_SHA256SUM ${AutoUpdate_Path}/${FW_Name} 5) + CLOUD_SHA256=$(echo ${FW_Name} | egrep -o "[0-9a-z]+.${Firmware_Type}" | sed -r "s/(.*).${Firmware_Type}/\1/") + [[ ${CURRENT_SHA256} != ${CLOUD_SHA256} ]] && { + ECHO r "本地固件 SHA256 与云端比对校验失败 [${CURRENT_SHA256}],请检查网络后重试!" + EXIT 1 + } + fi case "${Firmware_Type}" in img.gz) ECHO "正在解压固件,请耐心等待 ..." gzip -d -q -f -c ${AutoUpdate_Path}/${FW_Name} > ${AutoUpdate_Path}/$(echo ${FW_Name} | sed -r 's/(.*).gz/\1/') - FW_Name="$(echo ${FW_Name} | sed -r 's/(.*).gz/\1/')" [[ $? != 0 ]] && { - ECHO r "固件解压失败,请检查相关依赖或更换固件保存目录!" + ECHO r "固件解压失败,请检查固件完整性或更换固件保存目录!" EXIT 1 } || { + FW_Name="$(echo ${FW_Name} | sed -r 's/(.*).gz/\1/')" ECHO "固件解压成功,固件已解压到: ${AutoUpdate_Path}/${FW_Name}" } ;; @@ -578,6 +585,7 @@ AutoUpdate_Main() { [[ -z $* ]] && PREPARE_UPGRADES $* [[ $1 =~ path= && ! $* =~ -x && ! $* =~ -U ]] && PREPARE_UPGRADES $* + [[ $1 =~ --skip ]] && PREPARE_UPGRADES $* [[ $* =~ -T || $* =~ --test ]] && Downloader="$(echo ${Downloader} | sed -r 's/-q /\1/')" while [[ $1 ]];do @@ -730,7 +738,7 @@ AutoUpdate_Main() { done } -Version=V6.3.0 +Version=V6.3.1 AutoUpdate_Path=/tmp/AutoUpdate AutoUpdate_Log_Path=/tmp AutoUpdate_Script_URL=https://ghproxy.com/https://raw.githubusercontent.com/Hyy2001X/AutoBuild-Actions/master/Scripts/AutoUpdate.sh