Installing TwonkyMedia 5 on TS101
So here we have a Qnap TS101 NAS device. It’s quite a neat little thing, does a number of different sharing tasks from one hard-drive sized case. It shipped with TwonkyMedia 4, and as we’re getting more involved with media sharing in our household and our TV came with 3 TwonkyMedia 5 licences, I wanted to see how open it was to being upgraded. So this is that story.
The first thing you’ll need to do is to upgrade your TS101 to the latest firmware. This should give you access to the NAS via telnet. Some older versions of the firmware do not have Telnet access enabled.
Next you need to telnet to the NAS using your preferred telnet client on port 13131. Log in using the administrator username and whatever password you have assigned to that user.
You should get a standard shell prompt. You can use this to have a look around. The usual unix-type commands are available – ls, df, that sort of thing. (Note that you are dropped in to /root/ on login so you won’t see anything there. cd elsewhere to see stuff.)
The normally mounted areas are /share/HDA_DATA and /mnt/HDA_ROOT/ I have a second drive attached which appears as /share/external/sdb. The TM4 stuff is located in /mnt/HDA_ROOT/twonkymedia/ I guess you could – if you wished – directly overwrite this with your TM5 stuff, but this would give you no way back, I chose to create a new directory to house the TM5 binaries and associated database files.
The next thing is to download the correct TM5 install. The one you need for this is twonkymedia-powerpc-uclibc-0.9.28-5.1.2 and at the time of writing this was available from the TM site on the alternate builds download page.
The easiest way to upload that is to unpack the archive and then copy the resultant directory across to your NAS on one of its many shares. You can then use mv or cp from the shell login to move the directory to wherever you want it to be.
So now you have the software in place, you need to make some changes to the default ini so that you can start it up without issue. By default, the TM5 software puts a lot of its content (the database, etc.) into /var/. This is doubly useless on the NAS, firstly because /var/ is small, and secondly because it is a volitile area. So you need to change some ini lines. Copy the default twonkymedia-server-default.ini from the install directory to another file. This will be your working ini file. To edit the file, there is a built in vi on the shell, but I found that there were issues with my client sending double-returns, so for me it was easier to copy the file back to my host and edit it there. Just make sure that you use an editing tool that repects the unix EOL characters.
Once you have the file for editing, you need to set up the following bits of information -
# cachedir
cachedir=/mnt/HDA_ROOT/tm5/db/cache
# dbdir
dbdir=/var/twonkymedia
# HTTP Server Port
httpport=9001
# bgtransdir
bgtransdir=/var/twonkymedia/twonkymedia-server-transcoding-data
# uploadmusicdir
uploadmusicdir=/mnt/HDA_ROOT/tm5/twonkymedia-server-uploaded-music
# uploadpicturedir
uploadpicturedir=/mnt/HDA_ROOT/tm5/twonkymedia-server-uploaded-pictures
# uploadvideodir
uploadvideodir=/mnt/HDA_ROOT/tm5/twonkymedia-server-uploaded-videos
You should set these values to whatever locally created directories you have set up for Twonky to hold stuff in. (This probably means you’ll need to create a few directories.) I set the HTTP Port also so that it does not conflict with the TM4 server on 9000 should they both happen to be running at the same time.
Note that the paths are representative, you can stick stuff wherever you want. The upload paths are only important if you want to make use of that facility.
If you choose to put anything in /var/something then you’ll need to do a bit more work. My path in /var/twonkymedia is actually a symlink to a real directory. However, the normal startup will trash the symlink, so you have to ensure it is recreated on boot. Normally on a Linux system this means editing a startup file in /etc/ but in this case, even those are overwritten!
The startup scripts for the TS101 are in /etc/rcS.d (which links to /etc/init.d). There’s no runlevel support on the NAS, everything gets started in order. The twonkymedia script is in there and can be easily modified to start TM5 instead of 4. Copy the file from init.d to your chosen permanent directory. Call it whatever you like. Make a backup for easy reference to the TM4 file if needed.
You need to make only a few changes -
WORKDIR1=”/share/external/sdb/t5″
PIDFILE=/var/run/mediaserver.pid
INIFILE=”${WORKDIR}/twonkyvision-server-default.ini”
WORKDIR1 should be wherever you put the binaries. PIDFILE should be as above.
INIFILE is whatever your modified default ini file is called. Note these lines are spread out in the file itself.
I also commented out a few lines that overwrite the ini file when it starts.
Now, the fun bit is to get all that to auto-start. This requires modification of the autostart.sh file which is maintained in the on-board ram. You can mount that up to get access to the file -
mkdir /mnt/flash
mount /dev/mtdblock4 /mnt/flash
vi /mnt/flash/autorun.sh
Add something like this to the autorun file
ln -s /share/external/sdb/t5/var/ /var/twonkymedia
/etc/rcS.d/S90twonkymedia stop
cp /share/external/sdb/twonkymedia5.sh /etc/init.d/twonkymedia.sh
/etc/rcS.d/S90twonkymedia start
This creates your symlink in /var/ stops the TM4 server if it’s runing, overwrites the rc.d for TM4 (until the next reboot) with your tm5 startup scripts, and starts TM5. You’ll need to provide the full paths to all your files. Also, this method assumes that TM4 is enabled in the NAS config, or that you have commented out those checks in your TM5 startup script.
Reboot your NAS and enjoy TM5.


