From 796ef8471774a44b83cde106bf3e959333a6bb8d Mon Sep 17 00:00:00 2001 From: zhao Date: Mon, 21 Apr 2025 17:03:30 +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 | 1389 ++++++++++++++++++++++++------------------- 1 file changed, 789 insertions(+), 600 deletions(-) diff --git a/bin/ ZeroWrt.backup b/bin/ ZeroWrt.backup index eab10d4..224ffb7 100644 --- a/bin/ ZeroWrt.backup +++ b/bin/ ZeroWrt.backup @@ -1,10 +1,107 @@ #!/bin/bash +# 初始化语言变量 +LANG_CHOICE="" +AGREED="no" + # 彩色输出函数 color_output() { echo -e "$1" } +# 显示语言选择菜单 +select_language() { + clear + color_output "\e[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\e[0m" + color_output "\e[36m┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\e[0m" + color_output "\e[36m┃ ┃\e[0m" + color_output "\e[36m┃ \e[33m请选择语言/Select Language\e[36m ┃\e[0m" + color_output "\e[36m┃ ┃\e[0m" + color_output "\e[36m┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\e[0m" + color_output "\e[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\e[0m" + color_output "" + color_output "1. 中文" + color_output "2. English" + color_output "" + color_output "\e[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\e[0m" + + while [[ -z "$LANG_CHOICE" ]]; do + read -p "$(color_output "\e[33m请选择语言 [1-2]: \e[0m")" LANG_CHOICE + case "$LANG_CHOICE" in + 1) LANG_CHOICE="zh";; + 2) LANG_CHOICE="en";; + *) + color_output "\e[31m无效选择,请重新输入\e[0m" + LANG_CHOICE="" + ;; + esac + done +} + +# 显示用户协议 +show_agreement() { + clear + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\e[0m" + color_output "\e[36m┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\e[0m" + color_output "\e[36m┃ \e[33mZeroWrt 配置工具用户协议\e[36m ┃\e[0m" + color_output "\e[36m┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\e[0m" + color_output "\e[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\e[0m" + color_output "" + color_output "1. 本工具仅用于学习和研究目的,不得用于非法用途。" + color_output "2. 使用本工具可能会修改您的路由器配置,请谨慎操作。" + color_output "3. 作者不对使用本工具造成的任何损失负责。" + color_output "4. 继续使用表示您同意以上条款。" + color_output "" + color_output "\e[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\e[0m" + + while [[ "$AGREED" != "yes" ]]; do + read -p "$(color_output "\e[33m您是否同意上述条款?(yes/no): \e[0m")" AGREED + case "$AGREED" in + yes|YES|y|Y) + AGREED="yes" + ;; + no|NO|n|N) + color_output "\e[31m您必须同意条款才能使用本工具。\e[0m" + exit 1 + ;; + *) + color_output "\e[31m请输入yes或no\e[0m" + ;; + esac + done + else + color_output "\e[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\e[0m" + color_output "\e[36m┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\e[0m" + color_output "\e[36m┃ \e[33mZeroWrt Config Tool User Agreement\e[36m ┃\e[0m" + color_output "\e[36m┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\e[0m" + color_output "\e[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\e[0m" + color_output "" + color_output "1. This tool is for learning and research only, not for illegal use." + color_output "2. Using this tool may modify your router settings, use with caution." + color_output "3. The author is not responsible for any damage caused by this tool." + color_output "4. Continuing to use means you agree to these terms." + color_output "" + color_output "\e[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\e[0m" + + while [[ "$AGREED" != "yes" ]]; do + read -p "$(color_output "\e[33mDo you agree to these terms? (yes/no): \e[0m")" AGREED + case "$AGREED" in + yes|YES|y|Y) + AGREED="yes" + ;; + no|NO|n|N) + color_output "\e[31mYou must agree to the terms to use this tool.\e[0m" + exit 1 + ;; + *) + color_output "\e[31mPlease enter yes or no\e[0m" + ;; + esac + done + fi +} + # 打印脚本头部,增加美观 print_header() { clear @@ -16,562 +113,400 @@ print_header() { local mem_used=$(free | grep Mem | awk '{print $3}') local mem_usage=$((mem_used * 100 / mem_total)) - color_output "\e[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\e[0m" - color_output "\e[36m┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\e[0m" - color_output "\e[36m┃ ┃\e[0m" - color_output "\e[36m┃ \e[33m欢迎使用 ZeroWrt 配置工具\e[36m ┃\e[0m" - color_output "\e[36m┃ ┃\e[0m" - color_output "\e[36m┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\e[0m" - color_output "\e[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\e[0m" - color_output "" - color_output "\e[34m系统信息\e[0m" - color_output "----------------------------------------" - color_output " 设备型号: $model" - color_output " CPU 占用: $cpu_usage" - color_output " 内存占用: ${mem_usage}%" - color_output "----------------------------------------" - color_output "\e[32m说明:本工具用于配置 ZeroWrt \e[0m" - color_output "\e[32m博客:https://www.kejizero.online\e[0m" - color_output "----------------------------------------" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\e[0m" + color_output "\e[36m┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\e[0m" + color_output "\e[36m┃ ┃\e[0m" + color_output "\e[36m┃ \e[33m欢迎使用 ZeroWrt 配置工具\e[36m ┃\e[0m" + color_output "\e[36m┃ ┃\e[0m" + color_output "\e[36m┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\e[0m" + color_output "\e[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\e[0m" + color_output "" + color_output "\e[34m系统信息\e[0m" + color_output "----------------------------------------" + color_output " 设备型号: $model" + color_output " CPU 占用: $cpu_usage" + color_output " 内存占用: ${mem_usage}%" + color_output "----------------------------------------" + color_output "\e[32m说明:本工具用于配置 ZeroWrt \e[0m" + color_output "\e[32m博客:https://www.kejizero.online\e[0m" + color_output "----------------------------------------" + else + color_output "\e[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\e[0m" + color_output "\e[36m┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\e[0m" + color_output "\e[36m┃ ┃\e[0m" + color_output "\e[36m┃ \e[33mWelcome to ZeroWrt Config Tool\e[36m ┃\e[0m" + color_output "\e[36m┃ ┃\e[0m" + color_output "\e[36m┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\e[0m" + color_output "\e[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\e[0m" + color_output "" + color_output "\e[34mSystem Information\e[0m" + color_output "----------------------------------------" + color_output " Device Model: $model" + color_output " CPU Usage: $cpu_usage" + color_output " Memory Usage: ${mem_usage}%" + color_output "----------------------------------------" + color_output "\e[32mDescription: This tool configures ZeroWrt\e[0m" + color_output "\e[32mBlog: https://www.kejizero.online\e[0m" + color_output "----------------------------------------" + fi echo "" } # 显示菜单 show_menu() { - color_output "\e[36m┏━━━━━━━━━━━━━━━ 功能菜单 ━━━━━━━━━━━━━━━┓\e[0m" - color_output "\e[36m┃ ┃\e[0m" - color_output "\e[36m┃\e[0m 1. 更改 LAN 口 IP 地址 \e[36m┃\e[0m" - color_output "\e[36m┃\e[0m 2. 更改管理员密码 \e[36m┃\e[0m" - color_output "\e[36m┃\e[0m 3. 切换默认主题 \e[36m┃\e[0m" - color_output "\e[36m┃\e[0m 4. 恢复出厂设置 \e[36m┃\e[0m" - color_output "\e[36m┃\e[0m 5. 一键换源 \e[36m┃\e[0m" - 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 0. 退出 \e[36m┃\e[0m" - color_output "\e[36m┃ ┃\e[0m" - color_output "\e[36m┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\e[0m" - read -p "$(color_output "\e[33m请输入您的选择 [0-10]: \e[0m")" choice + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[36m┏━━━━━━━━━━━━━━━ 功能菜单 ━━━━━━━━━━━━━━━┓\e[0m" + color_output "\e[36m┃ ┃\e[0m" + color_output "\e[36m┃\e[0m 1. 更改 LAN 口 IP 地址 \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 2. 更改管理员密码 \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 3. 切换默认主题 \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 4. 恢复出厂设置 \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 5. 一键换源 \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 6. 一键部署 \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 7. IPv6 开关 (仅适用于主路由) \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 8. iStoreOS 风格化 \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 9. 检测更新 \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" + read -p "$(color_output "\e[33m请输入您的选择 [0-10]: \e[0m")" choice + else + color_output "\e[36m┏━━━━━━━━━━━━━━━ MENU ━━━━━━━━━━━━━━━━━━┓\e[0m" + color_output "\e[36m┃ ┃\e[0m" + color_output "\e[36m┃\e[0m 1. Change LAN IP Address \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 2. Change Admin Password \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 3. Switch Default Theme \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 4. Factory Reset \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 5. Change Software Sources \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 6. One-click Deployment \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 7. IPv6 Toggle (Main Router Only) \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 8. iStoreOS Styling \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 9. Check for Updates \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 0. Exit \e[36m┃\e[0m" + color_output "\e[36m┃ ┃\e[0m" + color_output "\e[36m┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\e[0m" + read -p "$(color_output "\e[33mEnter your choice [0-10]: \e[0m")" choice + fi + case "$choice" in 1) change_ip ;; 2) change_password ;; 3) change_theme ;; 4) reset_config ;; 5) change_source ;; - 6) one_click_setup ;; - 7) install_apps ;; - 8) configure_ipv6 ;; - 9) istore_style ;; - 10) check_update ;; + 6) install_apps ;; + 7) configure_ipv6 ;; + 8) istore_style ;; + 9) check_update ;; 0) exit 0 ;; - *) echo "无效选项,请重新输入"; show_menu ;; + *) + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[31m无效选项,请重新输入\e[0m" + else + color_output "\e[31mInvalid option, please try again\e[0m" + fi + show_menu + ;; esac } # 1. 更换 LAN 口 IP 地址 change_ip() { - color_output "\e[34m[更改 LAN 口 IP 地址]\e[0m" - read -p "请输入新的 LAN 口 IP 地址(如 192.168.1.2): " new_ip - if [[ -n "$new_ip" ]]; then - uci set network.lan.ipaddr="$new_ip" - uci commit network - /etc/init.d/network restart - color_output "\e[32mLAN 口 IP 已成功更改为 $new_ip\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[34m[更改 LAN 口 IP 地址]\e[0m" + read -p "请输入新的 LAN 口 IP 地址(如 192.168.1.2): " new_ip + if [[ -n "$new_ip" ]]; then + uci set network.lan.ipaddr="$new_ip" + uci commit network + color_output "\e[32mLAN 口 IP 已成功更改为 $new_ip\e[0m" + color_output "\e[33m系统将在 10 秒后自动重启,请使用新的 IP 地址重新连接。\e[0m" + sleep 10 + reboot + else + color_output "\e[31m无效的 IP 地址,操作取消。\e[0m" + read -p "按 Enter 键返回菜单..." + show_menu + fi else - color_output "\e[31m无效的 IP 地址,操作取消。\e[0m" + color_output "\e[34m[Change LAN IP Address]\e[0m" + read -p "Enter new LAN IP address (e.g. 192.168.1.2): " new_ip + if [[ -n "$new_ip" ]]; then + uci set network.lan.ipaddr="$new_ip" + uci commit network + color_output "\e[32mLAN IP successfully changed to $new_ip\e[0m" + color_output "\e[33mSystem will reboot in 10 seconds, please reconnect using the new IP.\e[0m" + sleep 10 + reboot + else + color_output "\e[31mInvalid IP address, operation cancelled.\e[0m" + read -p "Press Enter to return to menu..." + show_menu + fi fi - read -p "按 Enter 键返回菜单..." - show_menu } # 2. 更改管理员密码 change_password() { - color_output "\e[34m[更改管理员密码]\e[0m" - read -p "请输入新的管理员密码: " new_password - if [[ -n "$new_password" ]]; then - # 使用 openssl 生成密码哈希,使用 -1 参数生成 MD5 格式的密码哈希 - password_hash=$(openssl passwd -1 "$new_password") - - # 获取当前 shadow 文件的其他行 - tail -n +2 /etc/shadow > /tmp/shadow.tmp - - # 创建新的 root 行 - echo "root:$password_hash:0:0:99999:7:::" > /etc/shadow - - # 添加其他行 - cat /tmp/shadow.tmp >> /etc/shadow - - # 清理临时文件 - rm -f /tmp/shadow.tmp - - color_output "\e[32m管理员密码已成功更改。\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[34m[更改管理员密码]\e[0m" + read -p "请输入新的管理员密码: " new_password + if [[ -n "$new_password" ]]; then + # 使用 openssl 生成密码哈希,使用 -1 参数生成 MD5 格式的密码哈希 + password_hash=$(openssl passwd -1 "$new_password") + + # 获取当前 shadow 文件的其他行 + tail -n +2 /etc/shadow > /tmp/shadow.tmp + + # 创建新的 root 行 + echo "root:$password_hash:0:0:99999:7:::" > /etc/shadow + + # 添加其他行 + cat /tmp/shadow.tmp >> /etc/shadow + + # 清理临时文件 + rm -f /tmp/shadow.tmp + + color_output "\e[32m管理员密码已成功更改。\e[0m" + else + color_output "\e[31m无效的密码,操作取消。\e[0m" + fi + read -p "按 Enter 键返回菜单..." else - color_output "\e[31m无效的密码,操作取消。\e[0m" + color_output "\e[34m[Change Admin Password]\e[0m" + read -p "Enter new admin password: " new_password + if [[ -n "$new_password" ]]; then + # 使用 openssl 生成密码哈希,使用 -1 参数生成 MD5 格式的密码哈希 + password_hash=$(openssl passwd -1 "$new_password") + + # 获取当前 shadow 文件的其他行 + tail -n +2 /etc/shadow > /tmp/shadow.tmp + + # 创建新的 root 行 + echo "root:$password_hash:0:0:99999:7:::" > /etc/shadow + + # 添加其他行 + cat /tmp/shadow.tmp >> /etc/shadow + + # 清理临时文件 + rm -f /tmp/shadow.tmp + + color_output "\e[32mAdmin password changed successfully.\e[0m" + else + color_output "\e[31mInvalid password, operation cancelled.\e[0m" + fi + read -p "Press Enter to return to menu..." fi - read -p "按 Enter 键返回菜单..." show_menu } # 3. 切换默认主题 change_theme() { - color_output "\e[34m[切换默认主题]\e[0m" - uci set luci.main.mediaurlbase='/luci-static/bootstrap' - uci commit luci - color_output "\e[32m主题已成功切换为默认主题。\e[0m" - read -p "按 Enter 键返回菜单..." + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[34m[切换默认主题]\e[0m" + uci set luci.main.mediaurlbase='/luci-static/bootstrap' + uci commit luci + color_output "\e[32m主题已成功切换为默认主题。\e[0m" + read -p "按 Enter 键返回菜单..." + else + color_output "\e[34m[Switch Default Theme]\e[0m" + uci set luci.main.mediaurlbase='/luci-static/bootstrap' + uci commit luci + color_output "\e[32mTheme successfully switched to default.\e[0m" + read -p "Press Enter to return to menu..." + fi show_menu } # 4. 一键重置配置 reset_config() { - color_output "\e[31m[恢复出厂设置]\e[0m" - color_output "\e[31m警告:此操作将清除所有设置!\e[0m" - read -p "确定要继续吗?(y/n): " confirm - if [[ "$confirm" == "y" || "$confirm" == "Y" ]]; then - echo "恢复出厂设置中..." - firstboot -y - color_output "\e[33m设备将在 5 秒钟后重启...\e[0m" - sleep 5 - reboot + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[31m[恢复出厂设置]\e[0m" + color_output "\e[31m警告:此操作将清除所有设置!\e[0m" + read -p "确定要继续吗?(y/n): " confirm + if [[ "$confirm" == "y" || "$confirm" == "Y" ]]; then + echo "恢复出厂设置中..." + firstboot -y + color_output "\e[33m设备将在 5 秒钟后重启...\e[0m" + sleep 5 + reboot + else + color_output "\e[32m操作已取消\e[0m" + read -p "按 Enter 键返回菜单..." + show_menu + fi else - color_output "\e[32m操作已取消\e[0m" - read -p "按 Enter 键返回菜单..." - show_menu + color_output "\e[31m[Factory Reset]\e[0m" + color_output "\e[31mWarning: This will erase all settings!\e[0m" + read -p "Are you sure you want to continue? (y/n): " confirm + if [[ "$confirm" == "y" || "$confirm" == "Y" ]]; then + echo "Resetting to factory defaults..." + firstboot -y + color_output "\e[33mDevice will reboot in 5 seconds...\e[0m" + sleep 5 + reboot + else + color_output "\e[32mOperation cancelled\e[0m" + read -p "Press Enter to return to menu..." + show_menu + fi fi } # 5. 一键换源 change_source() { - color_output "\e[34m[更换软件源]\e[0m" - color_output "\e[36m请选择要使用的源:\e[0m" - color_output "1. 阿里源" - color_output "2. 清华源" - color_output "3. 中科大源" - color_output "4. 高校联合镜像站" - color_output "5. 南方科技大学" - color_output "6. 官方源" - color_output "0. 返回" - read -p "请输入您的选择 [0-6]: " source_choice + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[34m[更换软件源]\e[0m" + color_output "\e[36m请选择要使用的源:\e[0m" + color_output "1. 阿里源" + color_output "2. 清华源" + color_output "3. 中科大源" + color_output "4. 高校联合镜像站" + color_output "5. 南方科技大学" + color_output "6. 官方源" + color_output "0. 返回" + read -p "请输入您的选择 [0-6]: " source_choice + else + color_output "\e[34m[Change Software Sources]\e[0m" + color_output "\e[36mSelect source to use:\e[0m" + color_output "1. Aliyun Mirror" + color_output "2. Tsinghua Mirror" + color_output "3. USTC Mirror" + color_output "4. University Union Mirror" + color_output "5. SUSTech Mirror" + color_output "6. Official Source" + color_output "0. Back" + read -p "Enter your choice [0-6]: " source_choice + fi - # 检测当前设备架构 + # 仅支持 x86_64 和 aarch64 架构 arch=$(uname -m) - - # 针对不同架构的设置 case "$arch" in "x86_64") arch_name="x86_64" - ;; - "i386" | "pentium4") - arch_name="i386_pentium4" + target_core_url="https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/24.10.1/targets/x86/64/kmods/6.6.86-1-af351158cfb5febf5155a3aa53785982" + extras_url="https://clone.kejizero.online/raw.githubusercontent.com/oppen321/openwrt_extras/main/x86_64" ;; "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" + target_core_url="https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/24.10.1/targets/rockchip/armv8/kmods/6.6.86-1-a8e18e0ecc66cc99303d258424ec0db8" + extras_url="https://clone.kejizero.online/raw.githubusercontent.com/oppen321/openwrt_extras/main/aarch64" ;; *) - 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/packages/$arch_name" - ;; - 2) - base_url="https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/24.10.0/packages/$arch_name" - ;; - 3) - base_url="https://mirrors.ustc.edu.cn/openwrt/releases/24.10.0/packages/$arch_name" - ;; - 4) - base_url="https://mirrors.xjtu.edu.cn/openwrt/releases/24.10.0/packages/$arch_name" - ;; - 5) - base_url="https://mirrors.sustech.edu.cn/openwrt/releases/24.10.0/packages/$arch_name" - ;; - 6) - base_url="https://downloads.openwrt.org/releases/24.10.0/packages/$arch_name" - ;; - 0) show_menu ; return ;; - *) - color_output "\e[31m无效选项,返回菜单。\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[31m仅支持 x86_64 和 aarch64 架构,当前架构为:$arch\e[0m" + else + color_output "\e[31mOnly x86_64 and aarch64 are supported, current arch: $arch\e[0m" + fi + read -p "$([[ "$LANG_CHOICE" == "zh" ]] && echo "按 Enter 键返回菜单..." || echo "Press Enter to return to menu...")" show_menu return ;; esac - # 更新软件源 + # 镜像站选择 + case "$source_choice" in + 1) base_url="https://mirrors.aliyun.com/openwrt/releases/24.10.0/packages/$arch_name" ;; + 2) base_url="https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/24.10.0/packages/$arch_name" ;; + 3) base_url="https://mirrors.ustc.edu.cn/openwrt/releases/24.10.0/packages/$arch_name" ;; + 4) base_url="https://mirrors.xjtu.edu.cn/openwrt/releases/24.10.0/packages/$arch_name" ;; + 5) base_url="https://mirrors.sustech.edu.cn/openwrt/releases/24.10.0/packages/$arch_name" ;; + 6) base_url="https://downloads.openwrt.org/releases/24.10.0/packages/$arch_name" ;; + 0) show_menu; return ;; + *) + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[31m无效选项,返回菜单。\e[0m" + else + color_output "\e[31mInvalid option, returning to menu.\e[0m" + fi + show_menu; return + ;; + esac + + # 生成 distfeeds.conf 文件 cat < /etc/opkg/distfeeds.conf src/gz openwrt_base $base_url/base src/gz openwrt_luci $base_url/luci src/gz openwrt_packages $base_url/packages src/gz openwrt_routing $base_url/routing src/gz openwrt_telephony $base_url/telephony +src/gz openwrt_core $target_core_url +src/gz openwrt_extras $extras_url/package +src/gz openwrt_helloworld $extras_url/helloworld EOF - color_output "\e[32m软件源已成功切换。\e[0m" - read -p "按 Enter 键返回菜单..." + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[32m软件源已成功切换并追加自定义源。\e[0m" + read -p "按 Enter 键返回菜单..." + else + color_output "\e[32mSoftware sources changed successfully with custom sources added.\e[0m" + read -p "Press Enter to return to menu..." + fi show_menu } -# 6. 一键设置 -one_click_setup() { - while true; do - clear - color_output "\e[34m[一键设置]\e[0m" - color_output "\e[36m┏━━━━━━━━━━━━━━━ 设置选项 ━━━━━━━━━━━━━━━┓\e[0m" - color_output "\e[36m┃ ┃\e[0m" - color_output "\e[36m┃\e[0m 1. SmartDNS + AdGuardHome \e[36m┃\e[0m" - color_output "\e[36m┃\e[0m 2. MosDNS + AdGuardHome \e[36m┃\e[0m" - color_output "\e[36m┃\e[0m 3. 恢复默认设置 \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" - - read -p "$(color_output "\e[33m请输入您的选择 [0-3]: \e[0m")" setup_choice - - case "$setup_choice" in - 1) - color_output "\e[34m[SmartDNS + AdGuardHome]\e[0m" - - # 设置LAN口DNS - uci set network.lan.dns='127.0.0.1' - uci commit network - - # 恢复 MosDNS 配置 - cp /etc/config/default_mosdns /etc/config/mosdns - /etc/init.d/mosdns restart - - # Dnsmasq设置 - uci set dhcp.@dnsmasq[0].cachesize='0' - uci commit dhcp - /etc/init.d/dnsmasq restart - - # 配置 SmartDNS - uci set smartdns.@smartdns[0].prefetch_domain='1' - uci set smartdns.@smartdns[0].port='6053' - uci set smartdns.@smartdns[0].seconddns_port='5335' - uci set smartdns.@smartdns[0].seconddns_no_rule_addr='1' - uci set smartdns.@smartdns[0].seconddns_no_rule_nameserver='0' - uci set smartdns.@smartdns[0].seconddns_no_rule_ip='0' - uci set smartdns.@smartdns[0].seconddns_no_rule_soa='0' - uci set smartdns.@smartdns[0].tcp_server='1' - uci set smartdns.@smartdns[0].rr_ttl='600' - uci set smartdns.@smartdns[0].seconddns_enabled='1' - uci set smartdns.@smartdns[0].server_name='smartdns-China' - uci set smartdns.@smartdns[0].seconddns_tcp_server='1' - uci set smartdns.@smartdns[0].seconddns_server_group='smartdns-Overseas' - uci set smartdns.@smartdns[0].rr_ttl_min='5' - uci set smartdns.@smartdns[0].seconddns_no_speed_check='1' - uci set smartdns.@smartdns[0].cache_size='190150' - uci set smartdns.@smartdns[0].serve_expired='1' - uci set smartdns.@smartdns[0].auto_set_dnsmasq='0' - uci set smartdns.@smartdns[0].ipv6_server='0' - uci set smartdns.@smartdns[0].dualstack_ip_selection='0' - uci set smartdns.@smartdns[0].force_aaaa_soa='1' - uci set smartdns.@smartdns[0].coredump='1' - uci set smartdns.@smartdns[0].speed_check_mode='tcp:443,tcp:80,ping' - uci set smartdns.@smartdns[0].resolve_local_hostnames='1' - uci set smartdns.@smartdns[0].seconddns_force_aaaa_soa='1' - uci set smartdns.@smartdns[0].enable_auto_update='0' - uci set smartdns.@smartdns[0].enabled='1' - uci set smartdns.@smartdns[0].bind_device='1' - uci set smartdns.@smartdns[0].cache_persist='1' - uci set smartdns.@smartdns[0].force_https_soa='1' - uci set smartdns.@smartdns[0].seconddns_no_dualstack_selection='1' - uci set smartdns.@smartdns[0].seconddns_no_cache='1' - uci commit smartdns - /etc/init.d/smartdns restart - - # AdguardHome 设置 - cp /etc/config/default_AdGuardHome /etc/AdGuardHome.yaml - sed -i 's/cache_size: .*/cache_size: 0/' /etc/AdGuardHome.yaml - sed -i 's/upstream_mode: .*/upstream_mode: parallel/' /etc/AdGuardHome.yaml - sed -i 's/upstream_dns_file:.*/upstream_dns_file: \/etc\/AdGuardHome-dnslist.yaml/' /etc/AdGuardHome.yaml - uci set AdGuardHome.AdGuardHome.enabled='1' - uci set AdGuardHome.AdGuardHome.redirect='dnsmasq-upstream' - uci commit AdGuardHome - /etc/init.d/AdGuardHome restart - - # passwall 设置 - uci set passwall.@global[0].dns_shunt='dnsmasq' - uci set passwall.@global[0].remote_dns='127.0.0.1:5553' - uci set passwall.@global[0].dns_mode='udp' - uci commit passwall - /etc/init.d/passwall restart - - ### OpenClash设置 - # 禁用默认DNS配置 - n=0 - while [ "$n" -lt $(uci show openclash|grep -c "^openclash.@dns_servers\[[0-9]\{1,10\}\]=dns_servers") ]; do - uci set openclash.@dns_servers[$n].enabled='0' - n=$((n + 1)) - done - # 设置DNS - uci add openclash dns_servers - uci set openclash.@dns_servers[-1].enabled='1' - uci set openclash.@dns_servers[-1].group='nameserver' - uci set openclash.@dns_servers[-1].type='udp' - uci set openclash.@dns_servers[-1].ip='127.0.0.1' - uci set openclash.@dns_servers[-1].port='5553' - uci add openclash dns_servers - uci set openclash.@dns_servers[-1].enabled='1' - uci set openclash.@dns_servers[-1].group='fallback' - uci set openclash.@dns_servers[-1].type='udp' - uci set openclash.@dns_servers[-1].ip='127.0.0.1' - uci set openclash.@dns_servers[-1].port='5553' - uci set openclash.config.enable_custom_dns='1' - # 模式设置 - uci set openclash.config.en_mode='fake-ip-mix' - # 自定义上游DNS服务器 - uci set openclash.config.enable_custom_dns='1' - # Fake-IP持久化 - uci set openclash.config.store_fakeip='1' - # 启用Fake-IP 过滤器 - uci set openclash.config.custom_fakeip_filter='1' - # 开启绕过服务器地址 - uci set openclash.config.bypass_gateway_compatible='1' - # 禁用本地 DNS 劫持 - uci set openclash.config.enable_redirect_dns='0' - # 开启 GeoIP MMDB 自动更新 - uci set openclash.config.geoip_auto_update='1' - uci set openclash.config.geoip_update_week_time='*' # 每周更新 - uci set openclash.config.geoip_update_day_time='3' # 每周的第 3 天(可以根据需求修改) - # 开启 GeoIP Dat 自动更新 - uci set openclash.config.geo_auto_update='1' - uci set openclash.config.geo_update_week_time='*' # 每周更新 - uci set openclash.config.geo_update_day_time='1' # 每周的第 1 天(可以根据需求修改) - # 开启 GeoSite 数据库自动更新 - uci set openclash.config.geosite_auto_update='1' - uci set openclash.config.geosite_update_week_time='*' # 每周更新 - uci set openclash.config.geosite_update_day_time='4' # 每周的第 4 天(可以根据需求修改) - # 启用大陆白名单订阅自动更新 - uci set openclash.config.chnr_auto_update='1' # 开启大陆白名单订阅自动更新 - uci set openclash.config.chnr_update_week_time='*' # 每周更新 - uci set openclash.config.chnr_update_day_time='5' # 每周的第 5 天(可以根据需求修改) - uci commit openclash - - color_output "\e[32mSmartDNS 和 AdGuardHome 配置完成。\e[0m" - read -p "按 Enter 键继续..." - ;; - 2) - color_output "\e[34m[MosDNS + AdGuardHome]\e[0m" - - # 设置LAN口DNS - uci set network.lan.dns='127.0.0.1' - uci commit network - - # 恢复 SmartDNS 配置 - cp /etc/config/default_smartdns /etc/config/smartdns - /etc/init.d/smartdns restart - - # Dnsmasq设置 - uci set dhcp.@dnsmasq[0].cachesize='0' - uci commit dhcp - /etc/init.d/dnsmasq restart - - # 配置 MosDNS - uci set mosdns.config.enabled='1' - uci set mosdns.config.redirect='0' - uci set mosdns.config.custom_local_dns='1' - uci set mosdns.config.dump_file='1' - uci add_list mosdns.config.local_dns='119.29.29.29' # DNS 服务器 - uci add_list mosdns.config.local_dns='119.28.28.28' # DNS 服务器 - uci add_list mosdns.config.local_dns='223.5.5.5' # DNS 服务器 - uci add_list mosdns.config.local_dns='223.6.6.6' # DNS 服务器 - uci add_list mosdns.config.local_dns='180.184.1.1' # DNS 服务器 - uci add_list mosdns.config.local_dns='114.114.114.114' # DNS 服务器 - uci add_list mosdns.config.local_dns='https://doh.pub/dns-query' # DoH 服务器 - uci add_list mosdns.config.local_dns='quic://dns.alidns.com' # QUIC 协议 - uci add_list mosdns.config.local_dns='h3://dns.alidns.com/dns-query' # HTTP3 协议 - uci add_list mosdns.config.local_dns='https://dns.alidns.com/dns-query' # DoH 服务器 - uci add_list mosdns.config.local_dns='https://doh.360.cn/dns-query' # 360 DoH - uci set mosdns.config.remote_dns='tls://8.8.8.8' - uci add_list mosdns.config.remote_dns='tls://1.1.1.1' - uci add_list mosdns.config.remote_dns='tls://dns.google' - uci add_list mosdns.config.remote_dns='tls://cloudflare-dns.com' - uci set mosdns.config.cache='1' - uci set mosdns.config.dns_leak='1' - uci set mosdns.config.concurrent='2' - uci set mosdns.config.minimal_ttl='5' - uci set mosdns.config.maximum_ttl='300' - uci commit mosdns - /etc/init.d/mosdns restart - - # 配置 AdGuardHome - cp /etc/config/default_AdGuardHome /etc/AdGuardHome.yaml - sed -i 's/upstream_dns_file:.*/upstream_dns_file: \/etc\/AdGuardHome-mosdns.yaml/' /etc/AdGuardHome.yaml - sed -i 's/cache_size: .*/cache_size: 0/' /etc/AdGuardHome.yaml - sed -i 's/upstream_mode: .*/upstream_mode: parallel/' /etc/AdGuardHome.yaml - uci set AdGuardHome.AdGuardHome.enabled='1' - uci set AdGuardHome.AdGuardHome.redirect='dnsmasq-upstream' - uci commit AdGuardHome - /etc/init.d/AdGuardHome restart - - # passwall 设置 - uci set passwall.@global[0].dns_shunt='dnsmasq' - uci set passwall.@global[0].remote_dns='127.0.0.1:5553' - uci set passwall.@global[0].dns_mode='udp' - uci commit passwall - /etc/init.d/passwall restart - - ### OpenClash设置 - # 禁用默认DNS配置 - n=0 - while [ "$n" -lt $(uci show openclash|grep -c "^openclash.@dns_servers\[[0-9]\{1,10\}\]=dns_servers") ]; do - uci set openclash.@dns_servers[$n].enabled='0' - n=$((n + 1)) - done - # 设置DNS - uci add openclash dns_servers - uci set openclash.@dns_servers[-1].enabled='1' - uci set openclash.@dns_servers[-1].group='nameserver' - uci set openclash.@dns_servers[-1].type='udp' - uci set openclash.@dns_servers[-1].ip='127.0.0.1' - uci set openclash.@dns_servers[-1].port='5553' - uci add openclash dns_servers - uci set openclash.@dns_servers[-1].enabled='1' - uci set openclash.@dns_servers[-1].group='fallback' - uci set openclash.@dns_servers[-1].type='udp' - uci set openclash.@dns_servers[-1].ip='127.0.0.1' - uci set openclash.@dns_servers[-1].port='5553' - uci set openclash.config.enable_custom_dns='1' - # 模式设置 - uci set openclash.config.en_mode='fake-ip-mix' - # 自定义上游DNS服务器 - uci set openclash.config.enable_custom_dns='1' - # Fake-IP持久化 - uci set openclash.config.store_fakeip='1' - # 启用Fake-IP 过滤器 - uci set openclash.config.custom_fakeip_filter='1' - # 开启绕过服务器地址 - uci set openclash.config.bypass_gateway_compatible='1' - # 禁用本地 DNS 劫持 - uci set openclash.config.enable_redirect_dns='0' - # 开启 GeoIP MMDB 自动更新 - uci set openclash.config.geoip_auto_update='1' - uci set openclash.config.geoip_update_week_time='*' # 每周更新 - uci set openclash.config.geoip_update_day_time='3' # 每周的第 3 天(可以根据需求修改) - # 开启 GeoIP Dat 自动更新 - uci set openclash.config.geo_auto_update='1' - uci set openclash.config.geo_update_week_time='*' # 每周更新 - uci set openclash.config.geo_update_day_time='1' # 每周的第 1 天(可以根据需求修改) - # 开启 GeoSite 数据库自动更新 - uci set openclash.config.geosite_auto_update='1' - uci set openclash.config.geosite_update_week_time='*' # 每周更新 - uci set openclash.config.geosite_update_day_time='4' # 每周的第 4 天(可以根据需求修改) - # 启用大陆白名单订阅自动更新 - uci set openclash.config.chnr_auto_update='1' # 开启大陆白名单订阅自动更新 - uci set openclash.config.chnr_update_week_time='*' # 每周更新 - uci set openclash.config.chnr_update_day_time='5' # 每周的第 5 天(可以根据需求修改) - uci commit openclash - - color_output "\e[32mMosDNS 和 AdGuardHome 配置完成。\e[0m" - read -p "按 Enter 键继续..." - ;; - 3) - color_output "\e[34m[恢复默认设置]\e[0m" - - # 取消LAN口DNS - uci delete network.lan.dns - uci commit network - # 恢复 SmartDNS 配置 - cp /etc/config/default_smartdns /etc/config/smartdns - /etc/init.d/smartdns restart - # 恢复 MosDNS 配置 - cp /etc/config/default_mosdns /etc/config/mosdns - /etc/init.d/mosdns restart - # 恢复 adguardhome - uci set AdGuardHome.AdGuardHome.enabled='0' - uci set AdGuardHome.AdGuardHome.redirect='none' - cp /etc/config/default_AdGuardHome /etc/AdGuardHome.yaml - sed -i 's/upstream_dns_file:.*/upstream_dns_file: \/etc\/AdGuardHome-dns.yaml/' /etc/AdGuardHome.yaml - uci commit AdGuardHome - /etc/init.d/AdGuardHome restart - # 恢复 passwall - cp /etc/config/default_passwall /etc/config/passwall - /etc/init.d/passwall restart - # 恢复 openclash - cp /etc/config/default_openclash /etc/config/openclash - uci commit openclash - /etc/init.d/openclash restart - - color_output "\e[32m恢复默认设置 配置完成。\e[0m" - read -p "按 Enter 键继续..." - ;; - 0) - show_menu - return - ;; # 返回上一层菜单 - *) - color_output "\e[31m无效选项,返回菜单。\e[0m" - continue - ;; - esac - done -} - -# 7. 一键部署 +# 6. 一键部署 install_apps() { while true; do clear - color_output "\e[34m[一键部署]\e[0m" - color_output "\e[36m┏━━━━━━━━━━━━━━━ 部署选项 ━━━━━━━━━━━━━━━┓\e[0m" - color_output "\e[36m┃ ┃\e[0m" - color_output "\e[36m┃\e[0m 1. 部署 ShellClash \e[36m┃\e[0m" - color_output "\e[36m┃\e[0m 2. 部署 小雅 Alist \e[36m┃\e[0m" - 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 0. 返回主菜单 \e[36m┃\e[0m" - color_output "\e[36m┃ ┃\e[0m" - color_output "\e[36m┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\e[0m" - - read -p "$(color_output "\e[33m请输入您的选择 [0-6]: \e[0m")" app_choice + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[34m[一键部署]\e[0m" + color_output "\e[36m┏━━━━━━━━━━━━━━━ 部署选项 ━━━━━━━━━━━━━━━┓\e[0m" + color_output "\e[36m┃ ┃\e[0m" + color_output "\e[36m┃\e[0m 1. 部署 ShellClash \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 2. 部署 小雅 Alist \e[36m┃\e[0m" + 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 0. 返回主菜单 \e[36m┃\e[0m" + color_output "\e[36m┃ ┃\e[0m" + color_output "\e[36m┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\e[0m" + read -p "$(color_output "\e[33m请输入您的选择 [0-6]: \e[0m")" app_choice + else + color_output "\e[34m[One-click Deployment]\e[0m" + color_output "\e[36m┏━━━━━━━━━━━━━━━ DEPLOYMENT ━━━━━━━━━━━━━━━┓\e[0m" + color_output "\e[36m┃ ┃\e[0m" + color_output "\e[36m┃\e[0m 1. Deploy ShellClash \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 2. Deploy XiaoYa Alist \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 3. Deploy Subconverter \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 4. Deploy AdGuardhome \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 5. Deploy Gitea-MySQL \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 6. Deploy SunPanel \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 0. Back to Main Menu \e[36m┃\e[0m" + color_output "\e[36m┃ ┃\e[0m" + color_output "\e[36m┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\e[0m" + read -p "$(color_output "\e[33mEnter your choice [0-6]: \e[0m")" app_choice + fi case "$app_choice" in 1) - color_output "\e[34m[部署 ShellClash]\e[0m" - color_output "\e[36m请选择 ShellClash 的安装源:\e[0m" - color_output "1. GitHub 源" - color_output "2. jsDelivr CDN 源" - color_output "0. 返回" - read -p "请输入您的选择 [0-2]: " install_choice + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[34m[部署 ShellClash]\e[0m" + color_output "\e[36m请选择 ShellClash 的安装源:\e[0m" + color_output "1. GitHub 源" + color_output "2. jsDelivr CDN 源" + color_output "0. 返回" + read -p "请输入您的选择 [0-2]: " install_choice + else + color_output "\e[34m[Deploy ShellClash]\e[0m" + color_output "\e[36mSelect installation source:\e[0m" + color_output "1. GitHub Source" + color_output "2. jsDelivr CDN Source" + color_output "0. Back" + read -p "Enter your choice [0-2]: " install_choice + fi case "$install_choice" in 1) export url='https://raw.githubusercontent.com/juewuy/ShellCrash/master' ;; 2) export url='https://fastly.jsdelivr.net/gh/juewuy/ShellCrash@master' ;; 0) continue ;; *) - color_output "\e[31m无效选项\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[31m无效选项\e[0m" + else + color_output "\e[31mInvalid option\e[0m" + fi sleep 2 continue ;; @@ -579,85 +514,157 @@ install_apps() { if [ "$install_choice" != "0" ]; then sh -c "$(curl -kfsSl $url/install.sh)" && source /etc/profile &> /dev/null - color_output "\e[32mShellClash 已成功安装。\e[0m" - read -p "按 Enter 键继续..." + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[32mShellClash 已成功安装。\e[0m" + else + color_output "\e[32mShellClash installed successfully.\e[0m" + fi + read -p "$([[ "$LANG_CHOICE" == "zh" ]] && echo "按 Enter 键继续..." || echo "Press Enter to continue...")" fi ;; 2) - color_output "\e[34m[部署小雅 Alist]\e[0m" - color_output "\e[33m正在部署小雅 Alist...\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[34m[部署小雅 Alist]\e[0m" + color_output "\e[33m正在部署小雅 Alist...\e[0m" + else + color_output "\e[34m[Deploy XiaoYa Alist]\e[0m" + color_output "\e[33mDeploying XiaoYa Alist...\e[0m" + fi bash -c "$(curl --insecure -fsSL https://ddsrem.com/xiaoya_install.sh)" - color_output "\e[32m小雅 Alist 安装完成。\e[0m" - read -p "按 Enter 键继续..." + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[32m小雅 Alist 安装完成。\e[0m" + else + color_output "\e[32mXiaoYa Alist installed successfully.\e[0m" + fi + read -p "$([[ "$LANG_CHOICE" == "zh" ]] && echo "按 Enter 键继续..." || echo "Press Enter to continue...")" ;; 3) - color_output "\e[34m[部署 Subconverter]\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[34m[部署 Subconverter]\e[0m" + else + color_output "\e[34m[Deploy Subconverter]\e[0m" + fi # 检查 Docker 是否已安装 if ! command -v docker &> /dev/null; then - color_output "\e[33m未检测到 Docker,正在安装...\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[33m未检测到 Docker,正在安装...\e[0m" + else + color_output "\e[33mDocker not found, installing...\e[0m" + fi opkg update && opkg install docker fi # 检查 Subconverter 是否已运行 if docker ps | grep -q "subconverter"; then - color_output "\e[32mSubconverter 已经在运行\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[32mSubconverter 已经在运行\e[0m" + else + color_output "\e[32mSubconverter is already running\e[0m" + fi # 获取本机 IP 地址 local_ip=$(ip addr show br-lan | grep -w inet | awk '{print $2}' | cut -d/ -f1) - # 显示配置模板选项 - color_output "\e[36m┏━━━━━━━━━━━━━━━ 配置模板 ━━━━━━━━━━━━━━━┓\e[0m" - color_output "\e[36m┃ ┃\e[0m" - color_output "\e[36m┃\e[0m 1. ACL4SSR_Online_Mini.ini \e[36m┃\e[0m" - color_output "\e[36m┃\e[0m 2. ACL4SSR_Online_Full.ini \e[36m┃\e[0m" - color_output "\e[36m┃\e[0m 3. ACL4SSR_Online.ini \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" - read -p "$(color_output "\e[33m请输入选择 [0-3]: \e[0m")" template_choice + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[36m┏━━━━━━━━━━━━━━━ 配置模板 ━━━━━━━━━━━━━━━┓\e[0m" + color_output "\e[36m┃ ┃\e[0m" + color_output "\e[36m┃\e[0m 1. ACL4SSR_Online_Mini.ini \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 2. ACL4SSR_Online_Full.ini \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 3. ACL4SSR_Online.ini \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" + read -p "$(color_output "\e[33m请输入选择 [0-3]: \e[0m")" template_choice + else + color_output "\e[36m┏━━━━━━━━━━━━━━━ CONFIG TEMPLATE ━━━━━━━━━━━━━━━┓\e[0m" + color_output "\e[36m┃ ┃\e[0m" + color_output "\e[36m┃\e[0m 1. ACL4SSR_Online_Mini.ini \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 2. ACL4SSR_Online_Full.ini \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 3. ACL4SSR_Online.ini \e[36m┃\e[0m" + color_output "\e[36m┃\e[0m 0. Back \e[36m┃\e[0m" + color_output "\e[36m┃ ┃\e[0m" + color_output "\e[36m┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\e[0m" + read -p "$(color_output "\e[33mEnter your choice [0-3]: \e[0m")" template_choice + fi - case "$template_choice" in - 1) config_url="https://git.kejizero.online/zhao/rule/raw/branch/main/mihomo/ACL4SSR_Online_Mini.ini" ;; - 2) config_url="https://git.kejizero.online/zhao/rule/raw/branch/main/mihomo/ACL4SSR_Online_Full.ini" ;; - 3) config_url="https://git.kejizero.online/zhao/rule/raw/branch/main/mihomo/ACL4SSR_Online.ini" ;; - 0) continue ;; # 返回上一级 - *) - color_output "\e[31m无效选择\e[0m" - read -p "按 Enter 键继续..." - continue - ;; - esac + case "$template_choice" in + 1) config_url="https://git.kejizero.online/zhao/rule/raw/branch/main/mihomo/ACL4SSR_Online_Mini.ini" ;; + 2) config_url="https://git.kejizero.online/zhao/rule/raw/branch/main/mihomo/ACL4SSR_Online_Full.ini" ;; + 3) config_url="https://git.kejizero.online/zhao/rule/raw/branch/main/mihomo/ACL4SSR_Online.ini" ;; + 0) continue ;; # 返回上一级 + *) + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[31m无效选择\e[0m" + else + color_output "\e[31mInvalid choice\e[0m" + fi + read -p "$([[ "$LANG_CHOICE" == "zh" ]] && echo "按 Enter 键继续..." || echo "Press Enter to continue...")" + continue + ;; + esac # 获取订阅链接 - read -p "请输入订阅链接: " sub_url + if [[ "$LANG_CHOICE" == "zh" ]]; then + read -p "请输入订阅链接: " sub_url + else + read -p "Enter subscription URL: " sub_url + fi if [ -n "$sub_url" ]; then # 生成完整的转换链接 convert_url="http://${local_ip}:25500/sub?target=clash&insert=true&new_name=true&scv=true&url=${sub_url}&config=${config_url}" - color_output "\e[32m转换链接已生成:\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[32m转换链接已生成:\e[0m" + else + color_output "\e[32mConversion URL generated:\e[0m" + fi color_output "\e[33m${convert_url}\e[0m" else - color_output "\e[31m订阅链接不能为空\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[31m订阅链接不能为空\e[0m" + else + color_output "\e[31mSubscription URL cannot be empty\e[0m" + fi fi else - color_output "\e[33m正在部署 Subconverter...\e[0m" - if docker run -d --restart=always -p 25500:25500 tindy2013/subconverter:latest; then - color_output "\e[32mSubconverter 部署成功!\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[33m正在部署 Subconverter...\e[0m" else - color_output "\e[31mSubconverter 部署失败\e[0m" + color_output "\e[33mDeploying Subconverter...\e[0m" + fi + if docker run -d --restart=always -p 25500:25500 tindy2013/subconverter:latest; then + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[32mSubconverter 部署成功!\e[0m" + else + color_output "\e[32mSubconverter deployed successfully!\e[0m" + fi + else + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[31mSubconverter 部署失败\e[0m" + else + color_output "\e[31mSubconverter deployment failed\e[0m" + fi fi fi - read -p "按 Enter 键返回..." + read -p "$([[ "$LANG_CHOICE" == "zh" ]] && echo "按 Enter 键返回..." || echo "Press Enter to return...")" ;; 4) - color_output "\e[34m[部署 AdGuardHome]\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[34m[部署 AdGuardHome]\e[0m" + else + color_output "\e[34m[Deploy AdGuardHome]\e[0m" + fi # 检查 Docker 是否已安装 if ! command -v docker &> /dev/null; then - color_output "\e[33m未检测到 Docker,正在安装...\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[33m未检测到 Docker,正在安装...\e[0m" + else + color_output "\e[33mDocker not found, installing...\e[0m" + fi opkg update && opkg install docker fi @@ -666,11 +673,20 @@ install_apps() { # 检查 AdGuardHome 是否已运行 if docker ps | grep -q "adguardhome"; then - color_output "\e[32mAdGuardHome 已经在运行!\e[0m" - color_output "\e[33m请使用浏览器访问:\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[32mAdGuardHome 已经在运行!\e[0m" + color_output "\e[33m请使用浏览器访问:\e[0m" + else + color_output "\e[32mAdGuardHome is already running!\e[0m" + color_output "\e[33mAccess it at:\e[0m" + fi color_output "\e[32mhttp://${local_ip}:3000\e[0m" else - color_output "\e[33m正在部署 AdGuardHome...\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[33m正在部署 AdGuardHome...\e[0m" + else + color_output "\e[33mDeploying AdGuardHome...\e[0m" + fi # 创建配置目录 mkdir -p /root/adguardhome/work /root/adguardhome/conf @@ -684,26 +700,47 @@ install_apps() { --restart always \ adguard/adguardhome; then - color_output "\e[32m\nAdGuardHome 部署成功!\e[0m" - color_output "\e[33m请使用浏览器访问以下地址进行配置:\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[32m\nAdGuardHome 部署成功!\e[0m" + color_output "\e[33m请使用浏览器访问以下地址进行配置:\e[0m" + else + color_output "\e[32m\nAdGuardHome deployed successfully!\e[0m" + color_output "\e[33mAccess the following URL to configure:\e[0m" + fi color_output "\e[32mhttp://${local_ip}:3000\e[0m" else - color_output "\e[31mAdGuardHome 部署失败\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[31mAdGuardHome 部署失败\e[0m" + else + color_output "\e[31mAdGuardHome deployment failed\e[0m" + fi fi fi - read -p "按 Enter 键返回..." + read -p "$([[ "$LANG_CHOICE" == "zh" ]] && echo "按 Enter 键返回..." || echo "Press Enter to return...")" ;; 5) - color_output "\e[34m[部署 Gitea-MySQL]\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[34m[部署 Gitea-MySQL]\e[0m" + else + color_output "\e[34m[Deploy Gitea-MySQL]\e[0m" + fi # 检查 Gitea 容器是否已存在 if docker ps -a | grep -q "gitea"; then - color_output "\e[33mGitea-MySQL 已经部署过,跳过部署!\e[0m" - read -p "按 Enter 键返回..." + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[33mGitea-MySQL 已经部署过,跳过部署!\e[0m" + else + color_output "\e[33mGitea-MySQL already deployed, skipping!\e[0m" + fi + read -p "$([[ "$LANG_CHOICE" == "zh" ]] && echo "按 Enter 键返回..." || echo "Press Enter to return...")" continue fi - color_output "\e[33m正在部署 Gitea 和 MySQL...\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[33m正在部署 Gitea 和 MySQL...\e[0m" + else + color_output "\e[33mDeploying Gitea and MySQL...\e[0m" + fi # 创建目录 mkdir -p /opt/Gitea @@ -714,10 +751,18 @@ install_apps() { # 检查是否下载成功 if [ -f "/opt/Gitea/docker-compose.yml" ]; then - color_output "\e[32mDocker Compose 文件下载成功!\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[32mDocker Compose 文件下载成功!\e[0m" + else + color_output "\e[32mDocker Compose file downloaded successfully!\e[0m" + fi else - color_output "\e[31mDocker Compose 文件下载失败!\e[0m" - read -p "按 Enter 键返回..." + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[31mDocker Compose 文件下载失败!\e[0m" + else + color_output "\e[31mDocker Compose file download failed!\e[0m" + fi + read -p "$([[ "$LANG_CHOICE" == "zh" ]] && echo "按 Enter 键返回..." || echo "Press Enter to return...")" continue fi @@ -726,23 +771,43 @@ install_apps() { docker-compose up -d if docker ps | grep -q "gitea"; then - color_output "\e[32mGitea-MySQL 部署成功!\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[32mGitea-MySQL 部署成功!\e[0m" + else + color_output "\e[32mGitea-MySQL deployed successfully!\e[0m" + fi else - color_output "\e[31mGitea-MySQL 部署失败!\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[31mGitea-MySQL 部署失败!\e[0m" + else + color_output "\e[31mGitea-MySQL deployment failed!\e[0m" + fi fi - read -p "按 Enter 键返回..." + read -p "$([[ "$LANG_CHOICE" == "zh" ]] && echo "按 Enter 键返回..." || echo "Press Enter to return...")" ;; 6) - color_output "\e[34m[部署 sun-panel]\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[34m[部署 sun-panel]\e[0m" + else + color_output "\e[34m[Deploy sun-panel]\e[0m" + fi # 检查 SunPanel 容器是否已存在 if docker ps -a --filter "name=sun-panel" | grep -q "sun-panel"; then - color_output "\e[33msun-panel 已经部署过,跳过部署!\e[0m" - read -p "按 Enter 键返回..." + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[33msun-panel 已经部署过,跳过部署!\e[0m" + else + color_output "\e[33msun-panel already deployed, skipping!\e[0m" + fi + read -p "$([[ "$LANG_CHOICE" == "zh" ]] && echo "按 Enter 键返回..." || echo "Press Enter to return...")" continue fi - color_output "\e[33m正在部署 SunPanel...\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[33m正在部署 SunPanel...\e[0m" + else + color_output "\e[33mDeploying SunPanel...\e[0m" + fi # 创建目录 mkdir -p /opt/sunpanel @@ -752,10 +817,18 @@ install_apps() { # 检查是否下载成功 if [ -f "/opt/sunpanel/docker-compose.yml" ]; then - color_output "\e[32mDocker Compose 文件下载成功!\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[32mDocker Compose 文件下载成功!\e[0m" + else + color_output "\e[32mDocker Compose file downloaded successfully!\e[0m" + fi else - color_output "\e[31mDocker Compose 文件下载失败!\e[0m" - read -p "按 Enter 键返回..." + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[31mDocker Compose 文件下载失败!\e[0m" + else + color_output "\e[31mDocker Compose file download failed!\e[0m" + fi + read -p "$([[ "$LANG_CHOICE" == "zh" ]] && echo "按 Enter 键返回..." || echo "Press Enter to return...")" continue fi @@ -764,36 +837,58 @@ install_apps() { docker-compose up -d if docker ps | grep -q "sun-panel"; then - color_output "\e[32msun-panel 部署成功!\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[32msun-panel 部署成功!\e[0m" + else + color_output "\e[32msun-panel deployed successfully!\e[0m" + fi else - color_output "\e[31msun-panel 部署失败!\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[31msun-panel 部署失败!\e[0m" + else + color_output "\e[31msun-panel deployment failed!\e[0m" + fi docker logs $(docker ps -a -q --filter "name=sun-panel") # 查看失败的容器日志 fi - read -p "按 Enter 键返回..." + read -p "$([[ "$LANG_CHOICE" == "zh" ]] && echo "按 Enter 键返回..." || echo "Press Enter to return...")" ;; 0) show_menu return ;; *) - color_output "\e[31m无效选项,请重新选择\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[31m无效选项,请重新选择\e[0m" + else + color_output "\e[31mInvalid option, please try again\e[0m" + fi sleep 2 ;; esac done } -# 8. IPv6 开关 +# 7. IPv6 开关 configure_ipv6() { - color_output "\e[34m[IPv6 设置]\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[34m[IPv6 设置]\e[0m" + else + color_output "\e[34m[IPv6 Settings]\e[0m" + fi # 检查是否为 PPPoE 模式 local wan_proto=$(uci -q get network.wan.proto) if [ "$wan_proto" != "pppoe" ]; then - color_output "\e[31m错误: 无法开启 IPv6\e[0m" - color_output "\e[31m当前上网方式为: $wan_proto\e[0m" - color_output "\e[31m请先切换为 PPPoE 模式\e[0m" - read -p "按 Enter 键返回菜单..." + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[31m错误: 无法开启 IPv6\e[0m" + color_output "\e[31m当前上网方式为: $wan_proto\e[0m" + color_output "\e[31m请先切换为 PPPoE 模式\e[0m" + else + color_output "\e[31mError: Cannot enable IPv6\e[0m" + color_output "\e[31mCurrent connection type: $wan_proto\e[0m" + color_output "\e[31mPlease switch to PPPoE mode first\e[0m" + fi + read -p "$([[ "$LANG_CHOICE" == "zh" ]] && echo "按 Enter 键返回菜单..." || echo "Press Enter to return to menu...")" show_menu return fi @@ -805,18 +900,26 @@ configure_ipv6() { local current_filter_aaaa=$(uci -q get dhcp.@dnsmasq[0].filter_aaaa) if [ "$current_ra" = "server" ] && [ "$current_dhcpv6" = "server" ]; then - status_text="已开启" + status_text=$([[ "$LANG_CHOICE" == "zh" ]] && echo "已开启" || echo "Enabled") else - status_text="已关闭" + status_text=$([[ "$LANG_CHOICE" == "zh" ]] && echo "已关闭" || echo "Disabled") fi - color_output "\e[36m当前 IPv6 状态: $status_text\e[0m" - color_output "\e[36m请选择操作:\e[0m" - color_output "1. 开启 IPv6" - color_output "2. 关闭 IPv6" - color_output "0. 返回主菜单" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[36m当前 IPv6 状态: $status_text\e[0m" + color_output "\e[36m请选择操作:\e[0m" + color_output "1. 开启 IPv6" + color_output "2. 关闭 IPv6" + color_output "0. 返回主菜单" + else + color_output "\e[36mCurrent IPv6 Status: $status_text\e[0m" + color_output "\e[36mSelect operation:\e[0m" + color_output "1. Enable IPv6" + color_output "2. Disable IPv6" + color_output "0. Back to Main Menu" + fi - read -p "请输入选择 [0-2]: " ipv6_choice + read -p "$([[ "$LANG_CHOICE" == "zh" ]] && echo "请输入选择 [0-2]: " || echo "Enter your choice [0-2]: ")" ipv6_choice case "$ipv6_choice" in 1) @@ -836,11 +939,19 @@ configure_ipv6() { /etc/init.d/odhcpd restart >/dev/null 2>&1 /etc/init.d/dnsmasq restart >/dev/null 2>&1 - color_output "\e[32mIPv6 已开启!\e[0m" - color_output "\e[32m- RA 服务: 服务模式\e[0m" - color_output "\e[32m- DHCPv6 服务: 服务模式\e[0m" - color_output "\e[32m- IPv6 分配长度: 64\e[0m" - color_output "\e[32m- IPv6 AAAA 记录过滤: 已关闭\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[32mIPv6 已开启!\e[0m" + color_output "\e[32m- RA 服务: 服务模式\e[0m" + color_output "\e[32m- DHCPv6 服务: 服务模式\e[0m" + color_output "\e[32m- IPv6 分配长度: 64\e[0m" + color_output "\e[32m- IPv6 AAAA 记录过滤: 已关闭\e[0m" + else + color_output "\e[32mIPv6 enabled!\e[0m" + color_output "\e[32m- RA Service: server\e[0m" + color_output "\e[32m- DHCPv6 Service: server\e[0m" + color_output "\e[32m- IPv6 Prefix Length: 64\e[0m" + color_output "\e[32m- IPv6 AAAA Filtering: disabled\e[0m" + fi ;; 2) @@ -860,11 +971,19 @@ configure_ipv6() { /etc/init.d/odhcpd restart >/dev/null 2>&1 /etc/init.d/dnsmasq restart >/dev/null 2>&1 - color_output "\e[32mIPv6 已关闭!\e[0m" - color_output "\e[32m- RA 服务: 已禁用\e[0m" - color_output "\e[32m- DHCPv6 服务: 已禁用\e[0m" - color_output "\e[32m- IPv6 分配长度: 已禁用\e[0m" - color_output "\e[32m- IPv6 AAAA 记录过滤: 已开启\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[32mIPv6 已关闭!\e[0m" + color_output "\e[32m- RA 服务: 已禁用\e[0m" + color_output "\e[32m- DHCPv6 服务: 已禁用\e[0m" + color_output "\e[32m- IPv6 分配长度: 已禁用\e[0m" + color_output "\e[32m- IPv6 AAAA 记录过滤: 已开启\e[0m" + else + color_output "\e[32mIPv6 disabled!\e[0m" + color_output "\e[32m- RA Service: disabled\e[0m" + color_output "\e[32m- DHCPv6 Service: disabled\e[0m" + color_output "\e[32m- IPv6 Prefix Length: disabled\e[0m" + color_output "\e[32m- IPv6 AAAA Filtering: enabled\e[0m" + fi ;; 0) @@ -873,44 +992,76 @@ configure_ipv6() { ;; *) - color_output "\e[31m无效选择\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[31m无效选择\e[0m" + else + color_output "\e[31mInvalid choice\e[0m" + fi ;; esac sleep 2 - read -p "按 Enter 键返回菜单..." + read -p "$([[ "$LANG_CHOICE" == "zh" ]] && echo "按 Enter 键返回菜单..." || echo "Press Enter to return to menu...")" show_menu } -# 9. iStoreOS 风格化 +# 8. iStoreOS 风格化 istore_style() { clear - color_output "\e[34m[开始安装 iStoreOS 风格化]\e[0m" - + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[34m[开始安装 iStoreOS 风格化]\e[0m" + else + color_output "\e[34m[Installing iStoreOS Styling]\e[0m" + fi # 安装 iStore 商店 - color_output "\e[34m[1/2] 正在安装 iStore 商店...\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[34m[1/2] 正在安装 iStore 商店...\e[0m" + else + color_output "\e[34m[1/2] Installing iStore App Store...\e[0m" + fi wget -qO install.sh https://git.kejizero.online/zhao/files/raw/branch/main/%20Script/iStoreOS/install.sh && chmod +x install.sh && ./install.sh - color_output "\e[32miStore 商店安装完成\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[32miStore 商店安装完成\e[0m" + else + color_output "\e[32miStore App Store installed\e[0m" + fi # 安装网络向导和首页 - color_output "\e[34m[2/2] 正在安装网络向导和首页...\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[34m[2/2] 正在安装网络向导和首页...\e[0m" + else + color_output "\e[34m[2/2] Installing QuickStart and Homepage...\e[0m" + fi is-opkg install luci-i18n-quickstart-zh-cn - color_output "\e[32m网络向导和首页安装完成\e[0m" - - color_output "\e[32m所有组件安装完成!\e[0m" - read -p "按 Enter 键返回主菜单..." + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[32m网络向导和首页安装完成\e[0m" + color_output "\e[32m所有组件安装完成!\e[0m" + else + color_output "\e[32mQuickStart and Homepage installed\e[0m" + color_output "\e[32mAll components installed successfully!\e[0m" + fi + read -p "$([[ "$LANG_CHOICE" == "zh" ]] && echo "按 Enter 键返回主菜单..." || echo "Press Enter to return to main menu...")" show_menu } -# 10. 检测更新 +# 9. 检测更新 check_update() { - color_output "\e[34m[检测更新]\e[0m" - color_output "正在检查更新..." + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[34m[检测更新]\e[0m" + color_output "正在检查更新..." + else + color_output "\e[34m[Check for Updates]\e[0m" + color_output "Checking for updates..." + fi # 检查 wget 是否安装 if ! command -v wget >/dev/null 2>&1; then - color_output "\e[33m正在安装 wget...\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[33m正在安装 wget...\e[0m" + else + color_output "\e[33mInstalling wget...\e[0m" + fi opkg update && opkg install wget fi @@ -920,9 +1071,13 @@ check_update() { # 下载远程版本文件 if ! wget -q "https://git.kejizero.online/zhao/files/raw/branch/main/bin/version.txt" -O "$temp_dir/version.txt"; then - color_output "\e[31m无法连接到更新服务器。\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[31m无法连接到更新服务器。\e[0m" + else + color_output "\e[31mFailed to connect to update server.\e[0m" + fi rm -rf "$temp_dir" - read -p "按 Enter 键返回菜单..." + read -p "$([[ "$LANG_CHOICE" == "zh" ]] && echo "按 Enter 键返回菜单..." || echo "Press Enter to return to menu...")" show_menu return fi @@ -933,11 +1088,21 @@ check_update() { # 比较版本 if [ "$local_version" != "$remote_version" ]; then - color_output "\e[33m发现新版本:$remote_version\e[0m" - color_output "\e[33m当前版本:$local_version\e[0m" - read -p "是否更新到最新版本?(y/n): " confirm + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[33m发现新版本:$remote_version\e[0m" + color_output "\e[33m当前版本:$local_version\e[0m" + read -p "是否更新到最新版本?(y/n): " confirm + else + color_output "\e[33mNew version available: $remote_version\e[0m" + color_output "\e[33mCurrent version: $local_version\e[0m" + read -p "Update to the latest version? (y/n): " confirm + fi if [[ "$confirm" == "y" || "$confirm" == "Y" ]]; then - color_output "开始下载更新..." + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "开始下载更新..." + else + color_output "Downloading update..." + fi # 下载新版本到临时文件 if wget -q "https://git.kejizero.online/zhao/files/raw/branch/main/bin/ZeroWrt" -O "$temp_dir/ZeroWrt.new"; then @@ -953,32 +1118,56 @@ check_update() { # 更新版本文件 echo "$remote_version" > /root/version.txt - color_output "\e[32m更新成功!\e[0m" - color_output "\e[32m已备份原版本为 /bin/ZeroWrt.bak\e[0m" - color_output "\e[32m请重新运行脚本以应用更新。\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[32m更新成功!\e[0m" + color_output "\e[32m已备份原版本为 /bin/ZeroWrt.bak\e[0m" + color_output "\e[32m请重新运行脚本以应用更新。\e[0m" + else + color_output "\e[32mUpdate successful!\e[0m" + color_output "\e[32mOriginal version backed up as /bin/ZeroWrt.bak\e[0m" + color_output "\e[32mPlease rerun the script to apply updates.\e[0m" + fi # 清理并退出 rm -rf "$temp_dir" exit 0 else - color_output "\e[31m下载的文件格式不正确。\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[31m下载的文件格式不正确。\e[0m" + else + color_output "\e[31mDownloaded file is not a valid script.\e[0m" + fi fi else - color_output "\e[31m更新下载失败。\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[31m更新下载失败。\e[0m" + else + color_output "\e[31mUpdate download failed.\e[0m" + fi fi else - color_output "\e[32m已取消更新。\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[32m已取消更新。\e[0m" + else + color_output "\e[32mUpdate cancelled.\e[0m" + fi fi else - color_output "\e[32m当前已是最新版本:$local_version\e[0m" + if [[ "$LANG_CHOICE" == "zh" ]]; then + color_output "\e[32m当前已是最新版本:$local_version\e[0m" + else + color_output "\e[32mAlready up to date: $local_version\e[0m" + fi fi # 清理临时文件 rm -rf "$temp_dir" - read -p "按 Enter 键返回菜单..." + read -p "$([[ "$LANG_CHOICE" == "zh" ]] && echo "按 Enter 键返回菜单..." || echo "Press Enter to return to menu...")" show_menu } -# 启动菜单 +# 主程序 +select_language +show_agreement print_header show_menu \ No newline at end of file