Knockso Music Server

Description

This page basically describes how I setup a Knoppix 5.0.1 instance to be a Sockso music server in what is really an appliance mode.  Of course you can use any newer Knoppix release, and probably shortcut a few steps - but based on the size of the disk in the server Im using (6 Gb), I needed to keep the install small and tight - so I needed a CD based release, not the DVD as the DVD tries to install more software than I have room for.  I would imagine that 5.1.1 would work even better than 5.0.1 but I didnt have it and was tired of burning ISO's.

Anyway, this page is an extension of my other Sockso Music Server page, which really just explains how to install it on any given machine, application only.  This page differs by explaining the whole server build.

Process/Implementation

There were a few steps to get this going.  I'll lay them out below as I had done them.

  1. First, insert your Knoppix cd into your machine, and boot from it.  After it comes up, and you have selected which desktop you like, go ahead and launch the knoppix installer by opening a terminal window and becoming root, and running "knoppix-installer".  I just took the defaults for everything except the type of install (I chose Knoppix instead of Debian), and when prompted, I rebooted without the CD.
  1. Now you have an installed knoppix instance, we now need to set it up how its needed.  For me that means no dhcp, static IP address, hostname change, startup services, and a few other things like new users, new groups, and of course big brother.  Lets start with the users and groups - so edit the "/etc/group" file, the "/etc/passwd" file, and finally the "/etc/shadow" file (not shown for security reasons) :
root@knockso [~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
bin:x:2:2:bin:/bin:/bin/sh
...
bacula:x:112:112:Bacula:/var/lib/bacula:/bin/false
sockso:x:575:575:Sockso Player User:/home/sockso:/bin/bash
sockso2:x:576:575:Sockso Download User:/home/sockso2:/bin/bash

root@knockso [~]# passwd sockso
root@knockso [~]# passwd sockso2
root@knockso [~]# cat  /etc/group
root:x:0:
daemon:x:1:
bin:x:2:
...
bacula:x:112:
sockso:x:575:
  1. Now we have our users ready, so make the home directories and set the permissions.  Note that in my case, Im also going to simly copy the "~/.sockso" directory for both users, over from my existing host - since I've already got it installed and simply changing servers.  If you're doing a fresh install, you'll need to get the sockso application and add that as well.  Ideally that should be done between steps 13 and 14 but could be done now as well, if desired (instructions for that are at the other Sockso Music Server page) :
root@knockso [~]# cd /home
root@knockso [~]# mkdir sockso
root@knockso [~]# mkdir sockso2
root@knockso [~]# chown -R sockso:sockso /home/sockso
root@knockso [~]# chown -R sockso2:sockso /home/sockso2
  1. Im running on a machine with only 128Mb of RAM, and I want to have a desktop to work in, so Im changing the default desktop to fluxbox.  To make that stick, requires editing the boot parameters, which is done in the "/boot/grub/menu.lst" file.  So make the changes in that file as follows.  Leave everything at the top part alone, and just change the boot entries at the bottom :
## ## End Default Options ##

title           Debian GNU/Linux, (2.6.17) FluxBox
root            (hd0,1)
kernel          /boot/vmlinuz root=/dev/hda2 ro ramdisk_size=100000 init=/etc/init lang=us apm=power-off nomce quiet vga=791 desktop=fluxbox
initrd          /boot/initrd.img
savedefault
boot

title           Debian GNU/Linux, (2.6.17) Default
root            (hd0,1)
kernel          /boot/vmlinuz root=/dev/hda2 ro ramdisk_size=100000 init=/etc/init lang=us apm=power-off nomce quiet vga=791
initrd          /boot/initrd.img
savedefault
boot

title           Debian GNU/Linux, kernel 2.6.17
root            (hd0,1)
kernel          /boot/vmlinuz-2.6.17 root=/dev/hda2 ro ramdisk_size=100000 init=/etc/init lang=us apm=power-off nomce quiet vga=791
initrd          /boot/initrd.img-2.6.17
savedefault
boot
  1. Next is to setup the static IP address in the interfaces file.  So edit the "/etc/network/interfaces" file, and configure as desired.  Here is what mine looks like :
root@knockso [~]# cat /etc/network/interfaces
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)

