Files
calx/bootstrap.sh
2026-07-18 16:48:41 +08:00

55 lines
1.6 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
# ============================================================
# 乘法口诀 —— 新电脑一键部署脚本macOS
# 作用:检查/安装依赖(ffmpeg + whisper-cpp) → 补齐模型 → 生成证书 → 启动服务
# 幂等:已装的会跳过,可反复运行
# ============================================================
set -e
cd "$(dirname "$0")"
echo "==== 乘法口诀 部署脚本 ===="
# 1) Node
if ! command -v node >/dev/null 2>&1; then
echo "❌ 未检测到 Node.js请先安装https://nodejs.org 或 brew install node"
exit 1
fi
echo "✅ Node $(node -v)"
# 2) Homebrew
if ! command -v brew >/dev/null 2>&1; then
echo "❌ 未检测到 Homebrew请先安装https://brew.sh"
exit 1
fi
# 3) ffmpeg + whisper-cli
NEED=""
command -v ffmpeg >/dev/null 2>&1 || NEED="$NEED ffmpeg"
command -v whisper-cli >/dev/null 2>&1 || NEED="$NEED whisper-cpp"
if [ -n "$NEED" ]; then
echo "📦 安装依赖:$NEED"
brew install $NEED
else
echo "✅ ffmpeg / whisper-cli 已就绪"
fi
# 4) 模型(缺则下载 smallbase 可选)
mkdir -p models
if [ ! -f models/ggml-small.bin ]; then
echo "⬇️ 下载 small 模型 (465MB)…"
curl -L -o models/ggml-small.bin https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small.bin
else
echo "✅ 模型 ggml-small.bin 已存在"
fi
# 5) 自签名证书iOS 语音必需)
if [ ! -f certs/cert.pem ]; then
echo "🔐 生成自签名 HTTPS 证书…"
bash gen-cert.sh
else
echo "✅ 证书已存在IP 变了请手动跑 bash gen-cert.sh 重生成)"
fi
echo ""
echo "==== 部署完成,启动服务 ===="
exec node server.js