Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·493 lines (441 loc) · 16.5 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·493 lines (441 loc) · 16.5 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
#!/usr/bin/env bash
#
# Uschi installer — single-shot TUI wizard.
#
# Usage:
# ./install.sh # interactive wizard
# ./install.sh --pi # Raspberry Pi mode (skip dashboard build)
# ./install.sh --reconfig # update .env values without rebuilding everything
#
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
# --- Colors (only when stdout is a TTY) ---
if [[ -t 1 ]]; then
C_RESET=$'\033[0m'
C_BOLD=$'\033[1m'
C_DIM=$'\033[2m'
C_RED=$'\033[31m'
C_GREEN=$'\033[32m'
C_YELLOW=$'\033[33m'
C_BLUE=$'\033[34m'
C_MAGENTA=$'\033[35m'
C_CYAN=$'\033[36m'
else
C_RESET=""; C_BOLD=""; C_DIM=""; C_RED=""; C_GREEN=""; C_YELLOW=""; C_BLUE=""; C_MAGENTA=""; C_CYAN=""
fi
say() { printf "%s\n" "$*"; }
ok() { printf "%s✓%s %s\n" "$C_GREEN" "$C_RESET" "$*"; }
warn() { printf "%s!%s %s\n" "$C_YELLOW" "$C_RESET" "$*"; }
err() { printf "%s✗%s %s\n" "$C_RED" "$C_RESET" "$*" >&2; }
hr() { printf "%s%s%s\n" "$C_DIM" "────────────────────────────────────────────────────────────" "$C_RESET"; }
ask() {
# ask "Question" "default" -> echoes user response (or default)
local prompt="$1"
local default="${2-}"
local answer
if [[ -n "$default" ]]; then
printf "%s%s%s [%s%s%s]: " "$C_BOLD" "$prompt" "$C_RESET" "$C_CYAN" "$default" "$C_RESET" >&2
else
printf "%s%s%s: " "$C_BOLD" "$prompt" "$C_RESET" >&2
fi
read -r answer
printf "%s" "${answer:-$default}"
}
ask_secret() {
local prompt="$1"
local answer
printf "%s%s%s: " "$C_BOLD" "$prompt" "$C_RESET" >&2
read -rs answer
printf "\n" >&2
printf "%s" "$answer"
}
confirm() {
# confirm "Question" -> exits 0 on yes
local prompt="$1"
local answer
printf "%s%s%s [y/N]: " "$C_BOLD" "$prompt" "$C_RESET" >&2
read -r answer
[[ "$answer" =~ ^[yY] ]]
}
press_enter() {
printf "%sPress Enter to continue...%s" "$C_DIM" "$C_RESET" >&2
read -r _
}
# --- Parse flags ---
MODE=""
RECONFIG=false
for arg in "$@"; do
case "$arg" in
--pi|--raspberry-pi) MODE="raspberry-pi" ;;
--server) MODE="server" ;;
--local) MODE="local" ;;
--reconfig) RECONFIG=true ;;
-h|--help)
cat <<EOF
Uschi installer
Usage:
./install.sh [--local|--server|--pi] [--reconfig]
Options:
--local Set up everything on this machine (default).
--server Run on a server with a public domain (Caddy + auto-TLS).
--pi Set up the Raspberry Pi smart-speaker client only.
--reconfig Update .env values without rebuilding the whole stack.
-h, --help Show this help.
EOF
exit 0
;;
esac
done
# ============================================================================
# Welcome screen
# ============================================================================
clear || true
cat <<EOF
${C_MAGENTA}${C_BOLD}
__
.' '.
/ o o \\ ${C_RESET}${C_BOLD}Hi! I'm Uschi.${C_MAGENTA}
| __ |
\\ \\__/ /
'.____.'
${C_RESET}
${C_BOLD}Welcome.${C_RESET} Let's get you set up. This takes about five minutes.
You're installing two friends:
${C_CYAN}Uschi${C_RESET} — the voice. She listens, talks, and speaks Gemini.
${C_CYAN}Klaus${C_RESET} — the brain. He runs tasks in the background via OpenClaw.
They work together as a team. Uschi handles the conversation; Klaus handles
the actual work (research, sending messages, calling APIs, etc.).
EOF
press_enter
# ============================================================================
# Prerequisite check
# ============================================================================
hr
say "${C_BOLD}Step 1 — checking prerequisites${C_RESET}"
hr
missing=()
for cmd in docker curl git openssl; do
if ! command -v "$cmd" >/dev/null 2>&1; then
missing+=("$cmd")
fi
done
# docker compose is a subcommand, check separately
if ! docker compose version >/dev/null 2>&1; then
missing+=("docker-compose-v2")
fi
if [[ ${#missing[@]} -gt 0 ]]; then
err "The following prerequisites are missing: ${missing[*]}"
say ""
say "Install them and re-run this script. On Debian/Ubuntu:"
say " ${C_DIM}sudo apt update && sudo apt install -y docker.io docker-compose-v2 curl git openssl${C_RESET}"
say "On Fedora:"
say " ${C_DIM}sudo dnf install -y docker docker-compose curl git openssl${C_RESET}"
say "On macOS:"
say " ${C_DIM}brew install docker docker-compose curl git openssl${C_RESET}"
exit 1
fi
ok "All prerequisites are installed."
# ============================================================================
# Deployment mode
# ============================================================================
if [[ -z "$MODE" ]]; then
hr
say "${C_BOLD}Step 2 — pick a deployment mode${C_RESET}"
hr
say " ${C_CYAN}1)${C_RESET} ${C_BOLD}local${C_RESET} Run everything on this machine. Best for trying it out."
say " ${C_CYAN}2)${C_RESET} ${C_BOLD}server${C_RESET} Run on a public server with HTTPS via Caddy."
say " ${C_CYAN}3)${C_RESET} ${C_BOLD}raspberry-pi${C_RESET} Smart-speaker client only (no Docker stack)."
say ""
while true; do
choice="$(ask "Choose 1, 2, or 3" "1")"
case "$choice" in
1|local) MODE="local"; break ;;
2|server) MODE="server"; break ;;
3|pi|raspberry-pi) MODE="raspberry-pi"; break ;;
*) warn "Pick 1, 2, or 3." ;;
esac
done
fi
ok "Mode: $MODE"
# ============================================================================
# Raspberry Pi branch — runs the Pi client only, then exits.
# ============================================================================
if [[ "$MODE" == "raspberry-pi" ]]; then
hr
say "${C_BOLD}Raspberry Pi smart-speaker setup${C_RESET}"
hr
say "This installs only the Pi client. You also need a separate machine"
say "running the main Uschi stack — point this Pi at it."
say ""
PI_LIVEKIT_URL="$(ask "LiveKit server URL" "ws://uschi-server.local:7880")"
PI_LK_KEY="$(ask "LiveKit API key from your server's .env" "")"
PI_LK_SECRET="$(ask_secret "LiveKit API secret from your server's .env")"
say ""
say "Picovoice provides the wake-word detection. It's free for personal use."
say "1) Sign up at ${C_CYAN}https://console.picovoice.ai/${C_RESET}"
say "2) Copy your AccessKey."
say "3) (Optional) Train a custom wake word and download the .ppn file."
say ""
PV_KEY="$(ask_secret "Picovoice AccessKey")"
PPN_PATH="$(ask "Path to your .ppn wake-word file" "./uschi.ppn")"
if [[ -f pi-client/.env ]]; then
warn "pi-client/.env already exists."
if ! confirm "Overwrite it?"; then
err "Aborted."
exit 1
fi
cp pi-client/.env "pi-client/.env.backup.$(date +%s)"
ok "Backed up previous pi-client/.env"
fi
cat > pi-client/.env <<EOF
LIVEKIT_URL=${PI_LIVEKIT_URL}
LIVEKIT_API_KEY=${PI_LK_KEY}
LIVEKIT_API_SECRET=${PI_LK_SECRET}
PICOVOICE_ACCESS_KEY=${PV_KEY}
WAKEWORD_PATH=${PPN_PATH}
GEMINI_VOICE=Kore
SILENCE_TIMEOUT=15
SILENCE_THRESHOLD=300
EOF
ok "Wrote pi-client/.env"
say ""
say "Next, install the Python dependencies:"
say " ${C_DIM}cd pi-client && python3 -m venv .venv && . .venv/bin/activate${C_RESET}"
say " ${C_DIM}pip install -r requirements.txt${C_RESET}"
say ""
say "Then run it:"
say " ${C_DIM}python uschi_pi.py${C_RESET}"
say ""
say "To run it on boot, install the systemd unit (see docs/02-install.md)."
exit 0
fi
# ============================================================================
# OpenClaw setup
# ============================================================================
hr
say "${C_BOLD}Step 3 — Klaus's brain (OpenClaw)${C_RESET}"
hr
say "Klaus runs on OpenClaw. OpenClaw has its own setup wizard that handles"
say "your LLM subscription and tool configuration. We'll hand you over to it"
say "now — once it's done, you'll come back here and finish the Uschi setup."
say ""
say "If OpenClaw is already configured, you can skip this step."
say ""
OPENCLAW_DIR="$SCRIPT_DIR/openclaw/config"
OPENCLAW_WORKSPACE="$SCRIPT_DIR/openclaw/workspace"
mkdir -p "$OPENCLAW_DIR" "$OPENCLAW_WORKSPACE"
if [[ -d "$OPENCLAW_DIR/.openclaw" || -f "$OPENCLAW_DIR/config.json" ]]; then
ok "OpenClaw already configured at openclaw/config/"
else
if confirm "Run the OpenClaw setup wizard now?"; then
say "Opening OpenClaw setup..."
if command -v openclaw >/dev/null 2>&1; then
openclaw setup --workspace "$OPENCLAW_WORKSPACE" || warn "OpenClaw setup exited non-zero. You can re-run it later."
else
warn "The 'openclaw' command isn't installed on this machine."
say "Install it from https://openclaw.dev/install and run:"
say " ${C_DIM}openclaw setup --workspace $OPENCLAW_WORKSPACE${C_RESET}"
say "Then re-run ./install.sh and skip this step."
if ! confirm "Continue anyway? Klaus won't work until OpenClaw is configured"; then
exit 1
fi
fi
else
warn "Skipping OpenClaw setup. Klaus won't work until you configure it later."
fi
fi
# Seed workspace with templates if it's empty
for f in VOICE.md USCHI_MEMORY.md MEMORY.md TOOLS.md; do
if [[ ! -f "$OPENCLAW_WORKSPACE/$f" && -f "$SCRIPT_DIR/workspace-templates/$f" ]]; then
cp "$SCRIPT_DIR/workspace-templates/$f" "$OPENCLAW_WORKSPACE/$f"
ok "Seeded $f from template"
fi
done
if [[ ! -f "$OPENCLAW_WORKSPACE/devices.yaml" && -f "$SCRIPT_DIR/workspace-templates/devices.example.yaml" ]]; then
cp "$SCRIPT_DIR/workspace-templates/devices.example.yaml" "$OPENCLAW_WORKSPACE/devices.yaml"
ok "Seeded devices.yaml from example"
fi
# ============================================================================
# Google API key
# ============================================================================
hr
say "${C_BOLD}Step 4 — Google Gemini API key${C_RESET}"
hr
say "Uschi uses Google Gemini Live for speech. It's the only API key she needs."
say ""
say "1) Open ${C_CYAN}https://aistudio.google.com/apikey${C_RESET} in your browser."
say "2) Click 'Create API key'. There's a free tier — you don't need to pay."
say "3) Copy the key and paste it below."
say ""
GOOGLE_KEY="$(ask_secret "Google API key (input hidden)")"
if [[ -z "$GOOGLE_KEY" ]]; then
err "Empty Google API key. Re-run when you have one."
exit 1
fi
# Quick validation ping (best-effort)
say -n "Validating key... "
if curl -sf -o /dev/null \
"https://generativelanguage.googleapis.com/v1beta/models?key=${GOOGLE_KEY}"; then
ok "key works"
else
warn "couldn't reach Google to validate. If your network is offline that's fine; otherwise double-check the key later."
fi
# ============================================================================
# LiveKit secrets (auto-generated)
# ============================================================================
hr
say "${C_BOLD}Step 5 — LiveKit credentials${C_RESET}"
hr
LIVEKIT_API_KEY="APIuschi$(openssl rand -hex 4)"
LIVEKIT_API_SECRET="$(openssl rand -base64 32 | tr -d '=/+\n' | head -c 40)"
OPENCLAW_GATEWAY_TOKEN="$(openssl rand -hex 32)"
DASHBOARD_PASSWORD="$(openssl rand -base64 12 | tr -d '=/+\n' | head -c 16)"
ok "Generated LiveKit API key, secret, OpenClaw gateway token, and dashboard password."
# ============================================================================
# Server-mode extras
# ============================================================================
PUBLIC_HOST=""
PUBLIC_EMAIL=""
if [[ "$MODE" == "server" ]]; then
hr
say "${C_BOLD}Step 6 — public hostname (server mode)${C_RESET}"
hr
say "We'll spin up Caddy as a reverse proxy and let it issue a TLS"
say "certificate via Let's Encrypt. Make sure your DNS already points"
say "to this server before continuing."
say ""
PUBLIC_HOST="$(ask "Public hostname (e.g. uschi.example.com)" "")"
PUBLIC_EMAIL="$(ask "Email for Let's Encrypt notifications" "")"
fi
# ============================================================================
# Personality picker
# ============================================================================
hr
say "${C_BOLD}Step 7 — personality${C_RESET}"
hr
ASSISTANT_NAME="$(ask "What should your assistant call itself?" "Uschi")"
say ""
say "Pick a Gemini voice:"
say " ${C_CYAN}Aoede${C_RESET} — breezy, friendly"
say " ${C_CYAN}Charon${C_RESET} — informative, calm"
say " ${C_CYAN}Fenrir${C_RESET} — excitable, energetic"
say " ${C_CYAN}Kore${C_RESET} — firm, warm (default)"
say " ${C_CYAN}Puck${C_RESET} — upbeat, playful"
GEMINI_VOICE="$(ask "Voice" "Kore")"
ASSISTANT_LANGUAGE="$(ask "Spoken language code (en, de, fr, es, it, ...)" "en")"
ASSISTANT_TIMEZONE="$(ask "Timezone (e.g. UTC, Europe/Berlin, America/New_York)" "UTC")"
# ============================================================================
# Write .env
# ============================================================================
hr
say "${C_BOLD}Step 8 — writing .env${C_RESET}"
hr
if [[ -f .env ]] && ! $RECONFIG; then
warn ".env already exists."
if ! confirm "Overwrite it?"; then
err "Aborted."
exit 1
fi
backup_path=".env.backup.$(date +%s)"
cp .env "$backup_path"
ok "Backed up previous .env to $backup_path"
fi
cat > .env <<EOF
# Generated by install.sh on $(date)
# Do not commit this file.
GOOGLE_API_KEY=${GOOGLE_KEY}
LIVEKIT_API_KEY=${LIVEKIT_API_KEY}
LIVEKIT_API_SECRET=${LIVEKIT_API_SECRET}
LIVEKIT_URL=ws://livekit-server:7880
LIVEKIT_PUBLIC_URL=ws://localhost:7880
OPENCLAW_GATEWAY_TOKEN=${OPENCLAW_GATEWAY_TOKEN}
DASHBOARD_PASSWORD=${DASHBOARD_PASSWORD}
ASSISTANT_NAME=${ASSISTANT_NAME}
ASSISTANT_LANGUAGE=${ASSISTANT_LANGUAGE}
ASSISTANT_TIMEZONE=${ASSISTANT_TIMEZONE}
GEMINI_VOICE=${GEMINI_VOICE}
PUBLIC_HOST=${PUBLIC_HOST}
PUBLIC_EMAIL=${PUBLIC_EMAIL}
EOF
chmod 600 .env
ok "Wrote .env"
# ============================================================================
# Build & start
# ============================================================================
hr
say "${C_BOLD}Step 9 — building and starting the stack${C_RESET}"
hr
say "This may take a few minutes the first time (Docker has to pull images"
say "and build the agent container)."
say ""
COMPOSE_FILES=(-f docker-compose.yml)
if [[ "$MODE" == "server" ]]; then
if [[ -f docker-compose.server.yml ]]; then
COMPOSE_FILES+=(-f docker-compose.server.yml)
fi
fi
if ! docker compose "${COMPOSE_FILES[@]}" build; then
err "Docker build failed. Scroll up for the actual error."
err "See docs/05-troubleshooting.md (section 'Docker build failed') for help."
exit 1
fi
if ! docker compose "${COMPOSE_FILES[@]}" up -d; then
err "Docker failed to start the stack."
err "Run 'docker compose ${COMPOSE_FILES[*]} logs' to see what went wrong,"
err "or check docs/05-troubleshooting.md."
exit 1
fi
# ============================================================================
# Health checks
# ============================================================================
hr
say "${C_BOLD}Health checks${C_RESET}"
hr
livekit_ok=0
for i in 1 2 3 4 5 6; do
if curl -sf -o /dev/null http://localhost:7880; then
livekit_ok=1
break
fi
sleep 2
done
if [[ $livekit_ok -eq 1 ]]; then
ok "LiveKit server is responding."
else
err "LiveKit server didn't come up after 12 seconds."
err "Run 'docker compose ${COMPOSE_FILES[*]} logs livekit-server' to see why,"
err "and check docs/05-troubleshooting.md (section 'LiveKit server isn't responding')."
exit 1
fi
dashboard_ok=0
for i in 1 2 3; do
if curl -sf -o /dev/null http://localhost:8484/api/status; then
dashboard_ok=1
break
fi
sleep 2
done
if [[ $dashboard_ok -eq 1 ]]; then
ok "Dashboard is responding."
else
warn "Dashboard hasn't responded yet — it may still be starting."
warn "If it's still unreachable in a minute, see docs/05-troubleshooting.md."
fi
# ============================================================================
# Final screen
# ============================================================================
say ""
hr
cat <<EOF
${C_GREEN}${C_BOLD}${ASSISTANT_NAME} is awake.${C_RESET}
${C_BOLD}Talk to her${C_RESET} → ${C_CYAN}http://localhost:8484${C_RESET}
${C_BOLD}Username${C_RESET} → uschi
${C_BOLD}Password${C_RESET} → ${DASHBOARD_PASSWORD}
${C_BOLD}Stop the stack${C_RESET} → ${C_DIM}docker compose down${C_RESET}
${C_BOLD}View logs${C_RESET} → ${C_DIM}docker compose logs -f${C_RESET}
${C_BOLD}Reconfigure${C_RESET} → ${C_DIM}./install.sh --reconfig${C_RESET}
Customize her personality in ${C_CYAN}openclaw/workspace/VOICE.md${C_RESET}
or via the dashboard. See ${C_CYAN}docs/03-customize.md${C_RESET} for details.
EOF
hr