Copyright 2009-2012 by djg. All Rights Reserved.

Wonky Gibbon Ramblings



DNS-320: Access Denied from User Nobody 0

Posted on June 15, 2013 by danny

Just had a bit of a hair pulling moment with my DNS-320.

Despite having given myself write privileges to a shared drive, I couldn’t write to it from windows, only read. Every time I tried to do any writing activity, Windows 7 would say “Access Denied” and indicate that I had to get permissions from the Unix user “Nobody”.

I logged into my Debian Squeeze installation to check the permissions on the directory – they all looked fine.

Mad.

Or not so mad.

It seems that the only way to reliably maintain the mapping between the windows user on my laptop and the unix user on the DNS-320 is using the utility that came with the NAS drive, a simple mapping of the network drive in Windows is not sufficient.

So if you run into this problem. Unmap the drive in windows and then recreate the mapping using the D-Link utility.

D-Link DNS-320 NAS, DebianSqueeze and Twonky Media Server 7

Posted on November 28, 2012 by danny

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.

twonky.sh
#!/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/

Configuring the D-Link DNS-320 NAS as an SVN Subversion server and connecting with VisualStudio 2010 4

Posted on November 23, 2012 by danny

Introduction

I recently found myself wanting to work on a programming project at home, using C# and VisualStudio 2010, and like any good developer realised I needed source control. Yes of course I could use Microsoft Sourcesafe, it does integrate nicely with VisualStudio. But lets be honest, it is a pile of crap, I’m used to TFS at work, I can’t be doing with Sourcesafe. Running my own TFS server is probably a bit over the top, I’m not sure I have the spare change in my back pocket for the licencing.

At the same time I was aware I wanted to move my RAID’ed storage / backup solution out of the media system under the telly where it currently lives, to a dedicated NAS device.

Two birds? One stone?

Being a tight arse I went over to Ebuyer and looked up the cheapest unit that supported RAID1 (mirroring) and gigabit transfer rates and found the D-Link DNS320 for £53 inc VAT without disks, it can take up to two 2TB drives. Thinking of my old Linksys router and remembering appliances often run linux under the hood, I had a bit of a google and found this page. Someone had got subversion running on it. Very cool!!

So I ordered one, waited a few days and once it arrived shoved a drive in it. Getting the device up and running was the job of a few minutes work. Getting subversion working – rather longer. Nevertheless – success was ultimately had. For reference, I am not a linux expert – in fact it would be fair to say, I know to next to nothing about it. But I like a challenge…

What will I end up with?

Whilst the DNS-320 ships with its own version of Linux in the firmware, we aren’t going to be able to bolt directly onto that. However there is an undocumented hook (called ‘fun_plug’ which I guess stands for functionality plugin) that is checked on startup and can be used to add additional functionality stored on the hard drive.

To get subversion running on the DNS-320 you need a linux installation that runs alongside the one in the firmware, in this case DebianSqueeze. Installing this does not affect the rest of the NAS and you wont see any impact on the web interface. Once you have DebianSqueeze installed and running, you install and configure the subversion package and away you go.

So what you end up with, is a NAS running linux, that runs DebianSqueeze linux as a plugin that hosts subversion.

Installation

Unfortunately it’s not that simple. To configure DebianSqueeze requires Telnet to be running on the NAS and unfortunately out of the box, this is not the case. Luckily there is a (convoluted) way to get a very thin linux install (ffp) with Telnet onto the box first and then use that to configure DebianSqueeze. Once that is done, the ffp install is not used any further.

This exceptionally well written blog post describes how to install ffp, the “Fonz fun_plug 0.5 for CH3SNAS, CH3MNAS, DNS-323”
Follow it all the way down to the section headed “Logging in using SSH”, but don’t disable Telnet in the last step, as you’re going to need it.

Next, download DebianSqueeze from here
Open the zip file. Inside is a “how to” and two other files. Follow the instructions in the file from Step 2 (you have in effect already done Step 1).
The very last step of renaming fun_plug.debian to fun_plug effectively discards ffp that we installed earlier, it having served it’s purpose.

Now that you have DebianSqueeze running you can install subversion.
This blog post here provides a step by step guide to do this.
Half way down he mentions the command:
# svnadmin create /var/svn/projectalpha
‘projectalpha’ should be replaced by whatever you want to call your repository.
Other than that, follow the blog exactly, all the way down to the point where it starts talking about running an ssh server on a custom port. You probably don’t need to do that so can stop there.

You now have subversion running on your NAS. Excellent!!

Connecting VisualStudio 2010

Although subversion is usually used with an Apache web server this is not actually necessary. The author of the previous post has avoided doing this opting to instead use the ssh server and communication protocol already installed with DebianSqueeze. This makes it more lightweight and conserves the limited RAM available on the box.

To get VisualStudio 2010 to work with subversion you need a plugin. A popular one is AnkhSVN which can be downloaded for free.

Once installed, assuming you don’t have the Tortoise SVN client installed then you need to help the plugin understand the ssh protocol before you can use it in VisualStudio.
This blog post describes how.
NB: The configuration file mentioned in the post is described as being in your My Documents\Application Data\subversion directory, this is in XP. In Windows 7, this folder now maps to here: c:\Users\<USERNAME>\AppData\Roaming\Subversion. You may need to set the Windows Explorer “Folder and Search Options” to “Show hidden files, folders, and drives” to be able to see the AppData folder.

Now restart VisualStudio.

First you need to enable Subversion as the source control plugin for VisualStudio. Go to “Tools->Options” and in the dialog go to the subsection “Source Control” and edit the “Plug-in Selection” to be AnkhSVN.

Now, you can connect to your Subversion repository using “File->Subversion->Open From Subversion.

In the dialog that pops up enter the URL of the subversion repository on your NAS box, which will look like this: svn+ssh://<NASBOX>/var/svn/<SvnRepositoryYouCreatedEarlier>
and you’re in!!!

So now you’ve got it all working. The only thing is this irritating “Plink.exe” window that keeps popping up. It has to go – it just has to.

Download TortoiseSVN from here, install it, find the file tortoiseplink.exe, rename it to plink.exe and replace your plink.exe with it. You can then uninstall TortoiseSVN again.

Hope this has been of help.

Now some thanks and references:
First and foremost Murzal Arsya who made it clear that this project could be done on the DNS-320, outlined the need for DebianSqueeze and provided the step by step instructions for setting up subversion on the NAS.
Next http://nas-tweaks.net which is a great resource for people wanting to use their NAS for more than just NAS and provided the amazing ffp stuff.
Then Shaunc for guidance on svn+ssh, cheers geeza!!
Finally Hao Chen for for the tip to get rid of the plink pop-up window http://haochen.wordpress.com/2011/02/22/hiding-the-plink-pop-up-window-in-netbeans-ide-using-svnssh/



↑ Top