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

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

53 lines
1.8 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.

#!/bin/bash
# 1) 以本地为准推送到 GitHub yongpxu-soul
# 2) 打包 → SCP 上传 → SSH 解压并 pnpm install + build
# 3) 使用宝塔 API 重启 Node 项目(不用 pm2 命令)
# 在「一场soul的创业实验」目录下执行
set -e
cd "$(dirname "$0")"
echo "===== 1. 推送到 GitHub以本地为准====="
git push origin yongpxu-soul --force-with-lease
echo "===== 2. 打包 ====="
tar --exclude='node_modules' --exclude='.next' --exclude='.git' -czf /tmp/soul_update.tar.gz .
echo "===== 3. 上传到宝塔服务器 ====="
sshpass -p 'Zhiqun1984' scp /tmp/soul_update.tar.gz root@42.194.232.22:/tmp/
echo "===== 4. SSH解压、安装、构建不执行 pm2====="
sshpass -p 'Zhiqun1984' ssh root@42.194.232.22 "
cd /www/wwwroot/soul
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
pnpm install
pnpm run build
"
echo "===== 5. 宝塔 API 重启 Node 项目 soul ====="
BT_HOST="42.194.232.22"
BT_PORT="9988"
BT_KEY="hsAWqFSi0GOCrunhmYdkxy92tBXfqYjd"
REQUEST_TIME=$(date +%s)
# request_token = md5( request_time + md5(api_key) ),兼容 macOS/Linux
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=soul" 2>/dev/null || true)
if echo "$RESP" | grep -q '"status":true\|"status": true'; then
echo "宝塔 API 重启成功: $RESP"
else
echo "宝塔 API 返回(若失败请到面板手动重启): $RESP"
fi
echo "===== 部署完成 ====="