From 8bcde7d9c83d6bcbc5464da6ab302e1d01fc5916 Mon Sep 17 00:00:00 2001 From: zhao Date: Fri, 24 Jan 2025 17:08:32 +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 | 110 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 88 insertions(+), 22 deletions(-) diff --git a/bin/ ZeroWrt.backup b/bin/ ZeroWrt.backup index deed3d5..f3b1e10 100644 --- a/bin/ ZeroWrt.backup +++ b/bin/ ZeroWrt.backup @@ -149,19 +149,85 @@ change_source() { color_output "1. 阿里源" color_output "2. 清华源" color_output "3. 中科大源" - color_output "4. 官方源" + color_output "4. 高校联合镜像站" + color_output "5. 南方科技大学" + color_output "6. 官方源" color_output "0. 返回" - read -p "请输入您的选择 [0-4]: " source_choice + read -p "请输入您的选择 [0-6]: " source_choice - case "$source_choice" in - 1) base_url="https://mirrors.aliyun.com/openwrt/releases/24.10.0-rc5/packages/x86_64" ;; - 2) base_url="https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/24.10.0-rc5/packages/x86_64" ;; - 3) base_url="https://mirrors.ustc.edu.cn/openwrt/releases/24.10.0-rc5/packages/x86_64" ;; - 4) base_url="https://downloads.openwrt.org/releases/24.10.0-rc5/packages/x86_64" ;; - 0) show_menu ; return ;; - *) color_output "\e[31m无效选项,返回菜单。\e[0m" ; show_menu ; return ;; + # 检测当前设备架构 + arch=$(uname -m) + + # 针对不同架构的设置 + case "$arch" in + "x86_64") + arch_name="x86_64" + ;; + "i386" | "pentium4") + arch_name="i386_pentium4" + ;; + "aarch64") + arch_name="aarch64_generic" + ;; + "armv7l") + arch_name="arm_cortex-a9" + ;; + "armv6l") + arch_name="arm_arm1176jzf-s_vfp" + ;; + "mips64el") + arch_name="mips64el" + ;; + "mipsel") + arch_name="mipsel_24kc" + ;; + "aarch64_cortex-a72") + arch_name="aarch64_cortex-a72" + ;; + "aarch64_cortex-a53") + arch_name="aarch64_cortex-a53" + ;; + "armv5te") + arch_name="arm_cortex-a5_vfpv4" + ;; + "armv8") + arch_name="arm_cortex-a15_neon-vfpv4" + ;; + *) + color_output "\e[31m不支持此架构:$arch,请选择其他源。\e[0m" + return + ;; esac + # 根据选择的源和架构来设置对应的 base_url + case "$source_choice" in + 1) + base_url="https://mirrors.aliyun.com/openwrt/releases/24.10.0-rc6/packages/$arch_name" + ;; + 2) + base_url="https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/24.10.0-rc6/packages/$arch_name" + ;; + 3) + base_url="https://mirrors.ustc.edu.cn/openwrt/releases/24.10.0-rc6/packages/$arch_name" + ;; + 4) + base_url="https://mirrors.xjtu.edu.cn/openwrt/releases/24.10.0-rc6/packages/$arch_name" + ;; + 5) + base_url="https://mirrors.sustech.edu.cn/openwrt/releases/24.10.0-rc6/packages/$arch_name" + ;; + 6) + base_url="https://downloads.openwrt.org/releases/24.10.0-rc6/packages/$arch_name" + ;; + 0) show_menu ; return ;; + *) + color_output "\e[31m无效选项,返回菜单。\e[0m" + show_menu + return + ;; + esac + + # 更新软件源 cat < /etc/opkg/distfeeds.conf src/gz openwrt_base $base_url/base src/gz openwrt_luci $base_url/luci @@ -331,7 +397,7 @@ install_apps() { color_output "\e[36m┃\e[0m 3. 部署 Subconverter \e[36m┃\e[0m" color_output "\e[36m┃\e[0m 4. 部署 AdGuardhome \e[36m┃\e[0m" color_output "\e[36m┃\e[0m 5. 部署 Gitea-MySQL \e[36m┃\e[0m" - color_output "\e[36m┃\e[0m 6. 部署 SunPanel导航页 \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 6. 部署 SunPanel导航页 \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" @@ -503,7 +569,6 @@ install_apps() { fi # 部署 Gitea 和 MySQL - opkg install docker-compose cd /opt/Gitea docker-compose up -d @@ -515,22 +580,22 @@ install_apps() { read -p "按 Enter 键返回..." ;; 6) - color_output "\e[34m[部署 SunPanel]\e[0m" - + color_output "\e[34m[部署 sun-panel]\e[0m" + # 检查 SunPanel 容器是否已存在 - if docker ps -a | grep -q "sunpanel"; then - color_output "\e[33mSunPanel 已经部署过,跳过部署!\e[0m" + if docker ps -a --filter "name=sun-panel" | grep -q "sun-panel"; then + color_output "\e[33msun-panel 已经部署过,跳过部署!\e[0m" read -p "按 Enter 键返回..." continue fi color_output "\e[33m正在部署 SunPanel...\e[0m" - + # 创建目录 mkdir -p /opt/sunpanel # 下载 Docker Compose 文件到 /opt/sunpanel - curl -L https://git.kejizero.online/zhao/files/raw/branch/main/docker-compose/SunPanel -o /opt/sunpanel/docker-compose.yml + curl -v -L https://git.kejizero.online/zhao/files/raw/branch/main/docker-compose/SunPanel -o /opt/sunpanel/docker-compose.yml # 检查是否下载成功 if [ -f "/opt/sunpanel/docker-compose.yml" ]; then @@ -542,17 +607,18 @@ install_apps() { fi # 部署 SunPanel - opkg install docker-compose + docker-compose up -d cd /opt/sunpanel docker-compose up -d - if docker ps | grep -q "sunpanel"; then - color_output "\e[32mSunPanel 部署成功!\e[0m" + if docker ps | grep -q "sun-panel"; then + color_output "\e[32msun-panel 部署成功!\e[0m" else - color_output "\e[31mSunPanel 部署失败!\e[0m" + color_output "\e[31msun-panel 部署失败!\e[0m" + docker logs $(docker ps -a -q --filter "name=sun-panel") # 查看失败的容器日志 fi read -p "按 Enter 键返回..." - ;; + ;; 0) show_menu return