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

SheevaPlug Installation guide

From SqueezeboxWiki

Revision as of 15:24, 12 January 2011 by Zoop (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page describes various ways of how to install SqueezeCenter on a SheevaPlug.

Contents

Installation Guide for Dummies

'thruehl' has put up a very detailed and easy to read guide. He also provides images for SD-Cards which can be used with the SheevaPlug 'out-of-the-box'.

The Guide is now available as a wiki: http://wiki.slimdevices.com/index.php/Sheevaplug_SBS_Server_for_dummies

If you like having more 'fun' (i.e. googling, reading more, making mistakes, learning by it, understanding your plug) you can still go for the next sections.

Install SqueezeBoxServer (post 7.4.1)

As of 7.4.1 r28877, the standard Debian package should install and run on SheevaPlug systems running Ubuntu or Debian Lenny or later.

The following instructions will give you hints for a very 'easy' installation. Most of the time I will link to existing Wiki-Pages explaining the steps in a very detailed fashion. All these instructions assume a 'new' SheevaPlug.

By following this steps you will get:

  • A SheevaPlug with the original Ubuntu distribution. It will be copied to a SDCard to provide more space to install things. (2GB SDCard will be sufficient)
  • An USB-Disk which will be attached to the Sheeva-Plug to host all your music. Personally I use a Western Digital MyBook Essential. It automatically spins down, when there is no read or write access so you system will get dead silent :)

Create serial connection to Sheeva Plug

You might have noticed - the SheevaPlug doesn't have a monitor out ? So how do we see whats going on ?

To get access to your SheevaPlug you will need to create a so called 'serial connection'. This is just connecting an USB-cable (provided with the Sheeva) between the Sheeva and your computer. In addition you need to install some windows-drivers which are available on the Sheeva-CD or can be downloaded from the net. I tested the drivers with Windows Vista and XP and both worked easily. After that you can connect to your Sheeva with a program called 'Putty' and can watch it booting like on a real monitor.

More on this you can find in the PlugComputer Wiki:

http://plugcomputer.org/plugwiki/index.php/Serial_terminal_program

http://plugcomputer.org/plugwiki/index.php/How-to_setup_PuTTY_for_the_SheevaPlug_on_Windows

Do some housekeeping on the system

Some quirks of a new SheevaPlug will need to be adjusted. Just follow these steps

http://plugcomputer.org/plugwiki/index.php/New_Plugger_How_To

Furthermore you should copy the whole system to a SDCard to have some room for various stuff:

http://plugcomputer.org/plugwiki/index.php/SD_Card_As_Root_File_System

(there was one error in this tutorial as my SD-Card slot was called '/dev/mmcblk0' instead of '/dev/mmcblk0p1'

Connect USB-Drive

Now we want to get an USB drive connected to the SheevaPlug.

My drive was formatted as 1GB Fat32, I had to repartition it to use 1TB and formatted it with ext3. Then I had to change /etc/fstab to mount the drive (to /mnt/usbdisk). I'm afraid you have to google the steps involved yourself. Programs involved are fdisk, mkfs. Mounting is done in the /etc/fstab file.

To copy files to the USB-drive from Windows you will need a networkshare. Samba (a program to create windows network-shares under linux) is preinstalled on the SheevaPlug (and configured to expose everything under /mnt ) and you can already access the USB-drive (use \\NAMEOFSHEEVA in WindowsExplorer). But: windows will moan if you try to copy more than one GB (thats the space left on my SD-card ...) so one can only copy smaller chunks. To get full and easy access to the usbdrive, an extra samba-share starting at /mnt/usbdisk should be created. More on this you will find in the chapter #Sharing the Disk You Just Mounted later on

Install SqueezeBoxServer

Now comes the easy part :) ... installing the SqueezeBoxServer. First you will need to download the install package, then we just install it

cd ~
wget http://downloads.slimdevices.com/SqueezeboxServer_v7.4.1/squeezeboxserver_7.4.1_all.deb
dpkg -i squeezeboxserver_7.4.1_all.deb
apt-get -f install

If everything worked well you should be now able to see you SqueezeBoxServer, just surf to http://YOURSHEEVANAME:9000/

SqueezeBoxServer will start automatically when you reboot the Sheeva. If for some reason you need to manually start or stop SqueezeBoxServer use the following commands

 /etc/init.d/squeezeboxserver stop
 /etc/init.d/squeezeboxserver start

If you want to use on-the-fly transcoding to MP3 for bitrate limiting or useing the stream.mp3 URL, you will need to install Shine, since LAME is much too slow on the SheevaPlug.

Install Debian on the SheevaPlug (pre 7.4.1)

I have used the instruction given on this page: [1]. I have only tested the installation on an USB stick.

I have only tuned the /etc/fstab in order to mount tempory files using tmpfs and to add the option noatime for the main partition:

