From d632df7d5204a2def593c93f268a6360c1b51b3f Mon Sep 17 00:00:00 2001 From: wukongdaily <2666180@gmail.com> Date: Mon, 22 Jun 2026 08:08:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20curl|sh=20=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E8=BF=90=E8=A1=8C=E6=97=B6=E6=97=A0=E6=B3=95=E6=89=BE?= =?UTF-8?q?=E5=88=B0=E5=AD=90=E8=84=9A=E6=9C=AC=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.sh | 75 +++++++++++++++++++++++++++------------------------------ 1 file changed, 35 insertions(+), 40 deletions(-) diff --git a/main.sh b/main.sh index eb5b1e1..06cf4cc 100755 --- a/main.sh +++ b/main.sh @@ -12,6 +12,7 @@ light_yellow() { echo -e "\033[93m\033[01m$1\033[0m"; } cyan() { echo -e "\033[38;2;0;255;255m$1\033[0m"; } HTTP_HOST="https://cafe.cpolar.cn/wkdaily/gl/raw/branch/main" +SCRIPT_DIR="/tmp/gl-scripts" ##获取软路由型号信息 get_router_name() { @@ -19,6 +20,22 @@ get_router_name() { echo "$model_info" } +## 下载并运行脚本 +download_and_run_script() { + local script_name="$1" + mkdir -p "$SCRIPT_DIR" + local script_path="$SCRIPT_DIR/$script_name" + + green "正在下载 $script_name..." + wget -O "$script_path" "$HTTP_HOST/$script_name" 2>/dev/null || { + red "下载 $script_name 失败" + return 1 + } + chmod +x "$script_path" + green "正在启动 $script_name..." + sh "$script_path" +} + ## 自动检测路由器型号并调用对应脚本 auto_detect_and_run() { gl_name=$(get_router_name) @@ -26,42 +43,33 @@ auto_detect_and_run() { case "$gl_name" in *BE6500* | *be6500*) - green "正在启动 BE6500 脚本..." - sh "$(dirname "$0")/be6500.sh" + download_and_run_script "be6500.sh" ;; *BE3600* | *be3600*) - green "正在启动 BE3600 脚本..." - sh "$(dirname "$0")/be3600.sh" + download_and_run_script "be3600.sh" ;; *MT5000* | *mt5000*) - green "正在启动 MT5000 脚本..." - sh "$(dirname "$0")/mt5000.sh" + download_and_run_script "mt5000.sh" ;; *MT3600* | *mt3600*) - green "正在启动 MT3600 脚本..." - sh "$(dirname "$0")/mt3600.sh" + download_and_run_script "mt3600.sh" ;; *MT-3000* | *mt3000* | *MT3000*) if grep -q "OP24" /etc/openwrt_release 2>/dev/null; then - green "正在启动 MT-3000 OP24 脚本..." - sh "$(dirname "$0")/gl-inet-op24.sh" + download_and_run_script "gl-inet-op24.sh" else - green "正在启动 MT-3000 脚本..." - sh "$(dirname "$0")/gl-inet.sh" + download_and_run_script "gl-inet.sh" fi ;; *MT-6000* | *mt6000* | *MT6000*) if grep -q "OP24" /etc/openwrt_release 2>/dev/null; then - green "正在启动 MT-6000 OP24 脚本..." - sh "$(dirname "$0")/gl-inet-op24.sh" + download_and_run_script "gl-inet-op24.sh" else - green "正在启动 MT-6000 脚本..." - sh "$(dirname "$0")/gl-inet.sh" + download_and_run_script "gl-inet.sh" fi ;; *MT-2500* | *mt2500* | *MT2500*) - green "正在启动 MT-2500A 脚本..." - sh "$(dirname "$0")/gl-inet.sh" + download_and_run_script "gl-inet.sh" ;; *) red "抱歉,暂不支持该机型: $gl_name" @@ -96,41 +104,28 @@ select_model() { case $choice in 1) - sh "$(dirname "$0")/be6500.sh" + download_and_run_script "be6500.sh" ;; 2) - sh "$(dirname "$0")/be3600.sh" + download_and_run_script "be3600.sh" ;; 3) - sh "$(dirname "$0")/mt5000.sh" + download_and_run_script "mt5000.sh" ;; 4) - sh "$(dirname "$0")/mt3600.sh" + download_and_run_script "mt3600.sh" ;; 5 | 6 | 7) - sh "$(dirname "$0")/gl-inet.sh" + download_and_run_script "gl-inet.sh" ;; - 8) - sh "$(dirname "$0")/gl-inet-op24.sh" - ;; - 9) - sh "$(dirname "$0")/gl-inet-op24.sh" + 8 | 9) + download_and_run_script "gl-inet-op24.sh" ;; 10) - if [ -f "$(dirname "$0")/mt-3000/mt3000.sh" ]; then - sh "$(dirname "$0")/mt-3000/mt3000.sh" - else - wget -O "$(dirname "$0")/mt-3000.sh" "$HTTP_HOST/mt-3000/mt3000.sh" && chmod +x "$(dirname "$0")/mt-3000.sh" - sh "$(dirname "$0")/mt-3000.sh" - fi + download_and_run_script "mt-3000/mt3000.sh" ;; 11) - if [ -f "$(dirname "$0")/docker/do_docker.sh" ]; then - sh "$(dirname "$0")/docker/do_docker.sh" - else - wget -O "$(dirname "$0")/do_docker.sh" "$HTTP_HOST/docker/do_docker.sh" && chmod +x "$(dirname "$0")/do_docker.sh" - sh "$(dirname "$0")/do_docker.sh" - fi + download_and_run_script "docker/do_docker.sh" ;; q | Q) echo "退出"