D-Link DNS-320 NAS, DebianSqueeze and Twonky Media Server 7
I gave myself a bit of a shock today by working out something in Linux that actually worked, all by mself! Obviously to any proper linux person it’s little more than a child’s first steps – but it was quite satisfying!
So …
Having got the NAS loaded with all my media files, I enabled the UPnP MediaServer that came with it – to discover it was total crap. And promptly disabled it again.
But the word on the street, is that the Twonky Media Server is good, so I thought, put that on it.
And indeed people have put it on the DNS-320. This post covers much of what needs to be done, providing a link to a build of Twonky for the ARM processor and instructions on how to configure.
The only problem, is that all the instructions are for the lightweight ffp Linux install – rather than debiansqueeze which I’m using (because of the subversion project posted about previously).
Nevertheless – I followed the instructions, and with a few variations … got it to work … which surprised me!
The main thing I did was to strip off every occurrence of /ffp wherever I saw it in a path eg: /ffp/opt/twonky/ became /opt/twonky/
I did this both with the instructions in the blog post and with the content of the two scripts downloaded by those instructions ‘twonky.sh’ and ‘twonkyserver-default.ini’
Note: Two things to be aware of here: 1) Don’t edit these files with Windows Notepad, it messes up the line feeds at the end of each line such that linux doesn’t like the result! The free editor Notepad++ can probably handle it. 2) The debiansqueeze equivalent of the /ffp/start directory is /etc/inet.d so drop the twonky.sh file in there.
#!/bin/sh # PROVIDE: twonky # REQUIRE: LOGIN . /etc/ffp.subr name="twonky" start_cmd="twonky_start" stop_cmd="twonky_stop" twonky_start() { # Add a route for twonky to be published via UPNP route add -net 224.0.0.0 netmask 240.0.0.0 dev egiga0 >/dev/null 2>/dev/null </dev/null & cd /opt/twonky mkdir -p /opt/twonky/data/ & # Twonky requires one handle per monitored filesystem if inotify is # used. On many devices, this is set to 8192, which might be too low # if music or photos are scanned. Therefor this value is raised to # the doubled amount. If more is required, change the value below. # Thanks Michael for reporting this! /sbin/sysctl fs.inotify.max_user_watches=16384 >/dev/null 2>/dev/null </dev/null & # The line below is without logging (logs are written to /dev/null). # If you want logging, exchange it with the line below the current one. /opt/twonky/twonkystarter -logfile /dev/null -appdata /opt/twonky/data/ >/dev/null 2>/dev/null </dev/null & # /opt/twonky/twonkystarter -logfile /opt/twonky/data/TwonkyMediaServer-log.txt -appdata /opt/twonky/data/ >/dev/null 2>/dev/null </dev/null & } twonky_stop() { # Kill Twonky if [ -n "`pidof twonkyserver`" -o -n "`pidof twonkystarter`" ]; then echo "Stopping twonkyserver" kill -9 `pidof twonkyserver` `pidof twonkystarter` fi if [ -n "`pidof twonkyproxy`" ]; then echo "Stopping twonkyproxy" kill -9 `pidof twonkyproxy` fi if [ -n "`pidof twonkywebdav`" ]; then echo "Stopping twonkywebdav" kill -9 `pidof twonkywebdav` fi # Remove the route route del -net 224.0.0.0 netmask 240.0.0.0 dev egiga0 >/dev/null 2>/dev/null </dev/null & } run_rc_command "$1"twonkyserver-default.ini
#!/bin/sh # PROVIDE: twonky # REQUIRE: LOGIN . /etc/ffp.subr name="twonky" start_cmd="twonky_start" stop_cmd="twonky_stop" twonky_start() { # Add a route for twonky to be published via UPNP route add -net 224.0.0.0 netmask 240.0.0.0 dev egiga0 >/dev/null 2>/dev/null </dev/null & cd /opt/twonky mkdir -p /opt/twonky/data/ & # Twonky requires one handle per monitored filesystem if inotify is # used. On many devices, this is set to 8192, which might be too low # if music or photos are scanned. Therefor this value is raised to # the doubled amount. If more is required, change the value below. # Thanks Michael for reporting this! /sbin/sysctl fs.inotify.max_user_watches=16384 >/dev/null 2>/dev/null </dev/null & # The line below is without logging (logs are written to /dev/null). # If you want logging, exchange it with the line below the current one. /opt/twonky/twonkystarter -logfile /dev/null -appdata /opt/twonky/data/ >/dev/null 2>/dev/null </dev/null & # /opt/twonky/twonkystarter -logfile /opt/twonky/data/TwonkyMediaServer-log.txt -appdata /opt/twonky/data/ >/dev/null 2>/dev/null </dev/null & } twonky_stop() { # Kill Twonky if [ -n "`pidof twonkyserver`" -o -n "`pidof twonkystarter`" ]; then echo "Stopping twonkyserver" kill -9 `pidof twonkyserver` `pidof twonkystarter` fi if [ -n "`pidof twonkyproxy`" ]; then echo "Stopping twonkyproxy" kill -9 `pidof twonkyproxy` fi if [ -n "`pidof twonkywebdav`" ]; then echo "Stopping twonkywebdav" kill -9 `pidof twonkywebdav` fi # Remove the route route del -net 224.0.0.0 netmask 240.0.0.0 dev egiga0 >/dev/null 2>/dev/null </dev/null & } run_rc_command "$1"
NB: These scripts are provided for reference only – more current versions may vary.
Also – I didn’t bother with this line [[ $(ls -1 /mnt|grep -c HD_a2) -eq 0 ]] && sed -i -e ‘s!/HD_a2!/HD/HD_a2!g’ -e ‘s!/HD_b2!/HD/HD_b2!g’ /ffp/opt/twonky/twonkyserver-default.ini
in the instructions – it does a search and replace – but it doesn’t seem necessary.
Finally the ‘twonky.sh’ script makes use of a script called ‘ffp.subr’ which I think is used to start and stop the twonky service. This doesn’t exist in Debiansqueeze. There is probably some native way of achieving the same thing – but I don’t know what it is so instead, I went and found the download for ffp – unpacked it, and retrieved the script. There’s nothing specific to ffp in it so I dropped it into the /etc directory. You do need to go through the file and remove /ffp off the start of any paths that it appears in.
Then as instructed, I ran the twonky,sh script to start the service and connected via a web browser – and OMG!!!! IT WORKED!!!! First time too, which usually only happens to people who are either (a) lucky or (b) liars.
Once I had configured the server through the web page, I left it to get on with the job of indexing my media collection. This was a task that UPnP service that came with the NAS had taken all night to do. Twonky seemed to do it in minutes. Not only that, connecting using Windows Media Player, it downloads the metadata from Twonky so much more rapidly. Streaming of both audio and video is very rapid and smooth as is seeking to a certain spot in the video. All in all – very impressed with Twonky. It’s good.
There are three reasons, changing all this stuff worked:
1) All the scripts use the sh shell which is of course available in both ffp and debiansqueeze (ie the syntax was the same)
2) The folder structures of ffp and debiansqueeze are very similar.
3) Can’t remember – it’ll come back to me.
The only reference for this post, is to thank (again) Uli author of the http://nas-tweaks.net site
for this page http://nas-tweaks.net/384/installation-of-twonky-server-7-on-nas-devices/