#!/bin/bash
# ── deploy.sh ──
# 将 solution-1.0 的代码同步到实际部署位置
# 用法: bash deploy/deploy.sh
set -e
SOLUTION_DIR="$(cd "$(dirname "$0")/.." && pwd)"
echo "📦 从 $SOLUTION_DIR 部署..."
# 1. Chat Server
echo " → server/chat-server/server.py → /root/hermes_chat/server.py"
cp "$SOLUTION_DIR/server/chat-server/server.py" /root/hermes_chat/server.py
# 2. WebChat 前端
echo " → webchat/index.html → /var/www/webchat/index.html"
cp "$SOLUTION_DIR/webchat/index.html" /var/www/webchat/index.html
# 3. Task-Org 前端
echo " → task-org/index.html → /var/www/task-org/index.html"
cp "$SOLUTION_DIR/task-org/index.html" /var/www/task-org/index.html
# 4. Nginx 配置
echo " → deploy/nginx/* → /etc/nginx/sites-enabled/"
sudo cp "$SOLUTION_DIR/deploy/nginx/hermes-gateway" /etc/nginx/sites-enabled/hermes-gateway
sudo cp "$SOLUTION_DIR/deploy/nginx/assistant.conf" /etc/nginx/sites-enabled/assistant-rosicky-top
sudo cp "$SOLUTION_DIR/deploy/nginx/doc.conf" /etc/nginx/sites-enabled/doc-rosicky-top
sudo cp "$SOLUTION_DIR/deploy/nginx/org.conf" /etc/nginx/sites-enabled/org-rosicky-top
sudo cp "$SOLUTION_DIR/deploy/nginx/code.conf" /etc/nginx/sites-enabled/code-rosicky-top
# 5. 重新加载服务
echo " → nginx reload"
sudo nginx -t && sudo nginx -s reload
echo " → restart chat-server"
sudo systemctl restart hermes-chat-server
# 6. 代码浏览器
echo " → code-browser systemd"
sudo cp "$SOLUTION_DIR/deploy/systemd/code-browser.service" /etc/systemd/system/
sudo systemctl daemon-reload
if systemctl is-active code-browser >/dev/null 2>&1; then
sudo systemctl restart code-browser
else
sudo systemctl enable --now code-browser
fi
echo " → code-browser ready"
echo "✅ 部署完成"