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 2.2.5.6.0.28 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.
Items:
1. File names and background
2. Long install with explanations
3. Creating the autostart
4. Some problems solved
5. Short installation description
1. FILE NAMES AND BACKGROUND
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.
2. LONG INSTALL DESCRIPTION
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*
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:
(terminal)
Code: Select all
sudo apt-get install sysv-rc-conf
sudo ln -s /usr/sbin/sysv-rc-conf /usr/sbin/chkconfig
check the process with:
(terminal)
Code: Select all
ps -ef|grep twonky
(firefox)
http://localhost:9000
3. CREATING THE AUTOSTART
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:
(terminal)
Code: Select all
cd /usr/local/twonkymedia
sudo chmod +x twonkym* cgi-bin/* plugins/*
route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0
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:
(terminal)
Code: Select all
sudo chmod 755 /etc/init.d/twonkyserver
(terminal)
Code: Select all
sudo /etc/init.d/twonkyserver stop
sudo /etc/init.d/twonkyserver start
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))
http://localhost:9000
After installing twonky, there are not yet any entries in rc0..rc6.d where start stop levels need to be created.
(terminal)
Code: Select all
sudo update-rc.d twonkyserver defaults
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 .
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:
(terminal)
Code: Select all
cd /etc
sudo find . -name '*twonky*'
4. SOME PROBLEMS SOLVED
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:
(terminal)
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
exit
cd /usr/local/twonkymedia
Code: Select all
sudo killall twonkymedia
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
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..
5. SHORT INSTALL DESCRIPTION (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 .
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.