Files
chenproject/deploy.sh
2026-10-12 15:14:13 +08:00

32 lines
1.2 KiB
Bash
Executable File
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
# deploy.sh —— 构建并部署展示网站到 chenxy.biboer.cn
# 用法:./deploy.sh 构建 + 上传 + nginx 检查
# ./deploy.sh local 仅同步 core 到 web/py(本地预览用)
set -euo pipefail
REMOTE_HOST="web" # ssh config 中的主机别名
SITE_DIR="/var/www/chenxy" # 服务器站点目录
DOMAIN="chenxy.biboer.cn"
echo "[1/4] 同步算法核心 fiber_delay_sim -> web/py/"
rsync -a --delete --exclude '__pycache__' --exclude 'tests' \
--exclude 'experiments' --exclude 'export' --exclude 'cli.py' \
fiber_delay_sim/ web/py/fiber_delay_sim/
if [ "${1:-}" = "local" ]; then
echo "[done] 本地预览:python3 -m http.server -d web 8765 → http://localhost:8765"
exit 0
fi
echo "[2/4] 上传 web/ -> ${REMOTE_HOST}:${SITE_DIR}/"
ssh "$REMOTE_HOST" "mkdir -p ${SITE_DIR}"
rsync -az --delete web/ "$REMOTE_HOST:${SITE_DIR}/"
echo "[3/4] 检查 nginx 站点配置(${DOMAIN})"
ssh "$REMOTE_HOST" "test -f /etc/nginx/conf.d/${DOMAIN}.conf && echo 'conf 存在' || echo 'conf 缺失'"
echo "[4/4] 验证站点"
sleep 1
curl -sI "https://${DOMAIN}" | head -5
echo "[done] 部署完成:https://${DOMAIN}"