#!/bin/bash # Check that script is not running as root if [ "$EUID" -eq 0 ]; then echo "Error: This script should not be run as root" echo "Please run this script as the normal user that will be used to run the music players" echo "The script will use 'sudo' when elevated privileges are needed" exit 1 fi # Check if running Debian 13/Trixie if [ ! -f /etc/debian_version ]; then echo "Error: This script requires Debian" exit 1 fi debian_version=$(cat /etc/debian_version) if ! echo "$debian_version" | grep -q "^13\." && ! grep -q "trixie" /etc/os-release 2>/dev/null; then echo "Current Debian version: $debian_version" echo "This script requires Debian 13 (Trixie)" # Check if we're on a compatible version for upgrade if echo "$debian_version" | grep -q "^12\." || grep -q "bookworm" /etc/os-release 2>/dev/null; then echo "" echo "You appear to be running Debian 12 (Bookworm)" echo "An upgrade script is available to upgrade to Debian 13 (Trixie)" echo "" echo "Would you like to run the upgrade script now? [y/N]" read -r response if [[ "$response" =~ ^[Yy]$ ]]; then if [ -f "./upgrade-to-trixie" ]; then echo "Starting upgrade script..." ./upgrade-to-trixie exit $? else echo "Error: upgrade-to-trixie script not found in current directory" echo "Please run: ./upgrade-to-trixie manually" exit 1 fi else echo "To upgrade manually, run: ./upgrade-to-trixie" exit 1 fi else echo "Automatic upgrade is only supported from Debian 12 (Bookworm)" echo "Please manually upgrade to Debian 13 (Trixie) and run this script again" exit 1 fi fi echo "Detected Debian 13/Trixie - proceeding with installation" # Add HiFiBerry repository if not already present if ! grep -q "debianrepo.hifiberry.com" /etc/apt/sources.list.d/hifiberry.list 2>/dev/null; then echo "Adding HiFiBerry repository..." echo "deb [signed-by=/usr/share/keyrings/hifiberry-archive-keyring.gpg] http://debianrepo.hifiberry.com trixie main" | sudo tee /etc/apt/sources.list.d/hifiberry.list wget -O- "https://keys.openpgp.org/vks/v1/by-fingerprint/4192E989F186E770B273F98B7997FC464E443CFA" | gpg --dearmor | sudo tee /usr/share/keyrings/hifiberry-archive-keyring.gpg > /dev/null else echo "HiFiBerry repository already configured" fi sudo apt update -y sudo apt install -y hbos-minimal # Base configuration sudo config-configtxt --default-config # Check if $USER is set, otherwise set it if [ -z "$USER" ]; then echo "USER environment variable is not set, defaulting to 'hifiberry'" USER=`whoami` fi # Write current username to /etc/hifiberry.user echo "$USER" | sudo tee /etc/hifiberry.user # Linger for current user echo "Enabling linger for user $USER" sudo loginctl enable-linger "$USER" # Configure user manager to forward logs to system journal echo "Configuring user manager to forward logs to system journal..." sudo mkdir -p /etc/systemd/user.conf.d sudo tee /etc/systemd/user.conf.d/journal.conf > /dev/null <