# The loopback interface
# automatically added when upgrading
auto lo eth1
iface lo inet loopback

iface eth1 inet static
        address 207.86.37.64
        netmask 255.255.255.0
        network 207.86.37.0
        broadcast 207.86.37.255
        gateway 207.86.37.253
  1. Edit the "/etc/resolv.conf" file now to make the domain name, domain search, and name server settings persistent across reboots :
root@knockso [~]# cat /etc/resolv.conf
domain pluzzi.com
nameserver 207.86.37.1
nameserver 207.86.37.253
search pluzzi.com
  1. In the command line, set the new hostname with the "hostname" command, and then edit the "/etc/hosts" file so that it matches.  Just swap "Knoppix" with "knockso" (which is a combination of knoppix and sockso).  Then reboot and verify that the IP comes up properly, its in fluxbox window manager (desktop), has the right hostname, and that you can switch to the sockso and sockso2 users without issue.
  1. At this point, I wanted to setup my startup services so that I can work remotely.  In the end, this will be a headless server, with occasional console access - but mostly remote.  So we need ssh, klogd, sysklogd, and possibly others.  So set those up next.  First get your default run level either from inittab or by querying the running system with the "who -r" command :
root@knockso [~]# who -r
root@knockso [~]# cd /etc/rc5.d
root@knockso [~]# ln -s ../init.d/klogd ./S30klogd
root@knockso [~]# ln -s ../init.d/sysklogd ./S30sysklogd
root@knockso [~]# ln -s ../init.d/cron ./S40cron
root@knockso [~]# ln -s ../init.d/ssh ./S50ssh
root@knockso [~]# cd ../rc0.d
root@knockso [~]# ln -s ../init.d/klogd ./K30klogd
root@knockso [~]# ln -s ../init.d/sysklogd ./K30sysklogd
root@knockso [~]# ln -s ../init.d/cron ./K40cron
root@knockso [~]# ln -s ../init.d/ssh ./K50ssh
  1. For my own personal scripts, originally written in Solaris and ported over to HP-UX, Linux, AIX, and others - its alot easier for me to create a ksh link in /bin than it is to edit all my scripts.  So make that link now :
root@knockso [~]# cd /bin
root@knockso [~]# ln -s bash /bin/ksh
root@knockso [~]# ln -s bash /usr/bin/ksh
  1. I also wanted to see how much memory was being used by the java procs, so I like to have conky running for that, but it wasnt included in the distribution.  So get that now by updating the "/etc/apt/souces.list" file, and updating apt :
root@knockso [~]# cd /etc/apt
root@knockso [~]# cp -p sources.list sources.list.orig
root@knockso [~]# vi /etc/apt/sources.list
root@knockso [~]# apt-get update
root@knockso [~]# apt-get install conky
root@knockso [~]# which conky
root@knockso [~]# conky -a top_right &
  1. So we have the setup in place, host ready - now lets get the application stuff going.  I need to get my music NAS share mounted, so I mount that up with these commands :
root@knockso [~]# mount
root@knockso [~]# mkdir /mnt/dvd
root@knockso [~]# mount -t cifs //nas/share /mnt/dvd -o ro
root@knockso [~]# ln -s /mnt/dvd/music ./music
  1. Next, I know that since Im running verison 5.0.1 of Knoppix, my java is a little older.  So I wanted to update from Java5 to Java6 instead :
