TwonkyVision UPnP MediaServer

From NAS-Central Buffalo - The Linkstation Wiki
Revision as of 02:23, 13 September 2006 by Ramuk (Talk | contribs)

Jump to: navigation, search

twonky-banner03.gif

Contents

Twonkyvision

The TwonkyVision MediaServer enables you to share all your Music, Pictures and Videos throughout your home. It is available for many different platforms and interworks with a large variety of client devices including XBox 360™ and Sony PSP™. TwonkyMedia needs fewer resources and is faster than other UPnP Media Servers, but still provides more features which help the user to enjoy large media collections.

There are different ways to install Twonky onto the Linkstation

  1. The installer that comes with V3.1
  2. Frenchy's script from Yahoo Groups


Installer

You need telnet access enabled, so if you disabled it when you installed freelink, you need to

ln -s /etc/init.d/utelnetd /etc/rc2.d/S05utelnetd

Start NASSetup.exe and type your Linkstations IP then hit Send server- > NAS

Start the mediaserver

cd /etc/init.d
./twonkyvision start

Start and stop it at shutdown

Openlink

ln -s /etc/init.d/twonkyvision /etc/rc.d/rc2.d/S99twonkyvision 
ln -s /etc/init.d/twonkyvision /etc/rc.d/rc6.d/K92twonkyvision
ln -s /etc/init.d/twonkyvision /etc/rc.d/rc0.d/K92twonkyvision

Freelink

ln -s /etc/init.d/twonkyvision /etc/rc2.d/S99twonkyvision
ln -s /etc/init.d/twonkyvision /etc/rc6.d/K92twonkyvision
ln -s /etc/init.d/twonkyvision /etc/rc0.d/K92twonkyvision

Configure it on port 9000 on your Linkstation

http://<LinkstationIP>:9000


Frenchy script

Twonkyvision changed the name of the binaries from mediaserver to twonkymedia, this script looks for mediaserver, so , either alter the script or change the binary name.

LS1, LS HG owners should use the ppc-script
LS2 owners should use the mips-script
(there are different paths... /mnt/ vs. /mnt/hda/)


Create folder where Twonkyvision will run from according to script (you can alter this, but adjust the script too)

LS1,HG (ppc)

mkdir /mnt/share/twonkyvision

LS2 (mips)

mkdir /mnt/hda/share/twonkyvision

Save the corresponding script below as twonky and put it in the just created folder. LS1,HG (ppc)

cp /mnt/share/twonkyvision/twonky /etc/init.d/twonky
chmod 755 /etc/init.d/twonky

LS2 (mips)

cp /mnt/hda/share/twonkyvision/twonky /etc/init.d/twonky
chmod 755 /etc/init.d/twonky

Test it to see if it works and it's in the correct place...

cd /etc/init.d
./twonky start

It should tell you that Twonkyvision has started and what version is running.
XP users should see a UPNP icon flash up saying a new device has been detected.
Issue top and see that twonky is shown running, if not check the script is where it should be and if you changed it that it is correct.

top
./twonky stop

Obviously stops it and nothing should be running

./twonky restart

Should stop all pids and say wait 20 secs

Once you're sure it's all working OK create these links:
Openlink

ln -s /etc/init.d/twonkyvision /etc/rc.d/rc2.d/S99twonkyvision 
ln -s /etc/init.d/twonkyvision /etc/rc.d/rc6.d/K92twonkyvision
ln -s /etc/init.d/twonkyvision /etc/rc.d/rc0.d/K92twonkyvision

Freelink

ln -s /etc/init.d/twonkyvision /etc/rc2.d/S99twonkyvision
ln -s /etc/init.d/twonkyvision /etc/rc6.d/K92twonkyvision
ln -s /etc/init.d/twonkyvision /etc/rc0.d/K92twonkyvision


ppc-script

#!/bin/sh

# description: Starts and stops the Twonkyvision mediaserver daemons
# used to serve uPnP music-pics-video files
# This script should be used for all ppc-based Linkstations
# pidfile: /var/run/mediaserver.pid
PATH=/sbin:/bin:/usr/sbin:/usr/bin 

tag=TwkMediaServer
facility=user.info

# Check that binary file exists
[ -f /mnt/share/twonkyvision/mediaserver ] || exit 0

################## START SECTION ####################

