From 29b331c7b41c919ce665a52049bf7e2623c82231 Mon Sep 17 00:00:00 2001 From: shaw Date: Sun, 3 Aug 2025 23:16:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20manage.sh=20?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E8=BD=AF=E9=93=BE=E6=8E=A5=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E6=97=B6=E7=9A=84=E8=B7=AF=E5=BE=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复找不到脚本文件 /root/claude-relay-service/app/manage.sh 的错误 - 优先使用项目中的 $APP_DIR/scripts/manage.sh 路径 - 改进 load_config 函数以支持不同的项目目录结构 - 添加 symlink 命令执行前的检查,确保 APP_DIR 已设置 - 增加详细的诊断信息输出,方便调试路径问题 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- scripts/manage.sh | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/scripts/manage.sh b/scripts/manage.sh index e0000a40..01a1550e 100644 --- a/scripts/manage.sh +++ b/scripts/manage.sh @@ -938,7 +938,14 @@ handle_menu_choice() { create_symlink() { # 获取脚本的绝对路径 local script_path="" - if command_exists realpath; then + + # 优先使用项目中的 manage.sh(在 app/scripts 目录下) + if [ -n "$APP_DIR" ] && [ -f "$APP_DIR/scripts/manage.sh" ]; then + script_path="$APP_DIR/scripts/manage.sh" + elif [ -f "/app/scripts/manage.sh" ] && [ "$(basename "$0")" = "manage.sh" ]; then + # Docker 容器中的路径 + script_path="/app/scripts/manage.sh" + elif command_exists realpath; then script_path="$(realpath "$0")" elif command_exists readlink && readlink -f "$0" >/dev/null 2>&1; then script_path="$(readlink -f "$0")" @@ -950,11 +957,22 @@ create_symlink() { local symlink_path="/usr/bin/crs" print_info "创建命令行快捷方式..." + print_info "APP_DIR: $APP_DIR" print_info "脚本路径: $script_path" # 检查脚本文件是否存在 if [ ! -f "$script_path" ]; then print_error "找不到脚本文件: $script_path" + print_info "当前目录: $(pwd)" + print_info "脚本参数 \$0: $0" + if [ -n "$APP_DIR" ]; then + print_info "检查项目目录结构:" + ls -la "$APP_DIR/" 2>/dev/null | head -5 + if [ -d "$APP_DIR/scripts" ]; then + print_info "scripts 目录内容:" + ls -la "$APP_DIR/scripts/" 2>/dev/null | grep manage.sh + fi + fi return 1 fi @@ -1004,7 +1022,15 @@ load_config() { fi if [ -n "$INSTALL_DIR" ]; then - APP_DIR="$INSTALL_DIR/app" + # 检查是否使用了标准的安装结构(项目在 app 子目录) + if [ -d "$INSTALL_DIR/app" ] && [ -f "$INSTALL_DIR/app/package.json" ]; then + APP_DIR="$INSTALL_DIR/app" + # 检查是否直接克隆了项目(项目在根目录) + elif [ -f "$INSTALL_DIR/package.json" ]; then + APP_DIR="$INSTALL_DIR" + else + APP_DIR="$INSTALL_DIR/app" + fi # 加载.env配置 if [ -f "$APP_DIR/.env" ]; then @@ -1077,6 +1103,12 @@ main() { ;; symlink) # 单独创建软链接 + # 确保 APP_DIR 已设置 + if [ -z "$APP_DIR" ]; then + print_error "请先安装项目后再创建软链接" + print_info "运行: $0 install" + exit 1 + fi create_symlink ;; help)