#!/usr/bin/env bash # 新成员一键初始化: # 1. 克隆 6 个业务仓库到 REPOS_DIR(默认为 ai-ops 的父目录) # 2. 创建 .env(如果还没有) # 3. 构建 Docker 镜像 set -euo pipefail cd "$(dirname "$0")/.." AI_OPS_DIR="$(pwd)" # 读取 .env 里的 REPOS_DIR(如果存在) if [[ -f .env ]]; then # shellcheck disable=SC1091 source <(grep -E '^REPOS_DIR=' .env || true) fi REPOS_DIR="${REPOS_DIR:-$(cd .. && pwd)}" echo ">>> 仓库将克隆到: $REPOS_DIR" mkdir -p "$REPOS_DIR" declare -A REPOS=( [chat-gw]="https://github.com/Fasthei/chat-gw.git" [xiaoshou]="https://github.com/Fasthei/xiaoshou.git" [gongdan]="https://github.com/Fasthei/gongdan.git" [casdoor-internal]="https://github.com/zsbgnw12/casdoor-internal.git" [CloudCostbrank]="https://github.com/zsbgnw12/CloudCostbrank.git" [lobechat-enterprise]="https://github.com/zsbgnw12/lobechat-enterprise.git" ) for name in "${!REPOS[@]}"; do target="$REPOS_DIR/$name" if [[ -d "$target/.git" ]]; then echo " [skip] $name 已存在" else echo " [clone] $name" git clone "${REPOS[$name]}" "$target" fi done cd "$AI_OPS_DIR" if [[ ! -f .env ]]; then cp .env.example .env echo ">>> 已创建 .env(订阅模式无需改动;用 API Key 的话填上 ANTHROPIC_API_KEY)" fi echo ">>> 构建镜像(首次约 5 分钟)" docker compose build echo "" echo ">>> 完成。下一步:" echo " ./scripts/enter.sh # 进入容器" echo " 容器内运行 /login # 用你自己的 Claude Max/Pro 订阅登录"