From e3415ea6d332b13a6a7b67755048f76e3539a8f5 Mon Sep 17 00:00:00 2001 From: zhao Date: Fri, 27 Dec 2024 10:14:35 +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 | 68 ++++++++++++++++++++++------------------------------- 1 file changed, 28 insertions(+), 40 deletions(-) diff --git a/bin/ZeroWrt b/bin/ZeroWrt index 1aa6857..f805136 100644 --- a/bin/ZeroWrt +++ b/bin/ZeroWrt @@ -270,32 +270,24 @@ install_apps() { 4) color_output "\e[34m[部署 Alist]\e[0m" - # 检查存储空间 - available_space=$(df -h / | awk 'NR==2 {print $4}' | sed 's/[A-Za-z]//g') - if [ $(echo "$available_space < 1" | bc) -eq 1 ]; then - color_output "\e[31m存储空间不足,请确保至少有 1GB 可用空间\e[0m" - color_output "\e[33m当前可用空间: ${available_space}GB\e[0m" - read -p "按 Enter 键返回..." - continue - fi - - # 检查 Docker 是否已安装 - if ! command -v docker &> /dev/null; then - color_output "\e[33m未检测到 Docker,正在安装...\e[0m" - opkg update && opkg install docker - fi - - # 创建 Alist 配置目录 - mkdir -p /etc/alist - - # 清理 Docker 缓存 - color_output "\e[33m正在清理 Docker 缓存...\e[0m" - docker system prune -af - # 检查 Alist 是否已运行 if docker ps | grep -q "alist"; then - color_output "\e[32mAlist 已经在运行\e[0m" + # 获取本机 IP 地址 + local_ip=$(ip addr show br-lan | grep -w inet | awk '{print $2}' | cut -d/ -f1) + + color_output "\e[32mAlist 已经在运行!\e[0m" + color_output "\e[33m您的访问地址:\e[0m" + color_output "\e[32mhttp://${local_ip}:5244\e[0m" else + # 检查 Docker 是否已安装 + if ! command -v docker &> /dev/null; then + color_output "\e[33m未检测到 Docker,正在安装...\e[0m" + opkg update && opkg install docker + fi + + # 创建 Alist 配置目录 + mkdir -p /etc/alist + color_output "\e[33m正在部署 Alist...\e[0m" docker run -d --restart=unless-stopped \ -v /etc/alist:/opt/alist/data \ @@ -306,25 +298,21 @@ install_apps() { --name="alist" \ xhofe/alist:latest - if [ $? -eq 0 ]; then - sleep 3 # 等待容器完全启动 - docker exec -it alist ./alist admin set password - - # 获取本机 IP 地址 - local_ip=$(ip addr show br-lan | grep -w inet | awk '{print $2}' | cut -d/ -f1) - - color_output "\e[32m\nAlist 部署完成!\e[0m" - color_output "\e[33m您的登录信息:\e[0m" - color_output "账号: \e[32madmin\e[0m" - color_output "密码: \e[32mpassword\e[0m" - color_output "\e[33m请使用浏览器访问:\e[0m" - color_output "\e[32mhttp://${local_ip}:5244\e[0m" - else - color_output "\e[31m部署失败,请检查存储空间和网络连接\e[0m" - fi + sleep 3 # 等待容器完全启动 + docker exec -it alist ./alist admin set password + + # 获取本机 IP 地址 + local_ip=$(ip addr show br-lan | grep -w inet | awk '{print $2}' | cut -d/ -f1) + + color_output "\e[32m\nAlist 部署完成!\e[0m" + color_output "\e[33m您的登录信息:\e[0m" + color_output "账号: \e[32madmin\e[0m" + color_output "密码: \e[32mpassword\e[0m" + color_output "\e[33m请使用浏览器访问:\e[0m" + color_output "\e[32mhttp://${local_ip}:5244\e[0m" fi read -p "按 Enter 键返回..." - ;; + ;; 0) show_menu return