proc            /proc           proc    defaults        0       0
/dev/sda1       /               ext3    errors=remount-ro,noatime 0       1
/dev/sda2       none            swap    sw              0       0
tmpfs /var/run  tmpfs defaults 0 0
tmpfs /var/lock tmpfs defaults 0 0
tmpfs /var/log  tmpfs defaults 0 0
tmpfs /tmp      tmpfs defaults 0 0

Preparing the system

Some additional libraries and programs are needed in order to install SqueezeCenter. To install them, simply run this command:

apt-get install mysql-server gcc g++ libgd2-noxpm-dev libexpat1-dev make
apt-get clean

You may need to run apt-get update before the apt-get install... command above.

If you do not need MySQL for other server operations, you do not need MySQL server to be running (SqueezeCenter will run its own instance), you can stop it:

/etc/init.d/mysql stop

This stops the current instance of MySQL server but does not prevent it from launching the next time the SheevaPlug boots. To do that requires renaming or removing some symbolic links in the /etc/rc?.d directories (these directories control what automatically gets launched at different runlevels). Do:

 cd /etc
 ls rc?.d/S*mysql*

Rename these files to start with a 'K' instead of an 'S' or just remove them altogether. A simple way to remove them is to use the update-rc.d script:

update-rc.d -f mysql remove
update-rc.d -f mysql-ndb remove
update-rc.d -f mysql-ndb-mgm remove

Now, it is time to create the user that will run SqueezeCenter:

adduser --system --group slimserver

Installing SqueezeCenter

All the other steps will be done with the slimserver user. It is time to become this user and to move to its directory:

su -s /bin/bash slimserver
cd

I have installed the latest stable release. I order to download it and to decompress it, just type:

wget http://downloads.slimdevices.com/SqueezeboxServer_v7.4.1/squeezeboxserver-7.4.1.tgz
tar xfz squeezeboxserver-7.4.1.tgz
cd squeezeboxserver-7.4.1-28947

The MySQL Error file shipped with SqueezeCenter is not adapted to the Debian MySQL version. You have to change one file:

rm MySQL/errmsg.sys 
ln -s /usr/share/mysql/english/errmsg.sys MySQL/

Running SqueezeCenter

Your installation is now completed. To launch SqueezeCenter, simply type:

./slimserver.pl

After a couple of minutes, you should be able to use your browser to configure SqueezeCenter.

If you want to run SqueezeCenter as a daemon, use the following command line:

./slimserver.pl --daemon

Add a script to launch SqueezeCenter during boot

Create a file in /etc/init.d/ called slimserver with the following text:

#! /bin/sh

# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Squeezebox Music Server"
NAME=slimserver.pl
DAEMON=/home/slimserver/squeezeboxserver-7.4.1-28947/slimserver.pl
DAEMON_ARGS="--user slimserver --group slimserver --pidfile /var/run/slimserver.pid --daemon"
PIDFILE=/var/run/slimserver.pid
SCRIPTNAME=/etc/init.d/slimserver

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
#VERBOSE=yes

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

#
# Function that starts the daemon/service
#
do_start()
{
	# Return
	#   0 if daemon has been started
	#   1 if daemon was already running
	#   2 if daemon could not be started
	start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
		|| return 1
	start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
		$DAEMON_ARGS \
		|| return 2
	# Add code here, if necessary, that waits for the process to be ready
	# to handle requests from services started subsequently which depend
	# on this one.  As a last resort, sleep for some time.
}

#
# Function that stops the daemon/service
#
do_stop()
{
	# Return
	#   0 if daemon has been stopped
	#   1 if daemon was already stopped
	#   2 if daemon could not be stopped
	#   other if a failure occurred
	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
	#start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --name $NAME
	RETVAL="$?"
	[ "$RETVAL" = 2 ] && return 2
	# Wait for children to finish too if this is a daemon that forks
	# and if the daemon is only ever run from this initscript.
	# If the above conditions are not satisfied then add some other code
	# that waits for the process to drop all resources that could be
	# needed by services started subsequently.  A last resort is to
	# sleep for some time.
	start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
	[ "$?" = 2 ] && return 2
	# Many daemons don't delete their pidfiles when they exit.
	rm -f $PIDFILE
	return "$RETVAL"
}

#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
	#
	# If the daemon can reload its configuration without
	# restarting (for example, when it is sent a SIGHUP),
	# then implement that here.
	#
	start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
	return 0
}

