From 8febfc15d24fa7d9e414557720a5b8a601079dda Mon Sep 17 00:00:00 2001 From: zhao Date: Mon, 31 Mar 2025 11:46:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20bin/=20ZeroWrt.backup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhao --- bin/ ZeroWrt.backup | 167 ++------------------------------------------ 1 file changed, 4 insertions(+), 163 deletions(-) diff --git a/bin/ ZeroWrt.backup b/bin/ ZeroWrt.backup index 026a9bb..eab10d4 100644 --- a/bin/ ZeroWrt.backup +++ b/bin/ ZeroWrt.backup @@ -48,9 +48,8 @@ show_menu() { color_output "\e[36m┃\e[0m 6. 一键设置 \e[36m┃\e[0m" color_output "\e[36m┃\e[0m 7. 一键部署 \e[36m┃\e[0m" color_output "\e[36m┃\e[0m 8. IPv6 开关 (仅适用于主路由) \e[36m┃\e[0m" - color_output "\e[36m┃\e[0m 9. iStoreOS 风格化 \e[36m┃\e[0m" - color_output "\e[36m┃\e[0m 10. 固件更新 \e[36m┃\e[0m" - color_output "\e[36m┃\e[0m 11. 检测更新 \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 9. iStoreOS 风格化 \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 10. 检测更新 \e[36m┃\e[0m" color_output "\e[36m┃\e[0m 0. 退出 \e[36m┃\e[0m" color_output "\e[36m┃ ┃\e[0m" color_output "\e[36m┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\e[0m" @@ -65,8 +64,7 @@ show_menu() { 7) install_apps ;; 8) configure_ipv6 ;; 9) istore_style ;; - 10) firmware_update ;; - 11) check_update ;; + 10) check_update ;; 0) exit 0 ;; *) echo "无效选项,请重新输入"; show_menu ;; esac @@ -905,164 +903,7 @@ istore_style() { show_menu } -# 10. 固件更新 (精确匹配版) -firmware_update() { - color_output "\e[34m[固件更新]\e[0m" - color_output "\e[33m警告:此操作将下载并更新固件,可能导致设备重启!\e[0m" - - # 使用镜像源解决国内访问问题 - local api_url="https://ghproxy.com/https://api.github.com/repos/oppen321/ZeroWrt-Action/releases/latest" - - # 设备检测 - local current_model=$(cat /tmp/sysinfo/model 2>/dev/null || echo "unknown") - local current_board=$(cat /tmp/sysinfo/board_name 2>/dev/null || echo "unknown") - local current_firmware=$(cat /etc/openwrt_release | grep "DISTRIB_DESCRIPTION" | cut -d"'" -f2) - - # 精确的固件匹配规则 (基于您的命名格式) - declare -A supported_devices=( - ["nanopi-r2c"]="ZeroWrt-Super-[0-9]*-[0-9.]*-friendlyarm_nanopi-r2c-squashfs-sysupgrade.img.gz" - ["nanopi-r2c-plus"]="ZeroWrt-Super-[0-9]*-[0-9.]*-friendlyarm_nanopi-r2c-plus-squashfs-sysupgrade.img.gz" - ["nanopi-r2s"]="ZeroWrt-Super-[0-9]*-[0-9.]*-friendlyarm_nanopi-r2s-squashfs-sysupgrade.img.gz" - ["nanopi-r3s"]="ZeroWrt-Super-[0-9]*-[0-9.]*-friendlyarm_nanopi-r3s-squashfs-sysupgrade.img.gz" - ["nanopi-r4s"]="ZeroWrt-Super-[0-9]*-[0-9.]*-friendlyarm_nanopi-r4s-squashfs-sysupgrade.img.gz" - ["nanopi-r4se"]="ZeroWrt-Super-[0-9]*-[0-9.]*-friendlyarm_nanopi-r4se-squashfs-sysupgrade.img.gz" - ["nanopi-r5c"]="ZeroWrt-Super-[0-9]*-[0-9.]*-friendlyarm_nanopi-r5c-squashfs-sysupgrade.img.gz" - ["nanopi-r5s"]="ZeroWrt-Super-[0-9]*-[0-9.]*-friendlyarm_nanopi-r5s-squashfs-sysupgrade.img.gz" - ["nanopi-r6c"]="ZeroWrt-Super-[0-9]*-[0-9.]*-friendlyarm_nanopi-r6c-squashfs-sysupgrade.img.gz" - ["nanopi-r6"]="ZeroWrt-Super-[0-9]*-[0-9.]*-friendlyarm_nanopi-r6-squashfs-sysupgrade.img.gz" - ["fastrhino-r66s"]="ZeroWrt-Super-[0-9]*-[0-9.]*-lunzn_fastrhino-r66s-squashfs-sysupgrade.img.gz" - ["fastrhino-r68s"]="ZeroWrt-Super-[0-9]*-[0-9.]*-lunzn_fastrhino-r68s-squashfs-sysupgrade.img.gz" - ) - - # 显示设备信息 - color_output "\e[36m设备信息:\e[0m" - color_output " 型号: $current_model" - color_output " 主板: $current_board" - color_output " 当前固件: $current_firmware" - - # 设备检测函数 - detect_device() { - for dev in "${!supported_devices[@]}"; do - if [[ $current_board == *"$dev"* ]] || [[ $current_model == *"$dev"* ]]; then - echo "$dev" - return - fi - done - echo "" - } - - local device_type=$(detect_device) - if [ -z "$device_type" ]; then - color_output "\e[31m错误:无法识别设备类型\e[0m" - color_output "\e[33m支持的设备类型:\e[0m" - for dev in "${!supported_devices[@]}"; do - color_output "- $dev" - done - read -p "按 Enter 键返回菜单..." - show_menu - return - fi - - color_output "\e[32m检测到设备类型: $device_type\e[0m" - - # 获取固件信息 - color_output "\e[33m正在获取固件信息...\e[0m" - local release_info=$(curl -s "$api_url" || { - color_output "\e[31m无法获取发布信息,尝试备用镜像...\e[0m" - curl -s "https://fastgit.xyz/https://api.github.com/repos/oppen321/ZeroWrt-Action/releases/latest" - }) - - local latest_date=$(echo "$release_info" | grep "created_at" | head -1 | cut -d'"' -f4 | cut -d'T' -f1 | sed 's/-//g') - local assets=$(echo "$release_info" | grep -E "browser_download_url|name" | awk -F'"' '{print $4}') - - # 精确匹配固件文件 - local pattern=${supported_devices[$device_type]} - local latest_url="" - while read -r line; do - if [[ $line == *"download"* ]] && [[ $line =~ $pattern ]]; then - latest_url=$line - break - fi - done <<< "$assets" - - if [ -z "$latest_url" ]; then - color_output "\e[31m错误:找不到匹配的固件文件\e[0m" - color_output "\e[33m搜索模式: $pattern\e[0m" - color_output "\e[33m可用的下载文件:\e[0m" - echo "$assets" | grep "download" | sed 's/.*\///' | while read -r line; do - color_output " - $line" - done - read -p "按 Enter 键返回菜单..." - show_menu - return - fi - - # 提取当前固件日期 - local current_date=$(echo "$current_firmware" | grep -oE "202[0-9]{5}" || echo "0") - - # 显示更新信息 - color_output "\e[36m最新固件发布日期: ${latest_date:0:4}-${latest_date:4:2}-${latest_date:6:2}\e[0m" - color_output "\e[36m当前固件发布日期: ${current_date:0:4}-${current_date:4:2}-${current_date:6:2}\e[0m" - color_output "\e[33m下载文件: $(basename "$latest_url")\e[0m" - - if [ "$latest_date" -gt "$current_date" ]; then - color_output "\e[32m发现新版本固件!\e[0m" - - read -p "是否下载并更新固件?(y/n): " confirm - if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then - color_output "\e[32m操作已取消\e[0m" - read -p "按 Enter 键返回菜单..." - show_menu - return - fi - - # 使用镜像源下载 - color_output "\e[33m正在下载固件...\e[0m" - local mirror_url="https://ghproxy.com/$latest_url" - if ! wget --show-progress -O /tmp/firmware.bin "$mirror_url"; then - color_output "\e[31m镜像下载失败,尝试原始链接...\e[0m" - if ! wget --show-progress -O /tmp/firmware.bin "$latest_url"; then - color_output "\e[31m固件下载失败!\e[0m" - read -p "按 Enter 键返回菜单..." - show_menu - return - fi - fi - - # 验证固件 - color_output "\e[33m正在验证固件...\e[0m" - if ! sysupgrade -v /tmp/firmware.bin; then - color_output "\e[31m固件验证失败!\e[0m" - color_output "\e[33m可能原因:\e[0m" - color_output " 1. 文件下载不完整" - color_output " 2. 设备不兼容" - color_output " 3. 固件签名验证失败" - rm -f /tmp/firmware.bin - read -p "按 Enter 键返回菜单..." - show_menu - return - fi - - color_output "\e[31m警告:此操作不可逆!\e[0m" - read -p "确认要刷写固件吗?(y/n): " flash_confirm - if [[ "$flash_confirm" == "y" || "$flash_confirm" == "Y" ]]; then - color_output "\e[33m开始刷写固件,设备将自动重启...\e[0m" - sleep 3 - sysupgrade -n /tmp/firmware.bin - else - color_output "\e[32m操作已取消\e[0m" - rm -f /tmp/firmware.bin - fi - else - color_output "\e[32m当前已是最新固件\e[0m" - color_output "\e[33m当前版本: ${current_date:0:4}-${current_date:4:2}-${current_date:6:2}\e[0m" - fi - - read -p "按 Enter 键返回菜单..." - show_menu -} - -# 11. 检测更新 +# 10. 检测更新 check_update() { color_output "\e[34m[检测更新]\e[0m" color_output "正在检查更新..."