-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·212 lines (185 loc) · 6.15 KB
/
setup.sh
File metadata and controls
executable file
·212 lines (185 loc) · 6.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#!/bin/bash
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
# ============================================================
# podcli — Install & Launch
# Usage:
# ./setup.sh # Install everything + open UI
# ./setup.sh --install # Install only (no launch)
# ./setup.sh --ui # Launch UI only (skip install)
# ./setup.sh --mcp # Show MCP config (for Claude Desktop/Code)
# ============================================================
MODE="${1:-full}"
echo ""
echo " ╔══════════════════════════════════════╗"
echo " ║ 🎬 podcli v1.0 ║"
echo " ╚══════════════════════════════════════╝"
echo ""
# ---- Install ----
install() {
echo "━━━ [1/6] Checking system dependencies ━━━"
local MISSING=0
if ! command -v ffmpeg &>/dev/null; then
echo " ✗ FFmpeg not found"
echo " → macOS: brew install ffmpeg"
echo " → Ubuntu: sudo apt install ffmpeg"
echo " → Windows: choco install ffmpeg"
MISSING=1
else
echo " ✓ FFmpeg"
fi
if ! command -v python3 &>/dev/null; then
echo " ✗ Python 3 not found"
MISSING=1
else
echo " ✓ Python $(python3 --version 2>&1 | awk '{print $2}')"
fi
if ! command -v node &>/dev/null; then
echo " ✗ Node.js not found"
MISSING=1
else
echo " ✓ Node $(node --version)"
fi
if [ "$MISSING" -eq 1 ]; then
echo ""
echo " Please install the missing dependencies above and re-run."
exit 1
fi
echo ""
echo "━━━ [2/6] Creating directories ━━━"
CLIPPER_HOME="${PODCLI_HOME:-$SCRIPT_DIR/.podcli}"
DATA_DIR="${PODCLI_DATA:-$SCRIPT_DIR/data}"
mkdir -p "$CLIPPER_HOME"/{assets,history,knowledge}
mkdir -p "$DATA_DIR"/{cache/transcripts,working,working/uploads,output,logs}
echo " ✓ $CLIPPER_HOME (internal)"
echo " ✓ $DATA_DIR (output & cache)"
# Download DNN face detection model if missing
MODEL_DIR="$SCRIPT_DIR/backend/models"
mkdir -p "$MODEL_DIR"
if [ ! -f "$MODEL_DIR/res10_300x300_ssd_iter_140000.caffemodel" ]; then
echo " ↓ Downloading face detection model..."
curl -sL -o "$MODEL_DIR/deploy.prototxt" \
"https://raw.githubusercontent.com/opencv/opencv/master/samples/dnn/face_detector/deploy.prototxt"
curl -sL -o "$MODEL_DIR/res10_300x300_ssd_iter_140000.caffemodel" \
"https://raw.githubusercontent.com/opencv/opencv_3rdparty/dnn_samples_face_detector_20170830/res10_300x300_ssd_iter_140000.caffemodel"
echo " ✓ Face detection model ready"
else
echo " ✓ Face detection model exists"
fi
echo ""
echo "━━━ [3/6] Python virtual environment ━━━"
if [ ! -d "venv" ]; then
python3 -m venv venv
echo " ✓ Created venv"
else
echo " ✓ venv exists"
fi
source venv/bin/activate
echo ""
echo "━━━ [4/6] Installing Python packages ━━━"
pip install -q --upgrade pip
pip install -q -r backend/requirements.txt 2>&1 | tail -3
echo " ✓ Python packages ready"
# Fix macOS SSL certificates (needed for Whisper model download)
if [[ "$OSTYPE" == "darwin"* ]]; then
PY_VER=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
CERT_SCRIPT="/Applications/Python ${PY_VER}/Install Certificates.command"
if [ -f "$CERT_SCRIPT" ]; then
echo " → Configuring SSL certificates..."
bash "$CERT_SCRIPT" > /dev/null 2>&1 || true
echo " ✓ SSL certificates configured"
fi
fi
echo ""
echo "━━━ [5/6] Installing Node packages ━━━"
npm install --silent 2>&1 | tail -1
echo " ✓ Node packages ready"
echo ""
echo "━━━ [6/6] Building TypeScript ━━━"
npx tsc
echo " ✓ Build complete"
# Create .env
VENV_PYTHON="$(pwd)/venv/bin/python3"
if [ ! -f .env ]; then
cp .env.example .env
fi
# Always update PYTHON_PATH to point at venv (handles re-runs)
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s|^PYTHON_PATH=.*|PYTHON_PATH=$VENV_PYTHON|" .env
else
sed -i "s|^PYTHON_PATH=.*|PYTHON_PATH=$VENV_PYTHON|" .env
fi
echo " ✓ .env configured (python: $VENV_PYTHON)"
# Copy public assets to dist
mkdir -p dist/ui/public
cp -r src/ui/public/* dist/ui/public/
echo ""
echo " ✅ Installation complete!"
echo ""
}
# ---- Launch UI ----
launch_ui() {
echo " Starting web UI..."
echo ""
# Ensure public files are in dist
mkdir -p dist/ui/public
cp -r src/ui/public/* dist/ui/public/ 2>/dev/null || true
# Always use venv python (absolute path, no spaces issue)
if [ -f "venv/bin/python3" ]; then
export PYTHON_PATH="$(cd "$(pwd)" && pwd)/venv/bin/python3"
echo " Using Python: $PYTHON_PATH"
fi
# Load .env (line-by-line to handle spaces in values)
if [ -f .env ]; then
while IFS='=' read -r key value; do
# Skip comments and empty lines
[[ "$key" =~ ^#.*$ || -z "$key" ]] && continue
# PYTHON_PATH from venv takes priority over .env
[[ "$key" == "PYTHON_PATH" ]] && continue
export "$key=$value"
done < .env
fi
exec npx tsx src/ui/web-server.ts
}
# ---- Show MCP config ----
show_mcp() {
VENV_PYTHON="$(pwd)/venv/bin/python3"
echo " ── Claude Desktop config ──"
echo " Add to ~/Library/Application Support/Claude/claude_desktop_config.json:"
echo ""
echo " {"
echo " \"mcpServers\": {"
echo " \"podcli\": {"
echo " \"command\": \"node\","
echo " \"args\": [\"$(pwd)/dist/index.js\"],"
echo " \"env\": {"
echo " \"PYTHON_PATH\": \"$VENV_PYTHON\""
echo " }"
echo " }"
echo " }"
echo " }"
echo ""
echo " ── Claude Code ──"
echo " claude mcp add podcli -- node $(pwd)/dist/index.js"
echo ""
}
# ---- Route ----
case "$MODE" in
--install)
install
;;
--ui)
launch_ui
;;
--mcp)
show_mcp
;;
full|*)
install
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
launch_ui
;;
esac