root@knockso [~]# which java
root@knockso [~]# java -version
root@knockso [~]# apt-cache search java
root@knockso [~]# apt-cache search sun-java
root@knockso [~]# apt-get sun-java6-bin
root@knockso [~]# apt-get install sun-java6-bin
root@knockso [~]# java -version
root@knockso [~]# ls -l /usr/bin/java
root@knockso [~]# ls -l /etc/alternatives/java*
root@knockso [~]# apt-get remove sun-j2se-1.4-jre-binary
root@knockso [~]# apt-get remove sun-j2se1.4-jre-binary
root@knockso [~]# ls -l /etc/alternatives/java*
root@knockso [~]# java -version
  1. Now that everything is in place, I'd like to get the startup script configured so we can test that out, and test the application.   Here is the simple but lengthy script I use to start up the sockso services.  I run two of them - one public on 8082 with no validation and no downloads - and one on 8083 with user authentication required, no public registration, and downloads enabled.  I also like to have them run in the foreground where I can see them if I choose to turn on the monitor, hnce I still run the desktop instead of text mode.   That could change if I find I truly am short on RAM, but so far its ok :
root@knockso [~]# cat /etc/init.d/sockso
#!/bin/ksh 
## BEGIN INIT INFO
# Required-Start: network
# Default-Start:  3 5
# Description:    Sockso Music Services
### END INIT INFO
#
#####
#####  Written on 02-02-2009
#####
#####  Call and startup/stop the sockso music services
#####

case "$1" in 
'start')
   #####
   #####  Mount the filesystem
   #####
   TESTMOUNT=`mount | grep "/mnt/dvd"`
   if [ "$?" = "0" ]
     then
       echo "CIFS share already mounted at /mnt/dvd"
      else
       echo "Mounting CIFS share //nas/share at /mnt/dvd"
       mount -t cifs //nas1/share /mnt/dvd -o ro,username=read,password=****
     fi
   echo "Setting display to 127.0.0.1:0.0"
   DISPLAY="127.0.0.1:0.0" ; export DISPLAY
   echo "Launching sockso music player service"
   xterm -title sockso_player -e su - sockso -c ~sockso/start_sockso.sh &
   echo "Launching sockso2 music download service"
   xterm -title sockso2_downloads -e su - sockso2 -c ~sockso/start_sockso.sh &
   ;;

'stop')
   #####
   #####  Stop the apache port 80 instance
   #####
   echo "Collecting sockso pids"
   SOCKSO1_PIDS=`ps -ef | grep java | grep "sockso" | grep -v sockso2 | awk '{print $2}' | sort -nr`
   echo "Killing sockso pids"
   kill -9 $SOCKSO1_PIDS
   #
   echo "Collecting sockso2 pids"
   SOCKSO2_PIDS=`ps -ef | grep java | grep "sockso2" | awk '{print $2}' | sort -nr`
   echo "Killing sockso2 pids"
   kill -9 $SOCKSO2_PIDS
   #
   echo "Unmounting the share"
   umount /mnt/dvd
   ;;

*)
  echo "Usage: $0 { start | stop }"
  exit 1
  ;;

esac

root@knockso [~]#
  1. Ok - testing the application is easy while I still have my monitor connected, I just make sure my share is unmounted, run the startup script, check if Im mounted and have processes running, and then stop it and check again.  
root@knockso [~]# cd /etc/init.d
root@knockso [~]# mount
root@knockso [~]# ./sockso start
root@knockso [~]# mount
root@knockso [~]# ./sockso stop
root@knockso [~]# mount
root@knockso [~]# reboot

Thats it for the setup portion.   Now you can launch a browser from anywhere - the linux server, or a windows client (preferably with an audio card and speakers).

  1. Launch a browser, and point it to the IP (or dns name) and port as shown in the bottom of the console, which you can see in the last screenshot above.
  1. Enjoy the ease of use - click a song and try out the flash player - very cool !

Thats it !

Tuning / Customization

Note that I totally left out the part about getting sockso working because I had already done that before.  If you dont have it already instealled , in between steps 13 and 14, follow the info on my other Sockso Music Server page, which has all the details of setting up the Sockso service.  This project was just setting up a dedicated server, and copying the files over to this box.

You can find much more about that in their online manual.

Tag page
You must login to post a comment.