-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
206 lines (171 loc) · 6.99 KB
/
Copy pathMakefile
File metadata and controls
206 lines (171 loc) · 6.99 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
# HelloHistory Makefile
# Development and deployment commands for the rotary phone audio player
#
# Usage:
# make test # Run local test player (Mac)
# make deploy # Deploy to Raspberry Pi
# make logs # View Pi service logs
# make ssh # SSH into Pi
#
# Configuration
PI_HOST ?= delmonte.local
PI_USER ?= pi
REMOTE_PATH ?= /home/pi/delmonte
# ============================================================================
# Local Development
# ============================================================================
.PHONY: test
test: ## Run the bench test player locally (Mac)
@echo "Starting bench player..."
@echo "Controls: SPACE=play/pause, 0-7=chapters, Q=quit"
@echo ""
python3 src/bench_player.py
.PHONY: test-audio
test-audio: ## Quick test of audio playback
@echo "Playing intro track..."
afplay src/audio/00_intro.mp3
# ============================================================================
# Audio Generation (ElevenLabs)
# ============================================================================
.PHONY: audio-generate
audio-generate: ## Generate all audio chapters (requires ELEVENLABS_API_KEY)
python3 scripts/generate_audio.py --all
.PHONY: audio-chapter
audio-chapter: ## Generate a single chapter: make audio-chapter CH=01_welcome
@if [ -z "$(CH)" ]; then \
echo "Usage: make audio-chapter CH=01_welcome"; \
echo ""; \
echo "Available chapters:"; \
grep "id:" scripts/audio_config.yaml | sed 's/.*id: "/ /; s/"//'; \
else \
python3 scripts/generate_audio.py $(CH); \
fi
.PHONY: audio-list-voices
audio-list-voices: ## List available ElevenLabs voices
python3 scripts/generate_audio.py --list-voices
.PHONY: audio-dry-run
audio-dry-run: ## Preview audio generation without calling API
python3 scripts/generate_audio.py --all --dry-run
# ============================================================================
# Deployment
# ============================================================================
.PHONY: deploy
deploy: ## Deploy code to Raspberry Pi
@chmod +x deploy/deploy.sh
@./deploy/deploy.sh $(PI_HOST)
.PHONY: sync
sync: ## Sync files to Pi without restarting service
rsync -avz --delete \
--exclude='.git' --exclude='venv' --exclude='__pycache__' \
--exclude='*.pyc' --exclude='.DS_Store' --exclude='.amplifier' \
./src/ $(PI_USER)@$(PI_HOST):$(REMOTE_PATH)/src/
# ============================================================================
# Pi Setup (First Time)
# ============================================================================
.PHONY: setup
setup: ## Run first-time Pi setup (installs deps, configures audio)
@echo "Copying setup script to Pi..."
scp deploy/setup-pi.sh $(PI_USER)@$(PI_HOST):~/
@echo "Running setup on Pi..."
ssh $(PI_USER)@$(PI_HOST) 'chmod +x ~/setup-pi.sh && ~/setup-pi.sh'
.PHONY: setup-service
setup-service: deploy ## Install/update the systemd service on Pi
@echo "Installing phone player service..."
scp deploy/setup-service.sh $(PI_USER)@$(PI_HOST):~/
ssh $(PI_USER)@$(PI_HOST) 'chmod +x ~/setup-service.sh && ~/setup-service.sh'
# ============================================================================
# Service Management
# ============================================================================
.PHONY: start
start: ## Start the phone player service on Pi
ssh $(PI_USER)@$(PI_HOST) 'sudo systemctl start phone-player'
@echo "Service started"
.PHONY: stop
stop: ## Stop the phone player service on Pi
ssh $(PI_USER)@$(PI_HOST) 'sudo systemctl stop phone-player'
@echo "Service stopped"
.PHONY: restart
restart: ## Restart the phone player service on Pi
ssh $(PI_USER)@$(PI_HOST) 'sudo systemctl restart phone-player'
@echo "Service restarted"
.PHONY: status
status: ## Check service status on Pi
@ssh $(PI_USER)@$(PI_HOST) 'systemctl status phone-player' || true
.PHONY: logs
logs: ## Tail the service logs from Pi (Ctrl+C to stop)
ssh $(PI_USER)@$(PI_HOST) 'journalctl -u phone-player -f'
.PHONY: logs-recent
logs-recent: ## Show last 50 log lines
ssh $(PI_USER)@$(PI_HOST) 'journalctl -u phone-player -n 50'
# ============================================================================
# WiFi Configuration
# ============================================================================
.PHONY: wifi-add
wifi-add: ## Add a WiFi network: make wifi-add SSID="NetworkName" PASS="password" PRIORITY=10
@if [ -z "$(SSID)" ] || [ -z "$(PASS)" ]; then \
echo "Usage: make wifi-add SSID=\"NetworkName\" PASS=\"password\" [PRIORITY=10]"; \
echo ""; \
echo "Example:"; \
echo " make wifi-add SSID=\"HomeWifi\" PASS=\"mypassword\" PRIORITY=10"; \
echo " make wifi-add SSID=\"RentalWifi\" PASS=\"otherpass\" PRIORITY=20"; \
echo ""; \
echo "Higher priority = preferred when multiple networks in range"; \
else \
scp deploy/setup-wifi.sh $(PI_USER)@$(PI_HOST):~/; \
ssh $(PI_USER)@$(PI_HOST) "chmod +x ~/setup-wifi.sh && ~/setup-wifi.sh '$(SSID)' '$(PASS)' $(or $(PRIORITY),10)"; \
fi
.PHONY: wifi-list
wifi-list: ## List saved WiFi networks on Pi
@ssh $(PI_USER)@$(PI_HOST) 'nmcli connection show | grep wifi'
# ============================================================================
# Pi Remote Access
# ============================================================================
.PHONY: ssh
ssh: ## SSH into the Raspberry Pi
ssh $(PI_USER)@$(PI_HOST)
.PHONY: ping
ping: ## Check if Pi is reachable
@ping -c 3 $(PI_HOST) && echo "✓ Pi is reachable" || echo "✗ Pi not found"
.PHONY: pi-info
pi-info: ## Show Pi system info (temp, disk, memory)
@ssh $(PI_USER)@$(PI_HOST) '\
echo "═══ System Info ═══" && \
echo "Hostname: $$(hostname)" && \
echo "Uptime: $$(uptime -p)" && \
echo "" && \
echo "═══ Temperature ═══" && \
vcgencmd measure_temp && \
echo "" && \
echo "═══ Disk Usage ═══" && \
df -h / && \
echo "" && \
echo "═══ Memory ═══" && \
free -h'
# ============================================================================
# Audio Testing on Pi
# ============================================================================
.PHONY: pi-test-audio
pi-test-audio: ## Test audio output on Pi
@echo "Playing test tone on Pi..."
ssh $(PI_USER)@$(PI_HOST) 'speaker-test -t sine -f 440 -c 1 -l 1'
.PHONY: pi-volume
pi-volume: ## Open audio mixer on Pi
ssh -t $(PI_USER)@$(PI_HOST) 'alsamixer'
# ============================================================================
# Help
# ============================================================================
.PHONY: help
help: ## Show this help message
@echo "HelloHistory - Development Commands"
@echo ""
@echo "Usage: make [target] [PI_HOST=hostname]"
@echo ""
@echo "Examples:"
@echo " make test # Run local test player"
@echo " make deploy # Deploy to delmonte.local"
@echo " make deploy PI_HOST=10.0.0.5 # Deploy to specific IP"
@echo ""
@echo "Targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := help