<?sphp $this->text('pagetitle') ?>
 
Home of the Squeezebox™ & Transporter® network music players.

Running multiple SBS instances on Linux

From SqueezeboxWiki

(Redirected from RunningMultipleSlimServers)
Jump to: navigation, search

Running Multiple SlimServer instances

SlimServer serves up a directory tree of music files which can be accessed by players. In some cases it might be desirable to limit the choice of music for certain players. For instance, if the kids have their own Squeezebox, one might want to shield them from some explicit content in Dad's music library. In the current setup SlimServer is not capable of differentiating the libraries as seen by the players.

The following recipe offers a way around this limitation. It relies heavily on Linux-specific stuff, and hence is not very portable across platforms. This solution uses the following ingredients:

  • A reasonably modern Linux
  • Shell scripts
  • iptables
  • Some Linux knowledge

Please remember: this setup is put together with basic tools, and is by no means a polished solution. Use at your own risk etc.

The layout of the solution is roughly as follows:

  • Each SlimServer instance listens on a separate IP address. These IP addresses are added to the Linux config by means of an IP alias.
  • Each SlimServer instance runs under a separate account, each with its own home directory. This home directory is used to store the prefs file, the music dir and the playlists dir.
  • Players have no knowledge of the fact that the server runs multiple instances of SlimServer, so there is no specific player config to change when you use this solution.
  • Players are linked to a specific SlimServer instance using iptables.

The following stuff needs to be set up before diving into the details:

  • Install SlimServer, and get it to work. In this recipe I have installed SlimServer in /home/slimserver/slimserver (so slimserver.pl is at /home/slimserver/slimserver/slimserver.pl).
  • The SlimServer files are all set to user "slimserver", group "slimserver".
  • Choose an IP subnet for the IP addresses for the SlimServer instances. I use IP range 10.0.0.1 - 10.0.0.254.
  • Make sure the stock SlimServer is not running.

The following steps create one SlimServer instance. These steps use <NR> to create instance number <NR>. The first instance you create should be <NR>=1.

  • useradd -d /home/slimserver/<NR> -g slimserver slimserver.<NR>
  • mkdir /home/slimserver/<NR>
  • chown slimserver.<NR>:slimserver /home/slimserver/<NR>
  • chmod 700 /home/slimserver/<NR>
  • ifconfig lo:<NR> 10.0.0.<NR> netmask 255.255.255.255
  • /home/slimserver/slimserver/slimserver.pl --daemon --prefsfile /home/slimserver/<NR>/slimserver.conf --logfile /home/slimserver/<NR>/slimserver.log --httpaddr 10.0.0.<NR> --cliaddr 10.0.0.<NR> --playeraddr 10.0.0.<NR>

This should get you a slimserver on IP address 10.0.0.<NR>. Check the output of netstat -na, this should show a process listening on TCP 10.0.0.<NR>:9000, TCP 10.0.0.<NR>:9090 and TCP 10.0.0.<NR>:3483, and a UDP entry for 10.0.0.<NR>:3483. To let a (Squeezebox or SoftSqueeze) player which is located at IP address <playerip> have access to SlimServer instance <NR>, you need to set up the following iptables rules:

  • iptables -t nat -A PREROUTING -s <playerip> -m multiport -p tcp --destination-ports 3483,9000,9090 -j DNAT --to-destination 10.0.0.<NR>
  • iptables -t nat -A PREROUTING -s <playerip> -p udp --destination-port 3483 -j DNAT --to-destination 10.0.0.<NR>

This will forward incoming requests from that specific player to the new SlimServer config. After this step, the player should be able to contact the server.

Now set up the playlists and music directory for the SlimServer <NR> instance. You could do that for instance like so (this example assumes the master music library in /home/music):

  • mkdir /home/slimserver/<NR>/music
  • mkdir /home/slimserver/<NR>/playlists
  • chown slimserver.<NR>:slimserver /home/slimserver/<NR>/*
  • cd /home/slimserver/<NR>/music
  • ln -s /home/music/Beatles Beatles
  • ln -s /home/music/"Rolling Stones" "Rolling Stones"
  • ln -s /home/music/Queen/"We will rock you.mp3" "We will rock you.mp3"
  • etc

Now start a browser on the SlimServer machine and point it to http://10.0.0.x:9000, specify the music and playlists, do a full rescan, and away you go.

Some extra points:

  • If you want to use the browser on another machine to configure a specific SlimServer instance (for instance, if the kids use a specific machine to access the server), you have to add the iptables rules for that client as well.
  • If necessary, lock down the settings page on the webserver of SlimServer so the user cannot alter the music directory.
  • The steps for the "ifconfig", the "slimserver.pl", and the "iptables" commands have to be re-run if the server machine is rebooted. Attached is an example replacement for the startup script.


See also