From 4e28336d4acaf4040d8f9540edfc33424d7c4857 Mon Sep 17 00:00:00 2001 From: zhao Date: Fri, 27 Dec 2024 12:22:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20bin/ZeroWrt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhao --- bin/ZeroWrt | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/bin/ZeroWrt b/bin/ZeroWrt index 1b8608a..97845a1 100644 --- a/bin/ZeroWrt +++ b/bin/ZeroWrt @@ -163,13 +163,14 @@ install_apps() { 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 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 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")" app_choice + read -p "$(color_output "\e[33m请输入您的选择 [0-4]: \e[0m")" app_choice case "$app_choice" in 1) @@ -266,6 +267,47 @@ install_apps() { fi read -p "按 Enter 键返回..." ;; + 4) + color_output "\e[34m[部署 AdGuardHome]\e[0m" + + # 检查 Docker 是否已安装 + if ! command -v docker &> /dev/null; then + color_output "\e[33m未检测到 Docker,正在安装...\e[0m" + opkg update && opkg install docker + fi + + # 获取本机 IP 地址 + local_ip=$(ip addr show br-lan | grep -w inet | awk '{print $2}' | cut -d/ -f1) + + # 检查 AdGuardHome 是否已运行 + if docker ps | grep -q "adguardhome"; then + color_output "\e[32mAdGuardHome 已经在运行!\e[0m" + color_output "\e[33m请使用浏览器访问:\e[0m" + color_output "\e[32mhttp://${local_ip}:3000\e[0m" + else + color_output "\e[33m正在部署 AdGuardHome...\e[0m" + + # 创建配置目录 + mkdir -p /root/adguardhome/work /root/adguardhome/conf + + # 部署 AdGuardHome + if docker run -d \ + --name adguardhome \ + -v /root/adguardhome/work:/opt/adguardhome/work \ + -v /root/adguardhome/conf:/opt/adguardhome/conf \ + -p 3000:3000 \ + --restart always \ + adguard/adguardhome; then + + color_output "\e[32m\nAdGuardHome 部署成功!\e[0m" + color_output "\e[33m请使用浏览器访问以下地址进行配置:\e[0m" + color_output "\e[32mhttp://${local_ip}:3000\e[0m" + else + color_output "\e[31mAdGuardHome 部署失败\e[0m" + fi + fi + read -p "按 Enter 键返回..." + ;; 0) show_menu return