xfvsdf/qqbot
0
1#!/bin/bash2# macOS 安装脚本 (支持 Intel 和 Apple Silicon)3 4# 确保 Homebrew 已安装5if ! command -v brew &> /dev/null; then6 echo "未检测到 Homebrew,开始安装..."7 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"8 9 # 检测 Homebrew 安装路径并设置环境变量10 if [[ -f "/opt/homebrew/bin/brew" ]]; then11 # Apple Silicon Mac12 eval "$(/opt/homebrew/bin/brew shellenv)"13 elif [[ -f "/usr/local/bin/brew" ]]; then14 # Intel Mac15 eval "$(/usr/local/bin/brew shellenv)"16 fi17fi18 19# 更新 brew 并安装 git20brew update21brew install git22 23# 安装 uv (Python 环境管理工具)24curl -Ls https://astral.sh/uv/install.sh | sh25 26# 确保 uv 在 PATH 中27export PATH="$HOME/.local/bin:$PATH"28 29# 克隆或进入项目目录30if [ -f "./web.py" ]; then31 # 已经在目标目录32 :33elif [ -f "./gcli2api/web.py" ]; then34 cd ./gcli2api35else36 git clone https://github.com/su-kaka/gcli2api.git37 cd ./gcli2api38fi39 40# 拉取最新代码41git pull42 43# 创建并同步虚拟环境44uv sync45 46# 激活虚拟环境47if [ -f ".venv/bin/activate" ]; then48 source .venv/bin/activate49else50 echo "❌ 未找到虚拟环境,请检查 uv 是否安装成功"51 exit 152fi53 54# 启动项目55python3 web.py56 