start()
{       ## Cleaning up processes left before start
	/sbin/killall -q -s9 "mediaserver" > /dev/null
             sleep 3
	if [ -f /var/run/mediaserver.pid ] ;
	then
             logger -t ${tag} -p ${facility} -i 'ATTENTION: a var/run/pid was left behind   
at stop time...'
	      echo "START: WARNING there was a /var/run/pid was left over running ..."
             #/sbin/killall -q -s9 "mediaserver" > /dev/null
             #sleep 3
	      rm -f /var/run/mediaserver.pid
       else
       echo "STARTING - NO staled PID found - Cleaning loop bypassed..."
       fi
       echo "DONE WITH THE START CLEANUP ..."
       ## Starting the server
       echo "Starting the Twonky Mediaserver"
	cd /mnt/share/twonkyvision/
	./mediaserver -D
       logger -t ${tag} -p ${facility} -i 'Started the service: /mnt/share/twonkyvision/mediaserver'

}
################## STOP SECTION ####################
# Need to find a better way to stop the server
# some pids are left behind showing some mediaserver processes dont just stop upon SIGTERM-
15 request
# Actually the server needs sometime to stop gracefully
stop()
{
       echo "Stopping the Twonky Mediaserver"
       /bin/kill $(cat /var/run/mediaserver.pid)
       echo "Sent the killall Cmd to mediaserver processes..."

       if [ -f /var/run/mediaserver.pid ] ;
	then
               echo "Removing Pid ..."
		rm -f /var/run/mediaserver.pid
       else
        echo "NO pids needed to be removed ..."
	fi
       
       logger -t ${tag} -p ${facility} -i 'Stopped the MediaServer and removed pid'
       echo "Waiting for 20 seconds for server activities to finish stopping ..."
	sleep 20
}
################## RESTART SECTION ####################
restartlog()
{
       echo "RESTARTING the Twonky Mediaserver!"
       logger -t ${tag} -p ${facility} -i 'RESTARTING the MediaServer .... '
}
################## SCRIPT COMMANDS ####################
case "$1" in
       start)
               start
               ;;
       stop)
               stop
               ;;
       restart)
               restartlog
		stop
               start
               ;;
	*)
	  echo "Usage: cd /etc/init.d THEN ./twonky {start|stop|restart}" >&2
	  exit 1
	  ;;
esac

exit 0

mips-script (LS2)

#!/bin/sh

# description: Starts and stops the Twonkyvision mediaserver daemons
# used to serve uPnP music-pics-video files
# this script should be used on the LS2
# pidfile: /var/run/mediaserver.pid
PATH=/sbin:/bin:/usr/sbin:/usr/bin 

tag=TwkMediaServer
facility=user.info

# Check that binary file exists
[ -f /mnt/hda/share/twonkyvision/mediaserver ] || exit 0

################## START SECTION ####################

start()
{       ## Cleaning up processes left before start
	/sbin/killall -q -s9 "mediaserver" > /dev/null
             sleep 3
	if [ -f /var/run/mediaserver.pid ] ;
	then
             logger -t ${tag} -p ${facility} -i 'ATTENTION: a var/run/pid was left behind   
at stop time...'
	      echo "START: WARNING there was a /var/run/pid was left over running ..."
             #/sbin/killall -q -s9 "mediaserver" > /dev/null
             #sleep 3
	      rm -f /var/run/mediaserver.pid
       else
       echo "STARTING - NO staled PID found - Cleaning loop bypassed..."
       fi
       echo "DONE WITH THE START CLEANUP ..."
       ## Starting the server
       echo "Starting the Twonky Mediaserver"
	cd /mnt/hda/share/twonkyvision/
	./mediaserver -D
       logger -t ${tag} -p ${facility} -i 'Started the service: /mnt/hda/share/twonkyvision/mediaserver'

}
################## STOP SECTION ####################
# Need to find a better way to stop the server
# some pids are left behind showing some mediaserver processes dont just stop upon SIGTERM-
15 request
# Actually the server needs sometime to stop gracefully
stop()
{
       echo "Stopping the Twonky Mediaserver"
       /bin/kill $(cat /var/run/mediaserver.pid)
       echo "Sent the killall Cmd to mediaserver processes..."

       if [ -f /var/run/mediaserver.pid ] ;
	then
               echo "Removing Pid ..."
		rm -f /var/run/mediaserver.pid
       else
        echo "NO pids needed to be removed ..."
	fi
       
       logger -t ${tag} -p ${facility} -i 'Stopped the MediaServer and removed pid'
       echo "Waiting for 20 seconds for server activities to finish stopping ..."
	sleep 20
}
################## RESTART SECTION ####################
restartlog()
{
       echo "RESTARTING the Twonky Mediaserver!"
       logger -t ${tag} -p ${facility} -i 'RESTARTING the MediaServer .... '
}
################## SCRIPT COMMANDS ####################
case "$1" in
       start)
               start
               ;;
       stop)
               stop
               ;;
       restart)
               restartlog
		stop
               start
               ;;
	*)
	  echo "Usage: cd /etc/init.d THEN ./twonky {start|stop|restart}" >&2
	  exit 1
	  ;;
esac

exit 0