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

OpenFilerInstallationGuide

From SqueezeboxWiki

Revision as of 07:15, 24 July 2009 by Wfaulk (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This is how I installed SqueezeCenter 7.3.3 on OpenFiler 2.3 x86_64.

I've probably forgotten any number of things. Feel free to provide feedback.

All monospaced text is intended to be typed in as the root user at the command line, which can be accessed using a secure shell client, like PuTTY (Windows) or ssh (everywhere else).

Contents

OpenFiler installation

First install OpenFiler. Details are outside the scope of this document, but there's nothing terribly special about installing it, and nothing special you need to do during installation to make SqueezeCenter work.

Once it's installed, do a complete system update. From the WebUI, System → System Update → Launch system update. Update everything.

Install conary packages

Log into your OpenFiler box via ssh and install the following packages. The first-level bullets should be all the ones you explicitly have to type; the second-level bullets were autoinstalled as dependencies, but I listed them just in case a dependency changes, one of them doesn't get installed, and it's needed for the SqueezeCenter installation.

The command to install conary packages is "conary update <packagename>". For example, "conary update glibc:devel".

  • gcc
    • libgcc:devellib
  • gcc-c++
    • libstdc++:devel
    • libstdc++:devellib
  • glibc:devel
    • glibc:devellib
    • linux-kernel-headers:devel
  • libjpeg:devel
    • libjpeg:devellib
    • libjpeg:lib
  • zlib:devel
    • zlib:devellib
  • libpng:devel
    • libpng:devellib
    • libpng:lib
  • expat:devel
    • expat:devellib
  • bzip2:devel
    • bzip2:devellib
  • openssl:devel
    • openssl:devellib
    • krb5:devel
    • krb5:devellib
  • gd:devel
    • gd:devellib
    • gd:lib
    • fontconfig:runtime
    • fontconfig:lib
    • freetype:lib
    • xorg-x11:data
    • xorg-x11:lib
  • xorg-x11:devel
    • xorg-x11:devellib
    • fontconfig:devel
    • fontconfig:devellib
    • freetype:devel
    • freetype:devellib
  • db:devel
    • db:devellib
  • mysql-server
    • mysql:runtime
    • mysql:lib
    • mysql:data
    • info-mysql:user
  • mysql:devel
    • mysql:devellib

These packages are not required at all, but can be useful in testing:

  • ftp
  • ncurses-devel
    • ncurses:devellib
  • man-pages
  • unzip
  • lynx

Configure OpenFiler

Configure mysql

  • /etc/init.d/mysqld start
  • mysql -u root
    • create database slimserver;
    • grant all on slimserver.* to slimserver identified by 'password';
    • grant all on slimserver.* to 'slimserver'@'localhost' identified by 'password';
    • flush privileges;

Add a user for SqueezeCenter

I used the OpenFiler's internal LDAP server for authentication, and that's what I'll describe here. If you're using something else, you probably already know how to create a user.

Open the OpenFiler web interface and go to Accounts → Authentication → Standard View.

  • Enable the "Use Local LDAP server" checkbox
  • For "Base DN", you can leave it as the default of "dc=example,dc=com", but you might want to personalize that.
  • For "Root Bind DN", you want to define the LDAP server superuser's id. I use "cn=admin,dc=example,dc=com", but you can use whatever you want. It probably makes sense to have it end with the Base DN.
  • Now enter a password in the "Root Bind Password" field. You are defining the superuser's password.
  • Click "Submit"

Now go to Accounts → Administration → Group Administration. Create a new group named "slimsrv".

Now go to Accounts → Administration → User Administration and create a new user named "slimsrv". Set the primary group to "slimsrv".

Now we need to change the user's login shell and home directory so that the account is usable to run the server.

Here are the scripts I use for this purpose. You'll have to edit the BINDDN and BASEDN variables in each script to match your configuration.

  • of_chsh
#!/bin/sh

BINDDN="cn=admin,dc=example,dc=com"
BASEDN="ou=People,dc=example,dc=com"

USER=$1
SHELL=$2

if [ -z "${USER}" -o "${3}" ]; then
        echo "Usage: $0 <username> [<shell>]"
        exit 1
fi

ldapsearch -s base -x -b "uid=${USER},${BASEDN}" > /dev/null
if [ $? -ne 0 ]; then
        echo "Error: User ${USER} not found in LDAP server"
        exit 1
fi

if [ -n "${SHELL}" ]; then
        grep -q -E -e "^${SHELL}$" /etc/shells
        if [ $? -ne 0 ]; then
                echo "Error: ${SHELL} not found in /etc/shells"
                exit 1
        fi
fi

echo -n "Current shell: "
ldapsearch -LLL -s base -x -b "uid=${USER},${BASEDN}" loginShell | grep loginShell | awk '{print $2}'

if [ -z "${SHELL}" ]; then
        exit
fi

ldapmodify -x -D ${BINDDN} -W <<EOF
dn: uid=${USER},${BASEDN}
changetype: modify
replace: loginShell
loginShell: ${SHELL}
EOF
  • of_chdir:
#!/bin/sh

BINDDN="cn=admin,dc=example,dc=com"
BASEDN="ou=People,dc=example,dc=com"

USER=$1
DIR=$2

if [ -z "${USER}" -o -n "${3}" ]; then
        echo "Usage: $0 <username> [<homedir>]"
        exit 1
fi

ldapsearch -s base -x -b "uid=${USER},${BASEDN}" > /dev/null
if [ $? -ne 0 ]; then
        echo "Error: User ${USER} not found in LDAP server"
        exit 1
fi

if [ -n "${DIR}" ]; then
        if [ ! -d ${DIR} ]; then
                echo "Error: ${DIR} is not a directory"
                exit 1
        fi
fi

echo -n "Current home directory: "
ldapsearch -LLL -s base -x -b "uid=${USER},${BASEDN}" homeDirectory | grep homeDirectory | awk '{print $2}'

if [ -z "${DIR}" ]; then
        exit
fi

ldapmodify -x -D ${BINDDN} -W <<EOF
dn: uid=${USER},${BASEDN}
changetype: modify
replace:homeDirectory
homeDirectory: ${DIR}
EOF

I set the user's home directory to /usr/local/slimserver and the shell to /bin/ash, but neither probably makes much difference as long as they are valid.

Install perl modules

You can choose to install perl modules either in the default perl hierarchy (/usr/lib/perl) or you can install them in a completely separate directory, and point the perl binary to that directory through the use of the PERL5LIB environment variable. I chose the latter so that none of the perl modules would affect any of the OpenFiler processes. (I did at one point install in the default hierarchy and everything seemed fine, so I'm probably just being paranoid.)

If you want to install in a separate directory, include the lines in red with an overbar. (Obviously, change the path everywhere if you're not happy with the directory I chose.) If not, leave them out.

  • mkdir /usr/local/sc-perl
  • export PERL5LIB=/usr/local/sc-perl/lib/perl5:/usr/local/sc-perl/lib/perl5/site_perl:/usr/local/sc-perl/lib64/perl5:/usr/local/sc-perl/lib64/perl5/site_perl
  • cpan
    • if you haven't run cpan before, it'll ask a lot of questions
      • answer "Parameters for the 'perl Makefile.PL' command" as "PREFIX=/usr/local/sc-perl"
      • answer "Policy on building prerequisites" as "follow"
      • choose nearby CPAN servers
      • defaults for everything else is fine
    • install Bundle::CPAN
      • there may be a few times that input is requested. The default is always fine
      • this takes forever
      • will eventually stop. (In my case, it complained of a circular dependency that seemed to disappear upon the next run of cpan.) Type exit
  • run cpan again
    • more questions:
      • "Parameters for the 'perl Build.PL' command" "--install_base /usr/local/sc-perl"
      • defaults
    • o conf commit

SqueezeCenter perl modules

Now get ready to install a load of perl modules. Some of the modules provided in the SqueezeCenter distribution are binary modules that are incompatible with OpenFiler's perl and cause a crash. I decided rather than picking and choosing the incompatible modules to just install all of them myself, except for the ones where SqueezeCenter requires an obsolete version. If you want to try replacing just the necessary ones, feel free. I know for certain that DBI causes a segfault, but I'd be suspicious of all of the rest of the binary modules. I'm pretty sure you can find all of the shared objects under .../CPAN/arch/.

Open the cpan interface by running "cpan" again and install each of these by typing "install <modulename>", for example, "install Compress::Zlib".

Explicitly required modules:

  • Compress::Zlib
  • DBI
  • DBD::mysql
    • You might need to create a test database with appropriate permissions.
  • Digest::SHA1
  • Encode::Detect
  • JSON::XS
  • HTML::Parser
  • POE::XS::Queue::Array
  • Template
  • Time::HiRes
  • XML::Parser::Expat
  • YAML::Syck
  • GD

Implicitly required modules:

  • version
  • Cache::Cache
  • Class::Accessor
  • Class::Data::Accessor
  • Class::Data::Inheritable
  • Class::Inspector
  • DBIx::Class
  • Data::URIEncode
  • Date::Parse
  • File::BOM
  • File::Next
  • IO::String
  • JSON::XS::VersionOneAndTwo
  • Log::Log4perl
  • Math::VecStat
  • Net::DNS
  • Net::IP
  • Net::UPnP
  • Path::Class
  • Proc::Background
  • SQL::Abstract
  • Text::Unidecode
  • Tie::Cache::LRU
  • Tie::LLHash
  • Tie::RegexpHash
  • Time::Zone
  • XML::Simple

Super-secret required modules:

  • File::Slurp
  • Exporter::Lite
  • Data::Dump
  • DBIx::Migration
  • Tie::Cache::LRU::Expires
  • URI::Find
  • Tie::IxHash
  • PAR

Some of these may already be up to date. Some may ask for input; defaults fine.

I think the DBIx modules are actually not needed, as SqueezeCenter needs the distributed versions. You can try leaving these out if you want, but I didn't realize that until after I'd already installed them and it worked fine.

Install SqueezeCenter

  • /etc/init.d/mysqld stop
  • Download squeezecenter-7.3.3.tgz to /usr/local/src
  • cd /usr/local
  • tar zxf src/squeezecenter-7.3.3.tgz
  • ln -s squeezecenter-7.3.3 slimserver
  • cd slimserver
  • mv CPAN CPAN.o
  • mkdir -p CPAN/Class/XSAccessor
  • cp CPAN.o/Class/XSAccessor/Array.pm CPAN/Class/XSAccessor/
  • cp -r CPAN.o/DBIx CPAN/
  • mkdir -p prefs/plugin
  • mkdir log
  • mkdir cache
  • chown -R slimsrv:slimsrv .
  • chmod -R ug+rwX .
  • If you're installing in a separate perl hierarchy and this is not the same shell session you used to install the perl modules, you'll have to set the PERL5LIB environment variable as before
  • su slimsrv -c "/usr/local/slimserver/slimserver.pl --cachedir=/usr/local/slimserver/cache --audiodir=/music --pidfile=/usr/local/slimserver/cache/slimserver.pl.pid --prefsdir=/usr/local/slimserver/prefs --playlistdir=/music --logfile=/usr/local/slimserver"/log/ss.log
  • wait until prefs/server.prefs exists
  • press Ctrl-C to exit
  • edit prefs/server.prefs to have these settings
    • dbpassword: 'password'
    • dbsource: dbi:mysql:database=slimserver
    • dbusername: slimserver
  • /etc/init.d/mysqld start
  • su slimsrv -c "/usr/local/slimserver/slimserver.pl --cachedir=/usr/local/slimserver/cache --audiodir=/music --pidfile=/usr/local/slimserver/cache/slimserver.pl.pid --prefsdir=/usr/local/slimserver/prefs --playlistdir=/music --logfile=/usr/local/slimserver/log/ss.log"
  • Test slimserver to make sure it's running properly. Going to the web interface should be fine.
    • If it's running okay, press Ctrl-C to exit
  • Save this file as /etc/init.d/slimserver and edit the variables at the top to match your configuration. If you didn't install your perl modules in a separate hierarchy, remove all of the references to perl5lib.
#!/bin/sh
#
#       /etc/init.d/slimserver
#
# description: slimserver is a networked media server
# chkconfig: - 99 01
# processname: slimserver.pl
# Source function library.
. /etc/init.d/functions

prog=slimserver.pl
progdir=/usr/local/slimserver
progpath=${progdir}/${prog}
cachedir=${progdir}/cache
prefsdir=${progdir}/prefs
logfile=${progdir}/log/ss.log

pidfile=${cachedir}/${prog}.pid

audiodir=/mnt/vg0/media/music
playlistdir=/mnt/vg0/media/slimplaylists

user=slimsrv

perl5lib=/usr/local/sc-perl/lib/perl5:/usr/local/sc-perl/lib/perl5/site_perl:/usr/local/sc-perl/lib64/perl5:/usr/local/sc-perl/lib64/perl5/site_perl

RETVAL=0

#
# See how we were called
#

start() {
        # Check if slimserver is running
        if [ ! -f /var/lock/subsys/${prog} ]; then
                echo -n $"Starting slimserver: "
                daemon su ${user} -c \"PERL5LIB=${perl5lib} ${progpath} --cachedir=${cachedir} --audiodir=${audiodir} --pidfile=${pidfile} --prefsdir=${prefsdir} --playlistdir=${playlistdir} --logfile=${logfile} --quiet --daemon \> /dev/null\"
                RETVAL=$?
                [ $RETVAL -eq 0 ] && touch /var/lock/subsys/${prog}
                ln -s ${pidfile} /var/run/${prog}.pid
        fi
        echo
        return $RETVAL
}

stop() {
        echo -n $"Stopping slimserver: "
        killproc ${progpath}
        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/${prog}
        echo
        return $RETVAL
}


restart(){
        stop
        start
}

case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
restart)
        restart
        ;;
reload)
        restart
        ;;
condrestart)
        if [ -f /var/lock/subsys/${prog} ]; then
                restart
        fi
        ;;
status)
        status ${prog}
        ;;
*)
        echo "Usage: slimserver {start|stop|restart|reload|condrestart|status}"
        exit 1
esac

exit $RETVAL
  • /etc/init.d/slimserver start
  • /sbin/chkconfig --levels 345 slimserver on
    • this configures the OS to start slimserver on boot

Tidy up

  • /usr/bin/mysql_secure_installation
    • This will clean up and secure the mysql databases
  • It wouldn't be a bad idea to reboot and make sure everything starts as it should.