Files
soul/部署到Kr宝塔.sh
卡若 6e276fca61 内容管理页面增强:上传/删除/API文档集成到原有admin页面
- 将"初始化数据库"和"同步到数据库"按钮替换为"上传内容"和"API接口"
- 隐藏"导入"、"导出"、"同步飞书"按钮
- 每个章节条目增加"删除"按钮
- 添加上传面板和API接口文档面板(可展开/收起)
- 保持原有侧边栏和页面风格不变

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-21 15:30:20 +08:00

53 lines
1.9 KiB
Bash
Executable File
Raw Permalink 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.

#!/bin/bash
# 部署到 Kr宝塔 (43.139.27.93):打包 → SCP(端口22022) → SSH 解压构建 → 宝塔 API 重启
# 不用 pm2 命令,用宝塔 API 操作。在「一场soul的创业实验」目录下执行。
set -e
cd "$(dirname "$0")"
SSH_PORT="22022"
BT_HOST="43.139.27.93"
BT_PORT="9988"
BT_KEY="qcWubCdlfFjS2b2DMT1lzPFaDfmv1cBT"
PROJECT_PATH="/www/wwwroot/soul"
PROJECT_NAME="soul"
echo "===== 1. 打包 ====="
tar --exclude='node_modules' --exclude='.next' --exclude='.git' -czf /tmp/soul_update.tar.gz .
echo "===== 2. 上传到 Kr宝塔 (${BT_HOST}:${SSH_PORT}) ====="
sshpass -p 'Zhiqun1984' scp -P "$SSH_PORT" /tmp/soul_update.tar.gz root@${BT_HOST}:/tmp/
echo "===== 3. SSH解压、安装、构建不执行 pm2====="
sshpass -p 'Zhiqun1984' ssh -p "$SSH_PORT" root@${BT_HOST} "
mkdir -p ${PROJECT_PATH}
cd ${PROJECT_PATH}
rm -rf app components lib public styles *.json *.js *.ts *.mjs *.md .next
tar -xzf /tmp/soul_update.tar.gz
rm /tmp/soul_update.tar.gz
export PATH=/www/server/nodejs/v22.14.0/bin:\$PATH
[ -x \"\$(command -v pnpm)\" ] || npm i -g pnpm
pnpm install
pnpm run build
"
echo "===== 4. 宝塔 API 重启 Node 项目 ${PROJECT_NAME} ====="
REQUEST_TIME=$(date +%s)
md5hex() { printf '%s' "$1" | openssl md5 2>/dev/null | awk '{print $NF}' || true; }
MD5_KEY=$(md5hex "$BT_KEY")
SIGN_STR="${REQUEST_TIME}${MD5_KEY}"
REQUEST_TOKEN=$(md5hex "$SIGN_STR")
RESP=$(curl -s -k -X POST "https://${BT_HOST}:${BT_PORT}/project/nodejs/restart_project" \
-d "request_time=${REQUEST_TIME}" \
-d "request_token=${REQUEST_TOKEN}" \
-d "project_name=${PROJECT_NAME}" 2>/dev/null || true)
if echo "$RESP" | grep -q '"status":true\|"status": true'; then
echo "宝塔 API 重启成功: $RESP"
else
echo "宝塔 API 返回(若失败请到面板 网站→Node项目→${PROJECT_NAME}→重启): $RESP"
fi
echo "===== 部署到 Kr宝塔 完成 ====="