markbaaijens / rpmusicserver

Transform a Raspberry Pi in a music server with LMS (Squeezebox), Samba, transcoder, etc.
GNU General Public License v3.0
5 stars 0 forks source link

RP Music Server

Transform a Raspberry Pi into a streaming/-file-server for your music with LMS (Lyrion/Logitech Media Server/Squeezebox), Samba, Transmission, Syncthing, transcoder, etc. in a few simple steps.

System requirements
Check your network if local DNS works
Installation of RPMS on a Pi
Troubleshooting
Folder mapping
Update RPMS
Transcoder
Backup
Disaster Recovery
Development
Migrating to 1.0

System requirements

Top

Check your network if local DNS works

To detect if your network supports local DNS, execute the following command in a terminal:

Check for output:

Top

Installation of RPMS on a Pi

Installing RPMS on your Pi can be done with a few simple steps, described below. But first, you should test your network if local DNS works.

Steps to install RPMS on your Pi

Top

Folder mapping

For several services within RPMS, the container-technology docker is used. Within docker, there is no direct link to the file-system, but this is achieved through a virtual folder which is set during installation.

Normally, an end-user does not have to know about these virtual folders, but there are a few exceptions primarily around LMS and SyncThing, these specific cases are documented here. So when working on the inside of the docker-infrastructure, either LMS or SyncThing, refer to the virtual folders.

Mapping of virtual folder to physical folders

Note. SyncThing maps to /media/usbdata/user, which is the root of all Samba-shares, public, music and downloads. Thus, you can sync any folder on any share with SyncThing.

Example

If you want to sync your music-files, with Synthing:

Top

Troubleshooting

Some common problems in their solutions.

Pi/rpms cannot be reached on the network

Sometimes the pi is not visible in the network, either by hostname rpms or even by ip-address.

If everything fails (no hostname shown for pi, multiple ip-addresses for hostname, not able to ping on hostname, etc.), try:

Pi/rpms can only reached by ip-address

On some local networks, there might be a problem present that the hostname of all connected devices, including RPMS cannot be resolved. In practice, ping rpms does not return anything. So any command directly targeted at RPMS such as ssh pi@rpms does not work. This is a problem within the router/network, the origin of this problem is unknown to date.

The good news however is that a device is always accessible by ip-address. So once you know the ip-address of your RPMS-instance, you can install, configure and use RPMS. All you have to do is the following: in any command in the section Installation of RPMS on a Pi (and following sections), replace RPMS with the discovered ip-address.

So for example, if the ip-address of RPMS is 192.68.1.20: ping rpms will become ping 192.68.1.20. And ssh pi@rpms will become ssh pi@192.68.1.20. In your browser, LMS rpms:9002 will become 192.68.1.20:9002 Etc.

Note that the ip-address might change over time b/c RPMS does not use a fixed address, but instead depends on the router which determines the address. In that case, point to the new address.

Reconnect players after LMS migration

When migrating from an existing LMS-server or upgrading your Pi-hardware, you have to reconfigure all players to point to the new LMS-server (even if LMS has the same name). This is especially true for Squeezebox-hardware like Squeezebox Classic, Duet, Touch, Radio, Boom or Transporter. Note: clients with piCorePlayer will autodetect the new LMS-server.

Reconfiguring is best done:

Top

Update RPMS

Update your RPMS-server by the web-interface:

You can also opt to update through ssh on rpms:

Note. Update is disabled when there is no newer version found.

Note. For developer-purposes, you might want to update from the development-branch, to have the latest-and-greatest version of RPMS. Beware that this might be unstable, so use with caution! See Update from another git branch for details.

Top

Transcoder

Within RPMS, there is a transcoder built in, for transcoding your lossless music files (flac) into lossy ones (ogg or mp3). By default, the transcoder is not active, it must be configured to become active.

Enabling transcoder

For getting transcoding to work, take the following steps:

From now on, file transcoding will take place and lossy-files will automagically appear in the given lossy-folder without any interaction.

In the Transcoder-page, You can also click on the Transcode-button, to start an immediate transcoding session, for if you do want to wait for the automatic session to kick in. Note that this button is disabled if transcoding is not configured.

Notes

Top

Backup

You can make a backup of all the data contained in your RPMS-server. You have the choice for a full, server-based backup. Or a remote backup, where your backup contains basically the data/user-part of RPMS. A proper backup is the basis for disaster recovery.

Server-based backup

The advantage of the server-based (local) backup is that the resulting backup is an identical copy of the data-disk, making it very easy to switch in case of a disaster. The disadvantage is that you have to have local access to the server (Pi) for attaching the backup-disk.

This backup will be done to a dedicated backup-disk, connected to the Pi itself, thus a server-based backup.

Steps to create a server-based backup

Viewing backup-data on the usbbackup-disk

In case of a server-based backup, your backup will be made to a separate backup-disk. You can view the data on this disk, either online or offline:

Remote backup

The advantage of the remote backup is that you can use a protocol at wish, be it ssh/rsync or syncthing (which is built-in in RPMS) or SMB. The disadvantage of a remote backup is that in case of a disaster, it is a lot more work to get up-and-running again.

