Skip to content

Instantly share code, notes, and snippets.

@luckydonald
Last active December 1, 2016 16:33
Show Gist options
  • Save luckydonald/4e8f94e07a322c6e527d to your computer and use it in GitHub Desktop.
Save luckydonald/4e8f94e07a322c6e527d to your computer and use it in GitHub Desktop.
How to install an Airplay server (shairport-sync) on a Cubietruck

Install Shairport-Sync on a Cubieboard

I did the steps in this Cubietruck GPIO tutorial before, so I might miss dependencies already installed there. If that is the case, bug me in a comment.

Licensed under a Luna-Will-Cry-If-You-Modify-Or-Redistribute-This 1.0 licence.

Install dependencies

source

sudo apt-get install -y autoconf libtool libdaemon-dev libasound2-dev libpopt-dev avahi-daemon libavahi-client-dev libssl-dev git
sudo apt-get install -y libsoxr-dev

If libsoxr-dev fails because it is missing (Raspberry Pi?), see the documentation at shairport-sync/LIBSOXR.md about how to compile it from source.

Download source

cd  # moves you to yor home folder
mkdir tools
cd tools/
git clone https://github.com/mikebrady/shairport-sync.git
cd shairport-sync/
autoreconf -i -f  # this takes some time without outputting anything...
./configure --with-alsa --with-avahi --with-ssl=openssl --with-soxr
make  # wow, on a raspberry this took forever.
sudo make install

I will refer to the files gpio_on, gpio_off, gpio_init and gpio_exit. They were created in the first tutorial part, How to set up GPIO on a Cubietruck. If you don't need GPIO, ignore them.

Now edit the shairport configuration

sudo nano /etc/init.d/shairport-sync

Add the following to the beginning of the file

# Manually added variables:
AIRPLAY_NAME="Stereoanlage"  # name displayed on the iPhone
ON_START_EXEC="/usr/local/bin/gpio_on"  # leave blank, if you didn't do the GPIO step before.
ON_STOP_EXEC="/usr/local/bin/gpio_off"  # leave blank, if you didn't do the GPIO step before.
PASSWORD="This is a secure password for Airplay. No, I lied, it is not, because it is on github."

# Run the GPIO init script to prepare the GPIO ports.
/bin/bash /usr/local/bin/gpio_init  # Don't add this line if you didn't do the GPIO step before.

Now find the do_start() { function somewhere below. Inside look for a line starting with

        start-stop-daemon --start --quiet 

After that line add the following, if you choose to use GPIO

Run the GPIO init script to prepare the GPIO ports.

/bin/bash /usr/local/bin/gpio_init # Don't add this line if you didn't do the GPIO step before.


Now find the next ```start-stop-daemon``` line. Comment out this line by adding ```#``` at the beginning of the line. Afterwards add this line above:     
```shell
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- -d --name=$AIRPLAY_NAME --wait-cmd --on-start=$ON_START_EXEC --on-stop=$ON_STOP_EXEC --password=$PASSWORD -- -d hw:0 || return 2

The -- -d hw:0 part right before the || return 2 tells ALSA to use audio device 0, which is the headphone jack. Remove the complete -- -d hw:0 to get the sound via HDMI instead.

If your choice was not to use GPIOs, you can exit the editor, and skip the next editing instructions.
Locate the do_stop() function, and add as first line:

/bin/bash /usr/local/bin/gpio_exit


When done, to exit the editor, press ```^X```. ```Y``` to confirm writing your changes.    

## Starting it
```shell
sudo service shairport-sync start

Stopping it

sudo service shairport-sync stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment