Ultimate Server (5.1) install guide on Ubuntu (9.10)

Linux and UNIX specific discussions
Posts: 10
Joined: Wed Mar 03, 2010 6:20 pm
AV Hardware: PC2500 VIA-C7 Ubuntu 10.04, Twonky Server 6.0.28, WD TV Live, AMDX4 Phoenix MSI 890 (Windows Performance index 7.1, Win 7-64 Ultimate)

Ultimate Server (5.1) install guide on Ubuntu (9.10)

Postby fboecom » Fri Mar 05, 2010 7:04 pm

I thought there is a need for a more comprehensive install guide for twonky on unbuntu - here it is.
A replay or gathering of earlier posts into the newest versions - tested&verified against Twonkyserver 2.2.5-5.1.3 and Ubuntu 9.10, but I am convinced it will work on other ubuntu versions - since it is so simple.
Some small changes to earlier posts. Some explanations. Some comments on Twonky's own documentation (LinuxHowTo). Some solutions after some errors.
**24feb11 - checked and quickly updated for on Ubuntu 10.04**.

Main goal environment for my installation was a headless (no monitor) Ubuntu server. So a start of twonky at boot time was required.

1. File names and background
2. Long install with explanations
3. Creating the autostart
4. Some problems solved
5. Short installation description

One of the major concerns for me was that the twonkymedia install script generates errors in Ubuntu 9.10, both during install as during the creating of boot links (update-rc), which are - so it seems - annoying but do not prevent normal operation. So simply disregard them - unless they really mean somthing of course.

Another concern is the terminology in packages that I find confusing. 'Media' and 'Server' are happily mixed up here. That situation no doubt has resulted from times when twonkymedia was the company to own the server.

Some """twonky""" items you may come accross:
- twonkymedia-i386-glibc-2.2.5-5.1.3.sh: the linux install setup package. Will stay and reside in your installation directory after running it.
after installing that .sh:
- twonkymedia and twonkymediaserver: in your installation directory, the actual server executables, that are daemonized by the twonkymedia.sh shell script
- twonkymedia.sh: in your install directory, the shell script (with non fatal errors in Ubuntu) that kicks off the server processes. Can run as a normal user, especially by the user who owns this directory, but not when auto startup is required.
- twonkyserver, in /etc/init.d, created by the install script run from a sudo command, has exactly the same contents as twonkymedia.sh in the install directory. Should be root and have exe privileges.
- twonkymedia, a process after kicking off the "<install path>twonkymedia.sh start" or "/etc/init.d/twonkyserver start" (use ps-ef|grep twonky).
- twonkymediaserver, same.
if both last two processes are running, without <defunct>, you have reached your goal!
- /var/run/mediaserver.pid: if catted out: will show the PID of the twonkymedia process that is active.

Another comment: after installing the twonkedia server, the install directory will contain a file LinuxHowTo.txt. Although the contents is not specifically wrong, it holds too many unnecessary instructions and the statement that you need to be a Linux expert to create autostart is ridiculous. It is dead simple.


download twonky media server Linux setup package from http://www.twonkymedia.com/installs.html
on Mar 5, 2010 that is:
http://www.twonkymedia.com/downloads/tw ... 5-5.1.3.sh

- Presume you will have admin rights for sudo.
--Although twonkymedia server will perfectly run when kicked off by a regular user, installing it as a bootup system service will (at this time) mean root to own the process anyway. In order to avoid any problems, I propose to sudo everything here. However, sudo/root owning the process means that twonky will access ANY content on your system!
- Presume you will want to install in /usr/local/twonkymedia
--(creating the install dir /usr/local/twonkymedia is a choice and it may be in other locations. But do check (nano / gedit) if the <install-dir>twonkymedia.sh has the right install directory specified (after installation).).
-Presume you (use firefox and) downloaded to your Downloads directory.
--Alternative is to use wget. Not described here.
---Note: With the * examples below I presume that you don't have anything else starting with 'tw' in the directories. If you do, expand the # of characters before the *

(open terminal)

Code: Select all

sudo mkdir /usr/local/twonkymedia
sudo mv ~/Downloads/tw* /usr/local/twonkymedia
cd /usr/local/twonkymedia
sudo chmod 755 tw*
sudo ./tw*

Instead of mv from Downloads you can of course also use copy (cp). Of course change the download path if the .sh file is somewhere else.
I have verified that you can start the <install>.sh with ./tw*. Of course you can also specify the exact name of the downloaded version.
Further we do need sudo in order to have access rights to write the server script to /etc/init.d. If you don't, then <install path>twonkymedia.sh will not be copied to /etc/init.d/twonkyserver.

Executing the script will generate a chkconfig error.
You can simply ignore that.
**6.0 version - problem solved**

If you must, you can prevent that by:


Code: Select all

sudo apt-get install sysv-rc-conf
sudo ln -s /usr/sbin/sysv-rc-conf /usr/sbin/chkconfig

