Files
aiagent/uninstall.sh
renjianbo beff3fac8d fix: delete agent 500 error + dynamic personality + deployment guide
- Fix delete agent 500: clean up FK records (agent_llm_logs, permissions,
  schedules, executions, team_members) and unbind goals/tasks before delete
- Remove hardcoded personality templates in Android, replace with dynamic
  system prompt generation from name + description
- Set promptSectionsEnabled=false to bypass PromptComposer for personality
- Add Tencent Cloud Linux deployment guide (Docker Compose)
- Accumulated backend service updates, frontend UI fixes, Android app changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-29 01:17:21 +08:00

106 lines
4.3 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# ═══════════════════════════════════════════════════════════════════════════════
# 天工智能体平台 — 卸载清理脚本
# 用法: bash uninstall.sh
# ═══════════════════════════════════════════════════════════════════════════════
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m'
info() { echo -e "${GREEN}[✓]${NC} $*"; }
warn() { echo -e "${YELLOW}[!]${NC} $*"; }
error() { echo -e "${RED}[✗]${NC} $*"; exit 1; }
COMPOSE_FILE="./docker-compose.prod.yml"
if docker compose version &>/dev/null; then
COMPOSE="docker compose"
elif command -v docker-compose &>/dev/null; then
COMPOSE="docker-compose"
else
error "未找到 Docker Compose"
fi
echo ""
echo -e "${RED}╔══════════════════════════════════════╗${NC}"
echo -e "${RED}║ 天工智能体平台 — 卸载清理 ║${NC}"
echo -e "${RED}╚══════════════════════════════════════╝${NC}"
echo ""
echo -e "${RED}⚠ 警告:此操作将停止并删除所有服务容器!${NC}"
echo ""
# ─── 1. 确认 ─────────────────────────────────────────────────────────────────
read -r -p "是否继续?(y/N): " CONFIRM
if [[ ! "$CONFIRM" =~ ^[Yy] ]]; then
info "已取消卸载"
exit 0
fi
# ─── 2. 停止并删除容器 ───────────────────────────────────────────────────────
echo ""
info "正在停止并删除容器..."
$COMPOSE -f "$COMPOSE_FILE" down --remove-orphans 2>/dev/null || true
# ─── 3. 询问是否删除数据卷 ───────────────────────────────────────────────────
echo ""
echo -e "${YELLOW}是否同时删除数据卷?${NC}"
echo " 这将删除 MySQL、Redis、工作区文件、上传文件、日志等所有数据。"
echo ""
read -r -p "删除数据卷?(y/N): " REMOVE_VOLS
if [[ "$REMOVE_VOLS" =~ ^[Yy] ]]; then
info "正在删除数据卷..."
$COMPOSE -f "$COMPOSE_FILE" down -v 2>/dev/null || true
# 同时清理项目相关的已命名卷
docker volume rm -f aiagent_mysql_data aiagent_redis_data \
aiagent_agent_workspaces aiagent_uploads aiagent_logs 2>/dev/null || true
info "数据卷已删除"
else
info "保留数据卷(重新安装时可恢复数据)"
echo " 手动删除数据卷:"
echo " docker volume rm aiagent_mysql_data aiagent_redis_data"
fi
# ─── 4. 清理镜像 ─────────────────────────────────────────────────────────────
echo ""
read -r -p "是否删除构建的镜像?(y/N): " REMOVE_IMGS
if [[ "$REMOVE_IMGS" =~ ^[Yy] ]]; then
info "正在删除镜像..."
docker images --filter "label=com.docker.compose.project=aiagent" -q 2>/dev/null | \
xargs -r docker rmi -f 2>/dev/null || true
info "镜像已删除"
else
info "保留镜像"
fi
# ─── 5. 总结 ─────────────────────────────────────────────────────────────────
echo ""
echo -e "${GREEN}卸载完成。${NC}"
echo ""
echo "已删除的内容:"
echo " - 所有服务容器"
if [[ "${REMOVE_VOLS:-no}" =~ ^[Yy] ]]; then
echo " - 数据卷MySQL/Redis/工作区/上传/日志)"
fi
if [[ "${REMOVE_IMGS:-no}" =~ ^[Yy] ]]; then
echo " - Docker 镜像"
fi
echo ""
echo "保留的文件(需手动删除):"
echo " - 项目源码: $SCRIPT_DIR"
echo " - 配置文件: $SCRIPT_DIR/backend/.env"
echo " - 备份目录: $SCRIPT_DIR/backups/"
echo ""