Multi Room Audio Configuration
# if you intend to create a multi-room audiophile configuration sharing the same music library on your LAN network
# Use the script below to configure your audio server very easily.
# change the hostname manually
$ sudo nano /etc/hosts
$ sudo nano /etc/hostname
$ sudo nano /etc/minidlna.conf
$ sudo nano /etc/upmpdcli.conf
$ sudo nano /etc/shairport-sync.conf
~$ sudo nano /etc/raspotify/conf
# in Edition 2021 raspotify config (/etc/default/raspotify)
# and docker spot image must be changed as well, see the script 2021 below
# change hostname by script
# create the script in scripts directory
$ sudo nano ~/scripts/musicloungerenamer2023.sh
# SCRIPT EDITION 2023
# insert these lines (copy then right-click on ssh session)
#!/bin/bash # File: musicloungerenamer.sh # Author: Linux Audio Foundation # Requirements: MusicLounge Audiophile Distro # Link: https://linuxaudiofoundation.org/musiclounge-multi-room-audio-configuration/ # # get current arch arch=$(dpkg --print-architecture) # check if run as root if [ "$(id -u)" -ne 0 ]; then echo "This script must be run by root" >&2 exit 1 fi CURR_HNAME=$(cat /etc/hostname) NEW_HOSTNAME=$1 NEW_HOSTNAMELOW=${NEW_HOSTNAME,,} echo "current hostname: ${CURR_HNAME}" >&2 echo "new hostname: ${NEW_HOSTNAME}" >&2 # empty new hostname if [ -z "${NEW_HOSTNAME}" ]; then echo "error: hostname (first parameter) is empty!" >&2 exit 1 fi # no change if [ "${CURR_HNAME}" == "${NEW_HOSTNAME}" ]; then echo "Same host name exit with no change." >&2 exit 1 fi # hostname cfg sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAMELOW/g" /etc/hostname # hosts sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAMELOW/g" /etc/hosts echo "hostname and hosts changed to: ${NEW_HOSTNAMELOW}" >&2 # mini dlna cfg sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAME/I" /etc/minidlna.conf echo "minidlna service changed to: ${NEW_HOSTNAME}" >&2 # upmpdcli (upnp)cfg sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAME/I" /etc/upmpdcli.conf echo "upnp service changed to: ${NEW_HOSTNAME}" >&2 # air play cfg # nothing to do as general section contains name = "%H" which is current hostname sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAME/I" /etc/shairport-sync.conf echo "AirPlay service changed to: ${NEW_HOSTNAME}" >&2 # spotify connect armhf & arm64 cfg if [ "amd64" != "$arch" ]; then # armhf and arm64 sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAME/I" /etc/raspotify/conf echo "Spotify Connect (armhf/arm64) service changed to: ${NEW_HOSTNAME}" >&2 fi # ask before rebooting while true; do read -p "Hostname and services have been changed for ${NEW_HOSTNAME}, reboot for the change to take effect (y / n)? " yx case $yx in [Yy]* ) sudo reboot; break;; * ) exit;; esac done
# CTRL+O to save
# CTRL+X to exit
# change permision
$ sudo chmod +x ~/scripts/musicloungerenamer2023.sh
# SCRIPT EDITION 2021
# change hostname by script
# create the script in scripts directory
$ sudo nano ~/scripts/musicloungerenamer2021.sh
# insert these lines (copy then right-click on ssh session)
#!/bin/bash # File: musicloungerenamer.sh # Author: Linux Audio Foundation # Requirements: MusicLounge Audiophile Distro # Link: https://linuxaudiofoundation.org/musiclounge-multi-room-audio-configuration/ # # get current arch arch=$(dpkg --print-architecture) # check if run as root if [ "$(id -u)" -ne 0 ]; then echo "This script must be run by root" >&2 exit 1 fi CURR_HNAME=$(cat /etc/hostname) NEW_HOSTNAME=$1 NEW_HOSTNAMELOW=${NEW_HOSTNAME,,} echo "current hostname: ${CURR_HNAME}" >&2 echo "new hostname: ${NEW_HOSTNAME}" >&2 # empty new hostname if [ -z "${NEW_HOSTNAME}" ]; then echo "error: hostname (first parameter) is empty!" >&2 exit 1 fi # no change if [ "${CURR_HNAME}" == "${NEW_HOSTNAME}" ]; then echo "Same host name exit with no change." >&2 exit 1 fi # hostname cfg sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAMELOW/g" /etc/hostname # hosts sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAMELOW/g" /etc/hosts echo "hostname and hosts changed to: ${NEW_HOSTNAMELOW}" >&2 # mini dlna cfg sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAME/I" /etc/minidlna.conf echo "minidlna service changed to: ${NEW_HOSTNAME}" >&2 # upmpdcli (upnp)cfg sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAME/I" /etc/upmpdcli.conf echo "upnp service changed to: ${NEW_HOSTNAME}" >&2 # air play cfg # nothing to do as general section contains name = "%H" which is current hostname sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAME/I" /etc/shairport-sync.conf echo "AirPlay service changed to: ${NEW_HOSTNAME}" >&2 # spotify connect armhf & arm64 cfg if [ "amd64" != "$arch" ]; then # armhf and arm64 sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAME/I" /etc/default/raspotify echo "Spotify Connect (armhf/arm64) service changed to: ${NEW_HOSTNAME}" >&2 fi # docker spot container on amd64 cfg if [ "amd64" == "$arch" ]; then # read -p "Press any key to stop Spotify Connect service" sudo docker ps -q --filter "name=spot" | grep -q . && docker stop spot && docker rm -fv spot # read -p "Press any key to change the new of Spotify Connect to ${NEW_HOSTNAME}" export SPOTNAME=$(echo "NAME=${NEW_HOSTNAME}") sudo docker run -d --restart unless-stopped \ --name "spot" \ --env $SPOTNAME \ --volume /tmp \ --group-add audio \ --device /dev/snd \ --net host \ --cap-drop ALL \ --read-only \ dubodubonduponey/librespot \ --backend alsa \ --device plughw:1,0 \ --disable-audio-cache \ --initial-volume=100 echo "Spotify Connect (Docker amd64) service changed to: ${NEW_HOSTNAME}" >&2 fi # ask before rebooting while true; do read -p "Hostname and services have been changed for ${NEW_HOSTNAME}, reboot for the change to take effect (y / n)? " yx case $yx in [Yy]* ) sudo reboot; break;; * ) exit;; esac done
# CTRL+O to save
# CTRL+X to exit
# change permision
$ sudo chmod +x ~/scripts/musicloungerenamer2021.sh
# we suggest a name which identify the room easily like a Music or Audio prefix + the room name (e.g MusicBedroom, MusicLivingroom, MusicKitchen,…)
# run the script with the audio server name in parameter, example:
$ cd scripts/
$ sudo ./musicloungerenamer.sh MusicKitchen
# type y to reboot the server
# that’s it!