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

Solaris Installation Guide

From SqueezeboxWiki

Revision as of 00:39, 5 July 2010 by Soulkeeper (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

SqueezeCenter on Solaris is a bit more difficult to setup than Linux, but with a good guide (hopefully this one) you will have it running in no time.

This guide is for SqueezeCenter 7.0.1 to 7.3.3 on Solaris 10 x86 and should be valid for the SPARC version of Solaris. If you are running a version of SlimServer everything in this guide still applies. This guide is only useful on 7.4.x through the installation of MySQL. Logitech removed the build-perl-modules.pl script from the tarball and has replaced it with buildme.sh which isn't included in the tarball release. Run slimserver.pl with no arguments for more info on where to grab the buildme.sh. See this thread for more information on building the modules for 7.4.x.

For OpenSolaris-specific instructions, see Opensolaris.

Contents

Prerequisites

You will need to add two users and groups to your system, one for SqueezeCenter and one for MySQL. The SqueezeCenter user won't need a home directory but the MySQL user will to work properly with the attached Service Management Facility manifest in Solaris 10.

# groupadd slimsrv
# groupadd mysql
# useradd -s /bin/false -g slimsrv -c "SqueezeCenter User" slimsrv
# useradd -s /bin/false -g mysql -d /opt/mysql/var -c "MySQL User" mysql

Installing Perl, MySQL, and other libraries

You will either need to download Perl 5.8.8 from www.perl.org or get a precompiled version from Blastwave or Sunfreeware. Perl 5.10.0 does not work with SqueezeCenter so you must use 5.8.8. If you have Sun Studio (or similar) installed don't use it to compile Perl, use gcc instead. You may need to change the /usr/bin/perl link to point to your new Perl installation.

Once Perl is installed use CPAN to download the Bundle::CPAN. This will install most Perl modules required by SqueezeCenter. It's also a good idea at this time to get DBI::DBD as one of the modules we'll be compiling later will need it.

SqueezeCenter also requires some additional libraries that don't come with the base OS. Download LibGD and FreeType and install them. You will need to go back to CPAN and get the LibGD Perl module. Make sure that the LibGD perl module version matches the LibGD version.

SqueezeCenter requires MySQL so either go back to Blastwave or Sunfreeware and get a precompiled version or download the source and compile it yourself. It's important that both MySQL and Perl are built using the same compiler (gcc recommended for SqueezeCenter) because some of the Perl modules to be installed later use some libraries from MySQL and won't build if the compiler is different. For the following examples I have MySQL installed in /opt/mysql.

Once MySQL is installed the first thing to do is initialize the database tables.

# /opt/mysql/bin/mysql_install_db

Now set the permissions on the database folder.

# chown -R mysql:mysql /opt/mysql/var
# chmod -R 770 /opt/mysql/var

Now start the daemon by hand so we can configure the users and database for use with SqueezeCenter.

# /opt/mysql/bin/mysqld_safe --user=mysql &

Now that the daemon is running configure the user and database.

# cd /opt/mysql/bin
# ./mysqladmin -u root password 'new_password'
# ./mysqladmin -u root -h `hostname` password 'new_password'

Note the back ticks around hostname and the single quotes around new_password. They are not the same! Substitute new_password with the administrator password you want for MySQL.

Now login to the MySQL monitor.

# ./mysql -u root -p
Enter password: new_password
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 39
Server version: 5.0.41 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database squeezecenter;
Query OK, 1 row affected (0.01 sec)

mysql> grant all on squeezecenter.* to squeezecenter identified by 'squeezecenter_password';
Query OK, 0 rows affected (0.04 sec)

mysql> grant all on squeezecenter.* to 'squeezecenter'@'localhost' identified by 'squeezecenter_password';
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
#

The following attributes are set on this database:

  • Database name is squeezecenter
  • Username that is authorized to use this database is squeezecenter
  • Password is whatever you choose to use for squeezecenter_password

You will need these values later when configuring SqueezeCenter to use MySQL.

You may run into an issue with authentication failing between SqueezeCenter and MySQL. If SqueezeCenter is unable to authenticate, you will need to go back to the MySQL monitor and change the password hashing algorithm.

mysql> set password for 'squeezecenter'@'localhost' = old_password ('new_password');
mysql> flush privileges;

Substitute new_password with the password you want.

See ExistingMySQLInstance for a more complete and less Solaris-centric resource.

Installing SqueezeCenter

Once everything else is installed SqueezeCenter is the easy part.

  • Tip: Unpack the archive in the directory you want (e.g. /opt) but don't rename the SqueezeCenter directory. Create a symlink to the SqueezeCenter directory called squeezecenter. This will make upgrades easier and you can always go back to an older version easily simply by changing the symlink to point to a different version. This allows version changes without changing the Service Management Facility files.

Unpack the archive and change to the new SqueezeCenter directory. I have SqueezeCenter installed in /opt. Run

# Bin/build-perl-modules.pl

to build the required modules. It will fail to build the XML-Parser, so change to the XML-Parser directory (/tmp/XML-Parser*) and run the command

# perl Makefile.PL EXPATLIBPATH=/usr/sfw/lib EXPATINCPATH=/usr/sfw/include

to properly configure the Makefile. Run the build-perl-modules.pl script again and this time it will complete successfully.

I have SqueezeCenter keep all of it's configuration in a subdirectory called cache. Make a directory to store your SqueezeCenter config files. At this point it's probably a good idea to make sure that the directory SqueezeCenter is in is owned by your SqueezeCenter user:

# chown -R slimsrv:slimsrv /opt/squeezecenter/

I use a script called scrun to actually start SqueezeCenter. Copy the script below and save it to the SqueezeCenter directory.

#!/bin/sh

PATH=/usr/sbin:/usr/bin:/usr/ccs/bin:/usr/local/bin:/opt/bin
export PATH

/opt/squeezecenter/slimserver.pl --cachedir=/opt/squeezecenter/cache --user=slimsrv --group=slimsrv \
--audiodir=/path/to/music --pidfile=/opt/squeezecenter/cache/squeezecenter.pid $*

Change any paths as needed.

Run the script and remain calm as it will fail to start with an error that the database hasn't been initialized. SqueezeCenter was started without it's configuration file and just created it using the default set that doesn't quite work for Solaris. Edit your server.prefs (slimserver.pref if using SlimServer) file in prefs/ (the cachedir if using SlimServer) and set the following values:

dbpassword squeezecenter_password
dbsource dbi:mysql:database=squeezecenter
dbusername squeezecenter

The values squeezecenter_password, database=squeezecenter, and dbusername squeezecenter all come from the MySQL configuration above. Set accordingly. See ExistingMySQLInstance for a more detailed reference of configuration.

Run the scrun script again and this time SqueezeCenter should again fail with the following error:

Can't call method "log" on an undefined value at /opt/squeezecenter-7.1/CPAN/Log/Log4perl/Appender.pm line 189.

The Logs directory has been created but is owned by root, and when SqueezeCenter switched to it's user it is unable to write to the Logs directory because root owns them. See Bug 5035. Change the ownership and run the scrun script and this time it should run and begin to scan your music folder. Play some music, enjoy the triumph of making it all work. There is still just a little bit of work to do.

Service Management Facility

Now that things are working, it's time to make everything run automatically on system startup. Solaris 10 can use the startup scripts like previous versions, but they are now considered legacy. The preferred method in Solaris 10 is the new Service Management Facility that offers more options and control, but is a bit more difficult to setup. There is currently no GUI for SMF, so open up a console window and get ready to finish up.

First up is the method script for MySQL. This is the actual script that starts and stops MySQL. Copy the script below and save it to /lib/svc/method/svc-mysql. Be sure to edit the paths accordingly. Make sure it's mode 755 otherwise it won't execute.

#!/usr/bin/sh

#

#        William Pool (Puddle) 01/05

#        SMF Method file for MySQL

#        E-mail: puddle@flipmotion.com

#        Modified 08/07 for Slim Devices Wiki

#        by Jeff Roesner

# Modify accordingly!

#

# NOTE: Make sure DB_DIR is owned BY the mysql

# user and group and chmod 700.

#

. /lib/svc/share/smf_include.sh

DB_DIR=/opt/mysql/var

PIDFILE=${DB_DIR}/`/usr/bin/uname -n`.pid



case "$1" in

 start)

  /opt/mysql/bin/mysqld_safe --user=mysql \
  --datadir=${DB_DIR} --pid-file=${PIDFILE} \
  > /dev/null &

 ;;

 stop)

  if [ -f ${PIDFILE} ]; then

   /usr/bin/pkill mysqld_safe >/dev/null 2>&1

   /usr/bin/kill `cat ${PIDFILE}` > /dev/null 2>&1 \
    && echo -n ' mysqld'

   fi

 ;;

 'restart')

  stop

  while pgrep mysqld > /dev/null

  do

   sleep 1

  done

  start

 ;;

 *)

  echo ""

  echo "Usage: `basename $0` \
    { start | stop | restart }"

  echo ""

  exit 64

 ;;

