-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathinstall.sh
More file actions
745 lines (636 loc) · 22.1 KB
/
Copy pathinstall.sh
File metadata and controls
745 lines (636 loc) · 22.1 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
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
#!/bin/bash
# Beatnik Pi Installation Script
# Automates the installation of Snapcast with AirPlay and Spotify Connect support
set -e # Exit on any error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Logging functions
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
log_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Get latest Snapcast version
get_latest_snapcast_version() {
log_info "Fetching latest Snapcast version..."
SNAPCAST_VERSION_TAG=$(curl -sL https://api.github.com/repos/badaix/snapcast/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$SNAPCAST_VERSION_TAG" ]; then
log_error "Failed to fetch latest Snapcast version. Please check your internet connection."
exit 1
fi
SNAPCAST_VERSION=${SNAPCAST_VERSION_TAG#v} # Remove 'v' prefix
log_info "Latest Snapcast version is $SNAPCAST_VERSION"
}
# Get OS codename (e.g., bookworm, trixie)
get_os_codename() {
if [ -f /etc/os-release ]; then
. /etc/os-release
OS_CODENAME=$VERSION_CODENAME
log_info "Detected OS Codename: $OS_CODENAME"
else
log_error "Cannot determine OS version. /etc/os-release not found."
exit 1
fi
}
# Check if running as root
check_root() {
if [[ $EUID -eq 0 ]]; then
log_error "This script should not be run as root. Please run as a regular user with sudo privileges."
exit 1
fi
}
# Check if running on Raspberry Pi
check_raspberry_pi() {
if ! grep -q "Raspberry Pi" /proc/cpuinfo 2>/dev/null; then
log_warning "This script is designed for Raspberry Pi. Continuing anyway..."
fi
}
# Installation type selection
select_installation_type() {
log_info "What would you like to install?"
echo "1) Full Beatnik Pi Server (Snapserver + Snapclient + AirPlay + Spotify)"
echo "2) Snapcast Client Only (connects to existing server)"
while true; do
read -p "Enter your choice (1-2): " choice
case $choice in
1)
INSTALL_TYPE="server"
break
;;
2)
INSTALL_TYPE="client"
break
;;
*)
log_error "Invalid choice. Please enter 1 or 2."
;;
esac
done
}
# Soundcard selection menu
select_soundcard() {
log_info "Please select your soundcard/HAT:"
echo "1) HiFiBerry Amp4 Pro"
echo "2) Raspberry Pi DAC+ (former IQAudio)"
echo "3) Raspberry Pi DigiAmp+ (former IQAudio)"
echo "4) HiFiBerry MiniAmp (for clients)"
echo "5) HiFiBerry Digi+ / Digi 2 Standard"
echo "6) HiFiBerry Digi+ Pro / Digi 2 Pro"
echo "7) Built-in 3.5mm jack"
echo "8) USB Audio Device"
echo "9) Other/Skip soundcard configuration"
while true; do
read -p "Enter your choice (1-9): " choice
case $choice in
1)
SOUNDCARD="hifiberry-amp4pro"
OVERLAY="dtoverlay=hifiberry-amp4pro"
break
;;
2)
SOUNDCARD="raspberry-dacplus"
# Will be configured after HAT detection
break
;;
3)
SOUNDCARD="raspberry-digiampplus"
# Will be configured after HAT detection
break
;;
4)
SOUNDCARD="hifiberry-miniamp"
OVERLAY="dtoverlay=hifiberry-dac"
break
;;
5)
SOUNDCARD="hifiberry-digi"
OVERLAY="dtoverlay=hifiberry-digi"
break
;;
6)
SOUNDCARD="hifiberry-digi-pro"
OVERLAY="dtoverlay=hifiberry-digi-pro"
break
;;
7)
SOUNDCARD="builtin"
OVERLAY="dtparam=audio=on"
break
;;
8)
SOUNDCARD="usb"
log_info "USB audio will be auto-detected. Make sure your USB audio device is connected."
break
;;
9)
SOUNDCARD="skip"
log_warning "Skipping soundcard configuration. You'll need to configure it manually."
break
;;
*)
log_error "Invalid choice. Please enter 1-9."
;;
esac
done
}
# Configure soundcard drivers
configure_soundcard() {
if [[ "$SOUNDCARD" == "skip" ]]; then
return
fi
log_info "Configuring soundcard drivers..."
# Backup config.txt
sudo cp /boot/firmware/config.txt /boot/firmware/config.txt.backup.$(date +%Y%m%d_%H%M%S)
# Handle built-in audio differently
if [[ "$SOUNDCARD" == "builtin" ]]; then
# Enable built-in audio
if ! grep -q "^dtparam=audio=on" /boot/firmware/config.txt; then
echo "dtparam=audio=on" | sudo tee -a /boot/firmware/config.txt > /dev/null
fi
return
fi
# Handle USB audio
if [[ "$SOUNDCARD" == "usb" ]]; then
log_info "USB audio configuration will be handled automatically."
return
fi
# Remove dtparam=audio=on if it exists (for HAT configurations)
sudo sed -i '/^dtparam=audio=on/d' /boot/firmware/config.txt
# Add noaudio to vc4-kms-v3d if it exists
if grep -q "^dtoverlay=vc4-kms-v3d" /boot/firmware/config.txt; then
sudo sed -i 's/^dtoverlay=vc4-kms-v3d.*/dtoverlay=vc4-kms-v3d,noaudio/' /boot/firmware/config.txt
fi
# Handle Raspberry Pi HATs (DAC+ and DigiAmp+)
if [[ "$SOUNDCARD" == "raspberry-dacplus" || "$SOUNDCARD" == "raspberry-digiampplus" ]]; then
log_info "HAT configuration will be completed after reboot and HAT detection."
NEEDS_HAT_DETECTION=true
else
# Add the overlay for HiFiBerry cards
if ! grep -q "$OVERLAY" /boot/firmware/config.txt; then
echo "$OVERLAY" | sudo tee -a /boot/firmware/config.txt > /dev/null
fi
fi
}
# Detect and configure Raspberry Pi HATs
configure_raspberry_hat() {
if [[ "$NEEDS_HAT_DETECTION" != "true" ]]; then
return
fi
log_info "Detecting HAT configuration..."
if grep -q "Raspberry Pi DAC Plus" /proc/device-tree/hat/product 2>/dev/null; then
log_info "Detected Raspberry Pi DAC+ HAT"
OVERLAY="dtoverlay=iqaudio-dacplus"
elif grep -q "Raspberry Pi DigiAMP+" /proc/device-tree/hat/product 2>/dev/null; then
log_info "Detected Raspberry Pi DigiAmp+ HAT"
OVERLAY="dtoverlay=iqaudio-digiamp"
else
log_warning "Could not detect HAT type. Please configure manually."
return
fi
# Add the detected overlay
if ! grep -q "$OVERLAY" /boot/firmware/config.txt; then
echo "$OVERLAY" | sudo tee -a /boot/firmware/config.txt > /dev/null
log_info "Added $OVERLAY to config.txt"
fi
}
# Update system
update_system() {
log_info "Updating system package lists..."
sudo apt update
if [[ "$INSTALL_TYPE" == "server" ]]; then
log_info "Performing a full system upgrade (this may take a while)..."
sudo apt full-upgrade -y
else
log_info "Skipping full system upgrade for faster client installation."
fi
}
# Install Snapcast
install_snapcast() {
log_info "Installing Snapcast $SNAPCAST_VERSION for $OS_CODENAME..."
cd /tmp
if [[ "$INSTALL_TYPE" == "server" ]]; then
# Download both server and client packages
wget -q -O snapserver.deb "https://github.com/badaix/snapcast/releases/download/${SNAPCAST_VERSION_TAG}/snapserver_${SNAPCAST_VERSION}-1_arm64_${OS_CODENAME}.deb"
wget -q -O snapclient.deb "https://github.com/badaix/snapcast/releases/download/${SNAPCAST_VERSION_TAG}/snapclient_${SNAPCAST_VERSION}-1_arm64_${OS_CODENAME}.deb"
# Install packages
sudo apt install ./snapserver.deb ./snapclient.deb -y
log_success "Snapcast server and client installed successfully"
else
# Download only client package
wget -q -O snapclient.deb "https://github.com/badaix/snapcast/releases/download/${SNAPCAST_VERSION_TAG}/snapclient_${SNAPCAST_VERSION}-1_arm64_${OS_CODENAME}.deb"
# Install package
sudo apt install ./snapclient.deb -y
log_success "Snapcast client installed successfully"
fi
}
# Install Shairport-Sync (AirPlay)
install_shairport_sync() {
log_info "Installing Shairport-Sync for AirPlay support..."
sudo apt install shairport-sync -y
# Disable the service (Snapserver will manage it)
sudo systemctl disable shairport-sync.service
log_success "Shairport-Sync installed and disabled"
}
# Install Raspotify (Spotify Connect)
install_raspotify() {
log_info "Installing Raspotify for Spotify Connect support..."
# Install curl if not present
sudo apt-get install -y curl
# Install raspotify
curl -sL https://dtcooper.github.io/raspotify/install.sh | sh
# Disable raspotify service (Snapserver will manage librespot)
sudo systemctl disable raspotify
sudo systemctl stop raspotify
log_success "Raspotify installed and disabled"
}
# Configure Snapserver
configure_snapserver() {
log_info "Configuring Snapserver..."
# Backup existing config
if [[ -f /etc/snapserver.conf ]]; then
sudo cp /etc/snapserver.conf /etc/snapserver.conf.backup.$(date +%Y%m%d_%H%M%S)
fi
# Create snapserver configuration
sudo tee /etc/snapserver.conf > /dev/null <<'EOF'
# Beatnik Pi Snapserver Configuration
[http]
enabled = true
bind_to_address = 0.0.0.0
port = 1780
[tcp]
enabled = true
bind_to_address = 0.0.0.0
port = 1705
[stream]
# AirPlay 1 (port 5000)
source = airplay:///usr/bin/shairport-sync?name=AirPlay&devicename=Beatnik-Airplay1&port=5000
[stream]
# AirPlay 2 (port 7000)
source = airplay:///shairport-sync?name=AirPlay2&devicename=Beatnik-Airplay2&port=7000
[stream]
# Spotify Connect
source = spotify:///librespot?name=Spotify&devicename=Beatnik-Spotify
EOF
log_success "Snapserver configured"
}
# Configure Snapclient
configure_snapclient() {
log_info "Configuring Snapclient..."
# Add snapclient user to audio group
sudo usermod -aG audio snapclient
# Get server hostname for client-only installations
if [[ "$INSTALL_TYPE" == "client" ]]; then
log_info "Enter the hostname or IP address of your Snapcast server:"
read -p "Server address: " SERVER_HOST
if [[ -z "$SERVER_HOST" ]]; then
log_warning "No server address provided. Using localhost (you can change this later in /etc/snapclient.conf)"
SERVER_HOST="localhost"
fi
else
SERVER_HOST="localhost"
fi
# Detect the correct audio device
AUDIO_DEVICE="hw:0,0"
# For USB audio, try to find the correct device
if [[ "$SOUNDCARD" == "usb" ]]; then
USB_DEVICE=$(aplay -l 2>/dev/null | grep -E "USB|Audio" | head -1 | sed -n 's/card \([0-9]\):.*device \([0-9]\):.*/hw:\1,\2/p')
if [[ -n "$USB_DEVICE" ]]; then
AUDIO_DEVICE="$USB_DEVICE"
log_info "Detected USB audio device: $AUDIO_DEVICE"
else
log_warning "USB audio device not found. Using default hw:0,0"
fi
fi
# Create snapclient configuration
sudo tee /etc/snapclient.conf > /dev/null <<EOF
[snapclient]
host = $SERVER_HOST
sound_device = $AUDIO_DEVICE
# buffer = 80
EOF
log_success "Snapclient configured for server: $SERVER_HOST"
}
# Check soundcard after reboot
check_soundcard() {
log_info "Checking soundcard configuration..."
if aplay -l | grep -q "sndrpihifiberry\|card"; then
log_success "Soundcard detected successfully"
aplay -l
else
log_warning "Soundcard not detected. You may need to check your configuration."
fi
}
# Start services
start_services() {
log_info "Enabling and starting services..."
if [[ "$INSTALL_TYPE" == "server" ]]; then
sudo systemctl enable snapserver snapclient
sudo systemctl start snapserver snapclient
log_success "Snapserver and Snapclient services started"
else
sudo systemctl enable snapclient
sudo systemctl start snapclient
log_success "Snapclient service started"
fi
}
# Install and Configure CamillaDSP
install_camilladsp() {
log_info "Would you like to install CamillaDSP for Room Correction/EQ? (y/n)"
read -p "Choice: " install_camilla
if [[ ! "$install_camilla" =~ ^[Yy]$ ]]; then
return
fi
log_info "Installing CamillaDSP..."
# 1. Dependencies and Directories
mkdir -p ~/camilladsp/configs ~/camilladsp/coeffs
sudo apt-get update
sudo apt-get install -y alsa-utils unzip
# 2. Install CamillaDSP Binary (v2.0.3)
CAMILLA_VERSION="v2.0.3"
wget -q "https://github.com/HEnquist/camilladsp/releases/download/${CAMILLA_VERSION}/camilladsp-linux-aarch64.tar.gz" -P /tmp
sudo tar -xvf /tmp/camilladsp-linux-aarch64.tar.gz -C /usr/local/bin/
rm /tmp/camilladsp-linux-aarch64.tar.gz
# 3. Setup Loopback
log_info "Setting up ALSA Loopback..."
sudo modprobe snd-aloop
echo "snd-aloop" | sudo tee /etc/modules-load.d/snd-aloop.conf > /dev/null
# 4. Configure Snapclient to use Loopback
log_info "Configuring Snapclient to use Loopback..."
if grep -q "sound_device" /etc/snapclient.conf; then
sudo sed -i 's|^sound_device = .*|sound_device = hw:Loopback,0,0|' /etc/snapclient.conf
else
echo "sound_device = hw:Loopback,0,0" | sudo tee -a /etc/snapclient.conf
fi
# 5. Configure CamillaDSP
log_info "Generating CamillaDSP configuration..."
# Determine playback device based on SOUNDCARD variable
case "$SOUNDCARD" in
"hifiberry-amp4pro"|"hifiberry-miniamp"|"hifiberry-digi"|"hifiberry-digi-pro")
PLAYBACK_DEVICE="plughw:CARD=sndrpihifiberry,DEV=0"
;;
"raspberry-dacplus"|"raspberry-digiampplus")
PLAYBACK_DEVICE="plughw:CARD=IQaudIODAC,DEV=0"
;;
"builtin")
PLAYBACK_DEVICE="plughw:CARD=Headphones,DEV=0"
;;
"usb")
PLAYBACK_DEVICE="plughw:CARD=Device,DEV=0" # Generic fallback
log_warning "For USB devices, you might need to adjust the playback device in ~/camilladsp/configs/client_config.yml"
;;
*)
PLAYBACK_DEVICE="plughw:CARD=Headphones,DEV=0"
;;
esac
cat > ~/camilladsp/configs/client_config.yml <<EOF
devices:
samplerate: 48000
chunksize: 1024
enable_rate_adjust: true
target_level: 1024
capture:
type: Alsa
channels: 2
device: "hw:Loopback,1,0"
format: S16LE
playback:
type: Alsa
channels: 2
device: "$PLAYBACK_DEVICE"
format: S16LE
filters:
bass:
type: Biquad
parameters:
type: Lowshelf
freq: 100
slope: 6
gain: 0.0
mid:
type: Biquad
parameters:
type: Peaking
freq: 1000
q: 0.7
gain: 0.0
high:
type: Biquad
parameters:
type: Highshelf
freq: 5000
slope: 6
gain: 0.0
mixers:
stereo:
channels:
in: 2
out: 2
mapping:
- dest: 0
sources:
- channel: 0
gain: 0
inverted: false
- dest: 1
sources:
- channel: 1
gain: 0
inverted: false
pipeline:
- type: Mixer
name: stereo
- type: Filter
channel: 0
names:
- bass
- mid
- high
- type: Filter
channel: 1
names:
- bass
- mid
- high
EOF
# Ensure user ownership
chown $USER:$USER ~/camilladsp/configs/client_config.yml
# 6. Service
log_info "Creating CamillaDSP service..."
sudo tee /etc/systemd/system/camilladsp.service > /dev/null <<EOF
[Unit]
Description=CamillaDSP
Wants=snapclient.service
After=snapclient.service
[Service]
Type=simple
User=$USER
ExecStartPre=/bin/sleep 2
ExecStart=/usr/local/bin/camilladsp --address 0.0.0.0 --port 1234 /home/$USER/camilladsp/configs/client_config.yml
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable camilladsp
log_success "CamillaDSP installed and configured."
}
# Install Docker and Beatnik Controller
install_beatnik_controller() {
# Only offer controller installation for server installations
if [[ "$INSTALL_TYPE" != "server" ]]; then
return
fi
# Switch to user home directory to ensure repo isn't installed in /tmp
cd "/home/$USER" || exit 1
log_info "Would you like to install the Beatnik Controller web interface? (y/n)"
read -p "Choice: " install_controller
if [[ "$install_controller" =~ ^[Yy]$ ]]; then
log_info "Installing Docker..."
# Install Docker
# Check if docker is installed and the service exists
if ! command -v docker &> /dev/null || ! systemctl cat docker.service &> /dev/null; then
log_info "Installing Docker..."
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
sudo usermod -aG docker $USER
else
log_info "Docker is already installed. Skipping installation."
fi
# Install Docker Compose Plugin (instead of standalone docker-compose)
# The get-docker.sh script usually installs docker-compose-plugin, so we check first
if ! docker compose version &> /dev/null; then
sudo apt install docker-compose-plugin -y
fi
log_info "Installing Beatnik Controller..."
# Clone and setup Beatnik Controller
if [ -d "beatnik-controller" ]; then
rm -rf beatnik-controller
fi
git clone https://github.com/byrdsandbytes/beatnik-controller.git
cd beatnik-controller
# Run docker compose using sg to pick up the new group membership
if command -v sg &> /dev/null; then
# Ensure docker service is running
if ! systemctl is-active --quiet docker; then
sudo systemctl start docker
fi
sg docker -c "docker compose up -d"
else
sudo docker compose up -d
fi
log_success "Beatnik Controller installed. Access it at http://$(hostname).local:8181"
cd ..
fi
}
# Display final information
show_completion_info() {
log_success "Installation completed successfully!"
echo
if [[ "$INSTALL_TYPE" == "server" ]]; then
log_info "Beatnik Pi Server is ready!"
echo "Next steps:"
echo "1. The system will reboot to apply soundcard configuration"
echo "2. After reboot, test your setup:"
echo " - Classic Snapweb UI: http://$(hostname).local:1780"
if [[ "$install_controller" =~ ^[Yy]$ ]]; then
echo " - Beatnik Controller: http://$(hostname).local:8181"
fi
echo "3. Test AirPlay from your phone/computer"
echo "4. Test Spotify Connect from the Spotify app"
echo "5. Install additional clients on other devices using this script"
else
log_info "Snapcast Client is ready!"
echo "Next steps:"
echo "1. The system will reboot to apply soundcard configuration"
echo "2. After reboot, the client will automatically connect to: $SERVER_HOST"
echo "3. Use the Snapcast server's web interface to control this client"
echo "4. If the server address is wrong, edit /etc/snapclient.conf"
fi
echo
log_info "Useful commands:"
if [[ "$INSTALL_TYPE" == "server" ]]; then
echo " - Check services: sudo systemctl status snapserver snapclient"
echo " - View server logs: journalctl -u snapserver -f"
fi
echo " - Check client: sudo systemctl status snapclient"
echo " - View client logs: journalctl -u snapclient -f"
echo " - Check soundcard: aplay -l"
echo " - Test audio: speaker-test -c2 -t wav"
echo
if [[ "$SOUNDCARD" != "skip" && "$SOUNDCARD" != "usb" ]]; then
log_warning "System will reboot in 10 seconds to apply soundcard configuration..."
echo "Press Ctrl+C to cancel the reboot."
sleep 10
sudo reboot
fi
}
# Main installation function
main() {
echo "================================================"
echo " Beatnik Pi Installation Script"
echo "================================================"
echo
check_root
check_raspberry_pi
get_os_codename
get_latest_snapcast_version
# Select installation type first
select_installation_type
if [[ "$INSTALL_TYPE" == "server" ]]; then
log_info "This script will install:"
echo "- Snapcast server and client"
echo "- Shairport-Sync (AirPlay support)"
echo "- Raspotify (Spotify Connect support)"
echo "- Configure your selected soundcard/HAT"
echo "- Optional: Beatnik Controller web interface"
else
log_info "This script will install:"
echo "- Snapcast client only"
echo "- Configure your selected soundcard/HAT"
echo "- Connect to an existing Snapcast server"
fi
echo
read -p "Do you want to continue? (y/n): " confirm
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
log_info "Installation cancelled."
exit 0
fi
select_soundcard
update_system
configure_soundcard
install_snapcast
# Only install server components for server installation
if [[ "$INSTALL_TYPE" == "server" ]]; then
install_shairport_sync
install_raspotify
configure_snapserver
fi
configure_snapclient
install_camilladsp
check_soundcard
start_services
install_beatnik_controller
show_completion_info
}
# Handle HAT configuration after reboot
if [[ "$1" == "--configure-hat" ]]; then
configure_raspberry_hat
check_soundcard
start_services
log_success "HAT configuration completed!"
exit 0
fi
# Run main installation
main "$@"