Note that system-data is also present on the data-part ('Public') in the form of a file rpms-system.zip. Thus, as you backup the user-data, you also backup the system-files resulting in a full backup.

For a backup using rsync over SSH, here is an example-script:

#!/bin/bash
rsync --progress --delete -rtv --max-size=4GB --modify-window=2 --exclude Downloads \
pi@rpms:/media/usbdata/user/* \
/media/$USER/<disklabel of backup-disk>/backup/user
sync

Top

Disaster Recovery

Disaster can come from anywhere: a broken Pi (very unlikely), a corrupt SD-card or a data-disk which gets broken. In each case, the solution within RPMS is very simple

Broken Pi (very unlikely)

Steps to get back on track:

You may possibly need to reconnect player(s)

Corrupt SD-card

Steps to get back on track:

You may possibly need to reconnect player(s)

Data-disk crash

In case of a server-based backup, you are 'lucky': b/c the backup-disk is an exact copy aka mirror of the data-disk and even of the same disk-type (ext4), you can simply swap them once the data-disk has been crashed.

Steps to get back on track:

By now, the backup-disk has been automagically changed into a data-disk and you can go on from the last backup that you made.

Note. As a bonus, you might rename the original usbdata-disk from usbdata to usbbackup and plug it into the Pi. Then you can do your backups again, as usual.

In case of a remote backup, you have more work to do:

Remember to make a backup to a new backup-disk immediately!

Top

Development

For the developer for RPMS, several tips-and-tricks are available to make development easier.

Update from another git branch

By default, the update-mechanism looks at the master branch on github. However, it is possible to override the master branch version, by setting the desired branch version to a different value.

In most cases this is the develop branch. Once set, you can update to the latest developer-features. But b/c this is considered as experimental (non-stable), use this option with precaution!

For overriding update from master to develop branch

Once the override-file update-branch.txt has been set, you can update your RPMS as usual, it will now update RPMS to the latest version on develop. See Update RPMS for details.

For reverting the update-override

Simply delete the update-branch.txt file:

Note. Once an override is active, the current and available version do not play a role anymore.

Note. If local DNS does not work, the hostname rpms has to be replaced by the ip-address of that machine. See Check your network if local DNS works for details.

Build development version with separate hostname

A regular install of rpms results in a Pi with hostname rpms, which is fine. As a developer, you want to test your code on a different machine then the one in production, on a second Pi; but having two machines within the network with the same hostname, results in errors.

You can opt for using rpmsdev as the hostname for that second Pi. This is done while burning the SD-card, as the first step in the installation process Installation of RPMS on a Pi

The other steps in the installation process stay the same. In the end, this results in a Pi with a hostname rpmsdev, so you can easily distinguish and address the two, development (rpmsdev) and production (rpms). From now on, you can reach the development-server on rpmsdev.

Note. It must be clear that if you do not have a production/live machine for rpms in your network and you are using the installed Pi solely for testing purposes, there is no need to have a different hostname, the standard rpms will do just fine.

Tip. In case hostnames rpms and rpmsdev get mixed up, try to flush DNS:

Update and install from local files

As a developer, you want to test your changes on a physical machine (Pi). As the changes in the code are usually done on a different machine than the one on which the test takes place, you have to have a way to transfer your code to the (test) Pi and install them to see the result.

To have the code locally on your development-machine

Copy local code to a Pi and install the (changed) code

Note. The transferred code is dependent on the chosen git-branch. By changing the branch, you can transfer and test any code in any branch.

Note. You can also do this 'trick' in a live, production-environment, but then you must know what you are doing, so don't try this at home! Usually, a production-machine is updated through the regular update-mechanism, in which code is retrieved from the git-repo on github (be it the master-branch or, if overridden, by another branch, usually develop).

Note. If local DNS does not work, the hostname rpmsdev must be replaced by the ip-address of that machine. See Check your network if local DNS works for details.

Local test-environment on your development-machine

Testing on a (second) machine/Pi is the ultimate test, but to quickly see your changes in the web-interface (api or web) on your development-machine, we can set up an environment for exactly that.

In short, you have to open two terminals, each running a web-service, one running the api, the second running the web-UI.

Steps to setup a local web-environment

Note. This environment is very limited b/c not all components which the code interacts with, such as disks or docker-containers or the Pi itself, are not available (however, you can spoof some of those components). But for seeing changes in the UI, this works just fine.

Local LMS-player

As a developer, it is useful to have at least one player which can connect to the LMS-server. We can easily transform a regular laptop or PC to a local player, just for testing purposes.

Steps for installing a local player:

List of API requests

Top

Migrating to 1.0

Coming from any version below 1.0, you cannot migrate through the usual upgrade-command b/c the upgrade will introduce breaking changes which turn your system into a broken one. Furthermore, b/c we moved the OS from 32-bit to 64-bit, a new image-burn is needed.

Steps to migrate to 1.0

(1) Burn a SD-card

(2) Convert your system

(3) Install the new SD-card, boot the Pi and finish the installation

(4) Check system if all is working well:

Optional

Top