esac

Now copy the XML below and save it to /var/svc/manifest/network/mysql.xml. This file should not need to be modified.

<?xml version='1.0'?>
 <!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<!--

        William Pool (Puddle) 02/05
        Service manifest for MySQL
        E-mail: puddle@flipmotion.com
 -->

 <service_bundle type='manifest' name='mysql:mysql'>

 <service
         name='network/mysql'
         type='service'
         version='1'>
         <create_default_instance enabled='false' />
         <single_instance />


         <dependency name='fs'
                 grouping='require_all'
                 restart_on='none'
                 type='service'>
                 <service_fmri value='svc:/system/filesystem/local' />
         </dependency>

         <dependency name='net'
                 grouping='require_all'
                 restart_on='none'
                 type='service'>
                 <service_fmri value='svc:/network/loopback' />
         </dependency>

         <exec_method
                 type='method'
                 name='start'
                 exec='/lib/svc/method/svc-mysql start'
                 timeout_seconds='-1'>
                <method_context>
                         <method_credential user='mysql' group='mysql' />
                 </method_context>
         </exec_method>

         <exec_method
                 type='method'
                 name='stop'
                 exec=':kill'
                 timeout_seconds='-1'>
         </exec_method>

  <exec_method
                 type='method'
                 name='restart'
                 exec='/lib/svc/method/svc-mysql restart''
                 timeout_seconds='-1'>
         </exec_method>



 </service>

 </service_bundle>

