This Rπ lying around already ran MPD. But, as it is placed on a random spot on the Earth (with WIFI), I could only play streams. To change this, I decided on exporting my file server's MPD database and music folder.
Exporting the database
The database is quite easy, since the guys working on MPD already implemented a satellite setup. All I had to do was setting up a tunnel over SSH to enable the local MPD to reach out to the file server's MPD. As the Rπ is running Arch, I have systemd to start the tunnel on startup. MPD is very flexible on when it gets a connection to the database.
[Unit] Description=SSH Tunnel for MPD database After=network.target [Service] ExecStart=/usr/bin/ssh -NTC -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -L 56600:localhost:6600 -i /root/.ssh/id_rsa HOST # Restart every >2 seconds to avoid StartLimitInterval failure RestartSec=3 Restart=always [Install] WantedBy=default.target
As you can see, there is an SSH key in
On the file server, the key's user gets a string prepended in the authorized_keys file:
This will restrict the key to doing nothing. You can't use this key to get a shell for example. You can, however, use the sftp subsystem needed for the next part…
Mounting the music folder
The file server will talk to other computers using either Samba or NFS. Except, since the Rπ is not on my home network, this will not work. Luckily, there will not be many file requests ( #1 / 2 min. ), so we can use SSHFS for this. I hadn't ever messed with SSHFS, but it's like a combination of SSH and NFS.
First I tried doing this manually:
sshfs USER@HOST:/path/to/music/folder /local/mountpoint
This enabled the testing of the whole idea.
Now, nobody wants to issue the above every time when the Π is started. Fortunately, you can add an entry to fstab so it will mount automatically
USER@HOST:/path/to/music/folder /local/mountpoint fuse.sshfs defaults,_netdev,reconnect 0 0
It's advisable to extend the options given to sshfs, see the ArchWiki on SSHFS