case "$1" in
  start)
	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
	do_start
	case "$?" in
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac
	;;
  stop)
	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
	do_stop
	case "$?" in
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac
	;;
  #reload|force-reload)
	#
	# If do_reload() is not implemented then leave this commented out
	# and leave 'force-reload' as an alias for 'restart'.
	#
	#log_daemon_msg "Reloading $DESC" "$NAME"
	#do_reload
	#log_end_msg $?
	#;;
  restart|force-reload)
	#
	# If the "reload" option is implemented then remove the
	# 'force-reload' alias
	#
	log_daemon_msg "Restarting $DESC" "$NAME"
	do_stop
	case "$?" in
	  0|1)
		do_start
		case "$?" in
			0) log_end_msg 0 ;;
			1) log_end_msg 1 ;; # Old process is still running
			*) log_end_msg 1 ;; # Failed to start
		esac
		;;
	  *)
	  	# Failed to stop
		log_end_msg 1
		;;
	esac
	;;
    status)
	if ( /usr/bin/pgrep -u slimserver slimserver.pl > /dev/nul ); then
	    log_success_msg "slimserver is running"
        else
	    log_failure_msg "slimserver is not running"
	fi
	;;
  *)
	#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
	exit 3
	;;
esac

:

This script is a modified version of the /etc/init.d/skeleton example script.

The DAEMON=/home/slimserver/squeezeboxserver-7.4.1-28947/slimserver.pl line near the top of the program just says where the "slimserver.pl" file is located. Your location may be different, depending on version.

In /etc there is a series of directories rc0.d rc1.d . . . rc6.d. These directories control what is launched on boot for each runlevel. In each of these directories you will need an entry for launching the slimserver script above. These entries will either start with an S (which stands for "start") or a K (which stands for stop). They start with "S##" (where "##" is a two-digit number). In each of the rc?.d directories, you must create a symbolic link to the /etc/init.d/slimserver file you just created but you should use a "##" value that isn't already used. Luckily there is a program, update-rc.d, to help you with this. So, the following lines are just a suggestion, it is up to you to verify you don't create any conflicts.

 update-rc.d slimserver 24

This is equivalent to

 cd /etc/rc0.d
 ln -s ../init.d/slimserver K24slimserver
 cd /etc/rc1.d
 ln -s ../init.d/slimserver K24slimserver
 cd /etc/rc2.d
 ln -s ../init.d/slimserver S24slimserver
 cd /etc/rc3.d
 ln -s ../init.d/slimserver S24slimserver
 cd /etc/rc4.d
 ln -s ../init.d/slimserver S24slimserver
 cd /etc/rc5.d
 ln -s ../init.d/slimserver S24slimserver
 cd /etc/rc6.d
 ln -s ../init.d/slimserver K24slimserver

Using An NTFS USB Disk

Read-Only

Read-only access is simpler.

Create a directory to mount the drive to:

 mkdir /mnt/usbdrive

Place a line in /etc/fstab like:

/dev/sda1 /mnt/usbdrive ntfs uid=XXX,gid=YYY,umask=0022 0 0

where XXX is the user id for the slimserver user and YYY is the group id for the slimserver group. These numbers can be found in /etc/passwd and /etc/group. Alternatively, you can do:

 su -s /usr/bin/id slimserver

The /etc/fstab line above assumes your external drive is NTFS formated. Other disk formats will be slightly different. To start your journey through the confusing options, you can visit a page like mount(8) (with /etc/fstab and mount, you can mount all kinds of music repositories including repositories out on your network on a windows file share somewhere or via NFS).

Now you can mount the device (it will automatically get mounted at boot as well).

mount /mnt/usbdrive

When you configure slimserver, you can now tell it to look for music on the mounted disk.


Sharing the Disk You Just Mounted

To make it easier to manage the disk you just mounted, you can share it via SMB (Windows file sharing). To do this, you use the Samba package which allows a Linux box to speak Windows. You can do a lot with Samba, but this example simply shares the disk you just mounted so anybody on the network can read and write to it.

Go to the samba configuration directory.

 cd /etc/samba

Back up the example configuration.

 cp smb.conf smb.conf.orig

Edit the smb.conf file to say:

[global]
guest account = slimserver
netbiosname = MYPLUG
security = share
socket options = TCP_NODELAY IPTOS_LOWDELAY
workgroup = WORKGROUP
[public]
guest ok = yes
guest only = yes
path = /mnt/usbdrive
read only = no

You will want to change the MYPLUG and WORKGROUP values to reflect the name you wish to call your SheevaPlug and workgroup name of the computer you are going to use to access the SheevaPlug with.

Set up the samba server to start at boot:

update-rc.d samba defaults

Start samba

/etc/init.d/samba start

Start explorer on your desktop machine and enter \\MYPLUG in the address bar. You should see a public share that you can browse into and copy files from.


cat

To be Done

  • Explain how to mount music directory from a NAS (using autofs for example)
  • Make transcoding work using unofficial Debian multimedia packages.
  • Detail installation on SD card.
  • Add a script to lauch SqueezeCenter during the boot.
  • Remover MySQL from the services launched during the boot.
  • install FUSE and ntfs-3g for read-write access to USB NTFS drive.