but..in normal cases, twonky displays it started the Daemons and is now running.

check the process with:

Code: Select all

ps -ef|grep twonky

3 entries should appear: twonkymedia + twonkymediaserver + the grep of twonky itself.


Now making twonky permanent at unattended startup.
Adding to the ubuntu user startup (Upstart) works for an individual user that logs in, but not for a server, where normally nobody will log in.

Twonky's own instruct, in LinuxHowTo in the install directory says:


Code: Select all

cd /usr/local/twonkymedia
sudo chmod +x twonkym* cgi-bin/* plugins/*
route add -net netmask dev eth0

Both of these, chmod or route, proved NOT necessary in my installation.

As indicated earlier, the install shell script that you have used, has (if you run it with sudo) created an executable script (copy of twonkymedia.sh) in the /etc/init.d directory, named twonkyserver.
It should have the correct execute rights, check it and if necessary:


Code: Select all

sudo chmod 755 /etc/init.d/twonkyserver

You can test the init.d script by:

Code: Select all

sudo /etc/init.d/twonkyserver stop
sudo /etc/init.d/twonkyserver start

NEVER use ./twonkymedia or ./twonkyserver stop|start but always the full path, as the LinuxHowTo states correctly.
I have experienced a <defunct> twonkymedia in the process list after disregarding this. (If you have <defunct> remove the /var entries (see below) and restart the computer).

(browser (firefox))

After installing twonky, there are not yet any entries in rc0..rc6.d where start stop levels need to be created.


Code: Select all

sudo update-rc.d twonkyserver defaults

or, you could specify specific start/stop conditions.
I prefer to put twonky at the end of the startup sequence, so at '99':

Code: Select all

cd /etc/init.d
sudo update-rc.d twonkyserver start 99 2 3 4 5 . stop 99 0 1 6 .

The update-rc command results in LSB errors since the twonkymedia script is not perfect for Ubuntu.
However the results will be OK in terms of daily operation.
Someone may want to update this script. It shouldnt be too difficult.

if you need to check the startup/kill entries:


Code: Select all

cd /etc
sudo find . -name '*twonky*'

reboot. test.


Some problems that occurred and were solved:
1. <defunct>
The reason why <defunct> occurs, is that something or someone has started the twonkymedia script the wrong way or with the wrong credentials. twonky tries to start, it fails, is not in the process list, but a second (manual) start leads to the <defunct>.
Apparantly, if an rcX.d start fails, you don't see it in the process list, you manually start it, but: <defunct>.

2. deinstall
If for some reason you need to deinstall twonky, for instance with the <defunct>, here are the steps:


Code: Select all

sudo su
cd /etc
rm -i rc*.d/*twonky*
rm /etc/init.d/twonky*
cd /var
rm -rf twonkymedia
cd /usr/local/twonkymedia
mv tw*.sh ..
rm -r *
cd ..
rm twonkymedia.sh
mv tw*.sh twonkymedia
cd /usr/local/twonkymedia

further, you can kill twonky at any time with:

Code: Select all

sudo killall twonkymedia

3. samba localhost conflict
Note: I have found localhost conflicts between samba and twonky. I removed samba en reinstalled it.

4. startup rights
As indicated earlier, twonkyserver (or <install path>twonkymedia.sh) will start with normal rights, However the autostart requires root to own the process in /etc/init.d and in the rc*.d directories too. So use sudo for the install procedure, as described above and below.

Note: For the 5.x version I had been trying to start twonkymedia with normal user rights using the 'sudo -u <user>' in the init.d startup script. However there was a bug in twonky that did not correctly startup the second (server) process.
**6.0.28 version: fixed** (In 5.x, twonky can only autorun as root and thus has access to ALL your content since through the http interface ANY user can set the content to "/".).
You can start twonky from the unix commandline, for example:

Code: Select all

sudo -u wintv /usr/local/twonkymedia/twonkymedia.sh start

with ps-ef this will show the user wintv as the owner of the twonkymedia and twonkyserver processes. Well done twonky :) .
In order to make this work in unattended startup, you need to update the /etc/init.d/twonkyserver script - I have not done that yet, so no advices here. You dont need sudo in the command because you run rc.d startups as root.
The good thing is twonkyserver now also has a password in the configuration HTML page .. so that also takes away the problem of the normal user serving any file through twonky..

(for root as user)
so, recapping, all what you really need for installing a headless twonky server, now including the download of the install package (of today):

Code: Select all

sudo mkdir /usr/local/twonkymedia
cd /usr/local/twonkymedia
wget http://www.twonkymedia.com/downloads/twonkymedia-i386-glibc-2.2.5-5.1.3.sh
sudo ./tw*.sh
sudo update-rc.d twonkymedia start 99 2 3 4 5 . stop 99 0 1 6 .

And that... folks.. is really all there is!!! Nothing else is really needed!!
but remember: don't fool around with the wrong rights, and don't start the server/media in the wrong way manually (with ./twxxx).

Some practical additional advice: for twonky to find and serve the right content, you may need to add root to the group that owns the media files. Even root could not have access.

Have fun and register your server copy.
Last edited by fboecom on Wed Feb 23, 2011 12:08 pm, edited 1 time in total.

Posts: 4
Joined: Sun Jan 02, 2011 5:18 am
AV Hardware: PS3, XBMC, PSP, iphone, Ubuntu Server, Windows

Re: Ultimate Server (5.1) install guide on Ubuntu (9.10)

Postby douglas_fj45 » Sun Jan 02, 2011 6:56 am

Thanks for the guide it really helped me install twonky server.
I pretty much followed it for Ubuntu 10.10 and twonky 6.0.28 works fine.

Thanks again :)

Posts: 1
Joined: Tue Feb 22, 2011 3:21 am
AV Hardware: Ubuntu 10.10 64 Bit server, Xbox 360, PS3

Re: Ultimate Server (5.1) install guide on Ubuntu (9.10)

Postby odinsride » Tue Feb 22, 2011 3:22 am

Thanks for this guide - it was of great help for me in setting up Twonky server on my Ubuntu 10.10 64-bit box

Posts: 10
Joined: Wed Mar 03, 2010 6:20 pm
AV Hardware: PC2500 VIA-C7 Ubuntu 10.04, Twonky Server 6.0.28, WD TV Live, AMDX4 Phoenix MSI 890 (Windows Performance index 7.1, Win 7-64 Ultimate)

Re: Ultimate Server (5.1) install guide on Ubuntu (9.10)

Postby fboecom » Wed Feb 23, 2011 11:07 am

I actually tested it again against the 6.0.28 server on Ubuntu 10.04 and indeed - the basics in my guide are still valid.
One good thing is that some of the error messages have disappeared, but really the best is that twonky now can run as normal user from the startup script in rc.d. Original text updated. The fact that in 5.x ANY user could configure auto started twonky to serve ANY content (because being root) was a totally black hole in my view - that is now fixed!
Greetings, Frederik

Posts: 2
Joined: Sat Mar 05, 2011 5:34 pm
AV Hardware: Denon AVR3808
Ubuntu server 10.04 64 bits

Re: Ultimate Server (5.1) install guide on Ubuntu (9.10)

Postby rbisschops » Sat Mar 05, 2011 5:42 pm


I'm relatively new to Ubuntu. So i installed twonky 6.0.28 on my Ubuntu 10.04 server. Installation went ok,and even the file twonkyserver in etc/init.d is created. This all thanks to this guide..... :D

However starting the server will always end with the error: Starting /usr/local/twonkymedia/twonkymedia ... /usr/local/twonkymedia/twonkymedia.sh: 154: /usr/local/twonkymedia/twonkymedia: not found

The folder is there, if i do: ls /usr/local/twonkymedia, it shows all files.

Can anyone tell what i'm overlooking or doing wrong?



Posts: 10
Joined: Wed Mar 03, 2010 6:20 pm
AV Hardware: PC2500 VIA-C7 Ubuntu 10.04, Twonky Server 6.0.28, WD TV Live, AMDX4 Phoenix MSI 890 (Windows Performance index 7.1, Win 7-64 Ultimate)

Re: Ultimate Server (5.1) install guide on Ubuntu (9.10)

Postby fboecom » Sun Mar 06, 2011 10:12 pm

R, I dont know how you start your server ... the /etc/init.d/twonkyserver is a script that kicks off the <install dir>/twonkymedia.sh which on its turn starts the processes twonkymedia and twonkyserver.
If you want to start (or stop; then replace stop for start) twonkymedia from the command line, you type in either:

Code: Select all

sudo /etc/init.d/twonkyserver start


Code: Select all

sudo <install-dir>/twonkymedia.sh start

you can omit the sudo in the last example. If root started twonky and you want to stop it, you need sudo. If it hasnt started yet, you can start it with/as a normal user and so without sudo, it will not have all rights to the files to serve though.
    always make sure that you type the full path before the twonkyserver or twonkymedia script.
    I dont know if the <install-dir> path is correct. My full path reads /usr/local/twonkymedia/twonkymedia.sh
    Also check if it is an executable (chmod 755 <install-dir>/twonkymedia.sh)
    And if you have the right rights on the executable script ((sudo) chown <yourusername> twonkymedia.sh)
Greetings, Frederik

Posts: 2
Joined: Sat Mar 05, 2011 5:34 pm
AV Hardware: Denon AVR3808
Ubuntu server 10.04 64 bits

Re: Ultimate Server (5.1) install guide on Ubuntu (9.10)

Postby rbisschops » Sat Mar 12, 2011 5:51 pm

I found what was wrong with my install. I installed Twonky on a 64bit Ubuntu version. Ubuntu is not reporting this, but simply replies it can't find the file. After installing the 32 bits library everything works fine!

Return to “Linux”

Who is online

Users browsing this forum: No registered users and 2 guests