PDA

Bekijk de volledige versie : HOW-TO: Running TwonkyVision on a WL500g DeLuxe



SuperB
12-08-2006, 21:23
Background

I have a lot of MP3's and I own an Asus WL500gx and a Terratec Noxon 2 (great machine by the way). So, what would make more sense than to connect the two of them and serve the songs from the WL500gx to the Noxon? To do this, I also need some software and this is where TwonkyVision (or TwonkyMusic to be precise) comes into play.

When I bought my WL500gx, I intended to use it for three things:
1) Use it as a wireless router (sic!)
2) Use it as a webserver
3) Use it as a media streaming server

Point 1) is trivial. My work on point 2) can be read here (http://wl500g.info/showthread.php?t=5092). Point 3) will be explained in this how-to.

To get things working, I had to do the following:
* Buy TwonkyMusic
* Prepare the hard-drive I will use for storing the MP3s and my websites
* Setting up TwonkyMusic
* Saving changes to the flash memory

Buying TwonkyMusic

For serving music, TwonkyVision has a great solution: TwonkyMusic. When you buy the Noxon 2, a Windows version is included. Of course, this software does not run on the WL500gx, so I had to buy the Asus version through the TwonkyVision website ( http://www.twonkyvision.com).

On the website, click on the shopping cart to enter the online store. If you own a Noxon, you may enter the voucher / upgrade key that was printed on the wrapper of the software CD.
I selected the Basic version of TwonkyMusic and the Voucher / upgrade key radio buttons. After I paid, I was able to download TwonkyMusic for the WL-HDD, which I did.

Preparing the hard-drive

I bought a Western Digital MyBook Essential 250GB, because this HDD has a very nice feature: it does a spin-down after being idle for some time. Ideal for my situation, since the load on my web- and music server is low.

The drive comes formatted as one large fat32 partition, and it's fine if you want to leave it like that. I myself decided to create two partitions on the drive, one large (about 230GB) fat32 partition for MP3s and websites and a small ext3 partition for applications.
The rest of this how-to is based on my choice for two partitions, so if you leave the drive in its original state you will have to do things slightly different.

I used Partition Magic to do the partitioning, but you can also look here ( http://wl500g.info/showthread.php?t=1984) on how to do this on the WL500gx. I formatted the fat32 partition with a tool I found here ( http://www.ridgecrop.demon.co.uk/index.htm?fat32format.htm). The ext3 partition was formatted on the WL500gx, as explained here ( http://wl500g.info/showthread.php?t=1984).
The advantage of the fat32 partition is that I can connect the drive to a Windows PC and copy the files to/from the drive.
Small disadvantages are that I cannot create symbolic links on fat32 and that it is slightly less robust than ext3 (which is not really an issue in this mostly read-only situation).

Mounting the partitions on the WL500gx

Before I had the MyBook Essential, I had a small website on a USB stick (read here ( http://wl500g.info/showthread.php?t=5092)). To mount this stick, I included the mount command in the post-boot file. After changing to the MyBook this no longer worked robustly, I presume because it takes some time to spin up the MyBook drive during boot time and the mount command fails because the drive is not yet available. So, I renamed the post-boot file to post-mount and the problem was solved. Alternatively, you can also add code to post-boot so it will wait until the drive is mounted.

I have chosen to mount the fat32 partition to /mnt and the ext3 partition to /opt, but you are free to make other choices. Here are the mount commands from my post-mount file that I use for this purpose:


mount -t vfat /dev/scsi/host0/bus0/target0/lun0/part1 /mnt
mount -t ext3 /dev/scsi/host0/bus0/target0/lun0/part5 /opt

Add these lines to the file /usr/local/sbin/post-mount. Save the post-mount file in flash memory:


flashfs save
flashfs commit

Reboot the Asus:


reboot

After the reboot, you will have 4 mount entries on the harddisk, as shown here:


[admin@asus /]$ mount
/dev/root on / type squashfs (ro)
none on /dev type devfs (rw)
proc on /proc type proc (rw)
ramfs on /tmp type ramfs (rw)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/scsi/host0/bus0/target0/lun0/part1 on /tmp/harddisk type vfat (rw,sync)
/dev/scsi/host0/bus0/target0/lun0/part5 on /tmp/harddisk/part1 type ext3 (rw,noatime)
/dev/discs/disc0/part1 on /mnt type vfat (rw,sync)
/dev/discs/disc0/part5 on /opt type ext3 (rw,noatime)

Finally, I created some directories to store my files:


mkdir /mnt/mp3
mkdir /mnt/www

Setting up TwonkyMusic

For installing TwonkyMusic I could not use the standard procedure as indicated in the installation manual, since this relates to the WL-HDD. The installation instructions in this section do not describe the official way to install the software (they don't exist), but I found them to be robust and simple.

Unzip the zip-file with software for the Asus WL-HDD, which you downloaded from the TwonkyVision website, into a directory on the harddisk of your Windows system.

Create a directory /opt/twonkyvision on the WL500gx and copy the following files to it:

lame, twonkymusic

Create a configuration file named /opt/twonkyvision/twonkyvision-mediaserver.ini with the following content:


contentbase=/mnt
contentdir=/mp3
friendlyname=TwonkyMusic Asus
dbdir=/mnt/twonkyvision/twonkymedia.db
httpport=9000
enableweb=2
scantime=0
maxmem=32000

Now create a shell script /opt/twonkyvision/init.sh with the following content:


#!/bin/sh
cd /opt/twonkyvision
/opt/twonkyvision/twonkymusic &

Make some of the files executable:


chmod +x /opt/twonkyvision/twonkymusic
chmod +x /opt/twonkyvision/lame
chmod +x /opt/twonkyvision/init.sh

Now we are ready to test the installation. Start TwonkyMusic by entering:


/opt/twonkyvision/init.sh

TwonkyMusic will start building a database with the music files in the /mnt/mp3 directory.

Wrapping up

The last step is to add TwonkyMusic to our startup procedure, so it will start running after a reboot.
To achieve this, I added the twonkymusic startup script (init.sh) to the post-mount file. My post-mount now looks like this:


#!/bin/sh
mount -t vfat /dev/scsi/host0/bus0/target0/lun0/part1 /mnt
mount -t ext3 /dev/scsi/host0/bus0/target0/lun0/part5 /opt
/usr/sbin/smbd -D
/usr/sbin/nmbd -D
busybox_httpd -p 8080 -h /mnt/www
dropbear
/opt/twonkyvision/init.sh

Save the post-mount file in flash memory:


flashfs save
flashfs commit

Reboot the Asus:


reboot

Log in again and check if TwonkyMusic is running:


ps

On my system, the output looks like:



.....
112 admin 240 S stupid-ftpd
114 admin 712 S /usr/sbin/nmbd -D
116 admin 564 S /usr/sbin/smbd -D
127 admin 232 S busybox_httpd -p 8080 -h /mnt/www
129 admin 296 S dropbear
131 admin 2588 S /opt/twonkyvision/twonkymusic
132 admin 2588 S /opt/twonkyvision/twonkymusic
133 admin 2588 S /opt/twonkyvision/twonkymusic
134 admin 2588 S /opt/twonkyvision/twonkymusic
135 admin 2588 S /opt/twonkyvision/twonkymusic
136 admin 2588 S /opt/twonkyvision/twonkymusic
137 admin 2588 S /opt/twonkyvision/twonkymusic
138 admin 2588 S /opt/twonkyvision/twonkymusic
139 admin 2588 S /opt/twonkyvision/twonkymusic
140 admin 2588 S /opt/twonkyvision/twonkymusic
141 admin 2588 S /opt/twonkyvision/twonkymusic
142 admin 2588 S /opt/twonkyvision/twonkymusic
143 admin 2588 S /opt/twonkyvision/twonkymusic
144 admin 2588 S /opt/twonkyvision/twonkymusic
145 admin 2588 S /opt/twonkyvision/twonkymusic
2562 admin 700 R dropbear
2563 admin 560 S -sh
2569 admin 388 R ps

If it looks like this, try playing music on the Noxon. If it works, congratulations! :)

Now, you can also configure TwonkyMusic using the webpage. Open the the pages by entering the IP address of your router followed by :9000 in your browser. For example: 192.168.1.1:9000

SuperB
18-12-2006, 05:55
Last weekend I upgraded to the latest version of TwonkyMusic. Here are my experiences.

Again, I downloaded and unzipped the software for the WL-HDD. There are two new subdirectories; plugins and resources.

I renamed the old program directory (/opt/twonkyvision) to back it up. I recreated the directory and copied the following files and directories to it:


plugins
resources
twonkymedia.sh
twonkymedia-default.ini
twonkymusic
twonkymusicserver

I changed twonkymedia-default.ini, so it had the following content:


contentbase=/mnt
contentdir=/mp3
friendlyname=TwonkyMusic Asus
dbdir=/opt/twonkyvision/twonkymedia.db
httpport=9000
enableweb=2
scantime=0
maxmem=32000
platform=Asus WL500gx

Note that /mnt is my fat32 partition for mp3 data and /opt is my ext3 partition for programs.
Beware: do not configure the database directory on a fat32 partition. TwonkyMusic will not start up.

Next, I created a new file init.sh in the twonkyvision directory. Look in the how-to above under 'Setting up TwonkyMusic' for the rest of the actions. Start where I create the init.sh file.

By the way; did anybody ever use the information in this thread to install TwonkyMusic? Since there are no replies, I'm assuming that it is a very clear story, or nobody is using it ;). Let me know.

pinkpanther
12-02-2007, 18:56
Great tutorial!!!

Learned a lot about Linux too!

Because i assumed this was a total tutorial by itself i ran into a few problems.

First a tried to create the post-mount file. I got the error that the directory
/sbin didn't exist.
So I did mkdir -p /usr/local/sbin

After reboot the post-mount file didn't work, so I did chmod +x /usr/local/sbin/post-mount
And it all works perfectly.

Because next to a music-server, i wanted the router to be able to download torrents, I combined this tutorial with this one: http://wl500g.info/showthread.php?t=5909&highlight=post-mount

A great tutorial too!!!

It shows you can do the save, commit and reboot instruction in one command: flashfs save && flashfs commit && flashfs enable && reboot
I split my Mybook Essential in two equal parts. One in FAT32 and one in EXT3.
EXT3 for all the torrent files which exceed more than the 2 GB FAT32 can cope with. It also allows to copy files from EXT3 to FAT32 partition, so I can disconnect the Harddisk and connect it to my Windows PC.

Thanks again for this great tutorial!