#!/bin/bash
# 快速部署脚本

echo "=== 快速部署云盘后端 ==="

# 基础检查
if [ ! -f "main.py" ]; then
    echo "错误: 请在包含main.py的目录运行"
    exit 1
fi

# 创建虚拟环境
python3 -m venv venv
source venv/bin/activate

# 安装依赖
pip install fastapi uvicorn sqlalchemy pymysql redis python-jose passlib python-multipart pydantic pydantic-settings httpx python-dotenv loguru

# 配置环境
if [ ! -f ".env" ]; then
    cat > .env << EOF
ENVIRONMENT=production
DEBUG=false
DATABASE_URL=mysql+pymysql://root:password@localhost:3306/test_db
REDIS_URL=redis://localhost:6379
JWT_SECRET_KEY=your-secret-key-here
JWT_EXPIRE_MINUTES=30
UPLOAD_DIR=uploads
MAX_FILE_SIZE=10485760
ALLOWED_HOSTS=["*"]
EOF
    echo "✓ 已创建 .env 配置文件"
fi

# 创建目录
mkdir -p logs uploads

# 启动服务
echo "启动服务..."
python main.py