Now copy the XML below and save it to /var/svc/manifest/application/squeezecenter.xml. Make sure the path to your script is correct.

<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type='manifest' name='squeezecenter'>
  <service name='application/squeezecenter' type='service' version='1'>
        <create_default_instance enabled='false'/>
        <single_instance/>
<dependency name='name-services' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/milestone/name-services' />
</dependency>
<dependency name='network' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/milestone/network' />
</dependency>
<dependency name='local-filesystems' grouping='require_all' type='service' restart_on='none'>
<service_fmri value='svc:/system/filesystem/local' />
</dependency>
        <exec_method type='method' name='start'
                exec='/opt/squeezecenter/scrun --daemon'
                timeout_seconds='30' />
        <exec_method type='method' name='stop'
         exec=':kill'
                timeout_seconds='30' />
        <stability value='Unstable' />
        <template>
               <common_name>
                        <loctext xml:lang='C'>SqueezeCenter</loctext>
                </common_name>
                <documentation>
                        <doc_link name='SlimDevices Home' uri='http://www.slimdevices.com/'/>
                </documentation>
        </template>
  </service>
</service_bundle>
# svccfg import /var/svc/manifest/network/mysql.xml
# svccfg import /var/svc/manifest/application/squeezecenter.xml
# svcadm enable mysql
# svcadm enable squeezecenter

If all of the file permissions and paths are correct MySQL and SqueezeCenter should now be running and ready to serve up your music.

Sources

Warren Strange provided an excellent resource for configuring SlimServer on Solaris including the service manifest and slimrun script.

William Pool created the original MySQL manifest and script and was kind enough to post it to Sun's BigAdmin page.