Adding unRAID UPnP How-To


Recommended Posts

So first of all hi to the forums since this is my first post.

 

Now that that's over with I'll get to the business of posting a little How To to get UPnP running on unRAID. I know quite a few people have UPnP media devices that want to play their content from unRAID and I happend to know one of them who needed help. I'm sure there are plenty of ways to get this working and that its been discussed before but I could honestly not find a good simple guide for it on these forums or linked from this great wiki entry: http://lime-technology.com/wiki/index.php?title=UnRAID_Topical_Index

 

I'm aware of Twonky and the PS3mediaserver solutions but Twonky is not free and PS3mediaserver went over my head and also was not geared towards generic UPnP devices. I choose MediaTomb in the end and this is how I got it working.

 

How-To Version 1.2

 

1: Download MediaTomb from http://mediatomb.cc/pages/download and get the Static Binaries for i368. Most current right now (8 April 2009) is "mediatomb-static-0.11.0-r2-linux-uclibc-i386.tar.gz"

 

2: Extract the .gz and the .tar file using 7-zip or whatever unpacking utility works for you until you get to the "mediatomb" folder. Copy this folder to the root of the unRAID flashdrive.

 

3: To start Mediatomb when you boot you need to edit the Go file found in the config folder. Please use WordPad to edit this file since WordPad is Linux/Unix friendly unlike Notepad or Word and won't "ruin" the file. Now add the following to the file at the bottom

 

cd /boot/mediatomb

echo "./mediatomb.sh" | at now + 1 minute

 

and save the file. The reason for navigating to the folder using cd first is that the mediatomb.sh script wont run properly if its not run from the correct folder. Using echo at the start hides the script from the consol so it wont look strange and the "at now + 1 minute" part delays the start of the script. The delay is there to make sure unRAID has time to mount all the drives properly and establish a network connection.

 

4: Reboot the server so that MediaTomb can start up once and create all its needed configuration files.

 

5: Getting support for international characters such as åäö. You will need to add the following lines to the config.xml file that was created during the reboot in step 4. You will find it in "flash\mediatomb\config\".

 

<filesystem-charset>UTF-8</filesystem-charset>

<metadata-charset>UTF-8</metadata-charset>

 

Add them to the top of the Import function, namely after "<import hidden-files="no">". Again please use WordPad when editing this file for the reasons mentioned above, also NotePad and the rest tend to have problems displaying .xml files in a easy-to-read manner.

 

6: Reboot once again to impose the UTF-8 changes. Once its all started again you can configure MediaTomb from http://unraid-servers-ip:49152/ and also add/remove content from its database. It could be other ports if the default 49152 is taken, usually it tries going one port higher until it finds a free port so just start upping the port until you find it.

 

Post-Install support of UTF-8: If you already have MediaTomb installed in some manner and want to add the UTF-8 support you have to delete the database file mediatomb.db found in "flash\mediatomb\config\" first so that MediaTomb can rebuilt it with the correct UTF-8 characters when rebooting.

 

End of How-To

 

Known Bugs in Version 1.0-1.2 configuration

The current configurations has one big problem and that is you cant stop the array when the UPnP server is being used. This will cause the parity to get unsynced and you'll be forced to do a hard-reboot of the array (alternatively shut it down from the terminal) so please keep that in mind and make sure all UPnP devices are inactive before stopping the array. Suggestions on how to fix this would be appreciated. The ability to run code when stopping the array will apparently be added to unRAID 5.X, until then just remember to turn of any UPnP devices before stopping the array.

 

Changelog of guide:

 

1.0: Initial guide, had known problems and was more of a betatest.

1.1: Fixed all known problems from 1.0 with starting script and other flaws such as spelling, wording and changed from NotePad to WordPad as suggested editor. Found the de-sync bug in this configuration for the first time, its assumed to be in the 1.0 configuration as well. Special thanks goes to [glow=green,2,300]Joe L.[/glow] and [glow=green,2,300]RobJ[/glow] for their help with this version of the guide.

1.2: Guide missed the reboot step before adding UTF-8 support, hard to change a file that's not there. De-sync bug still not fixed but also the only known bug, solution supposedly on its way in 5.X.

Link to comment

I might check this out.  I have ps3mediaserver installed, I didn't think it was too bad to do once I had all the packages, just that the way it organises the media didn't work out too well with my Xbox 360 (not too surprisingly perhaps?)

 

You should look into the screen command - I think its part of stock unRAID but I know its used in bubbaRAID because rTorrent is similar in that it takes up the current terminal.  You can create a new screen then use to run media tomb.

Link to comment

There is an easy way to start the process and allow the "go" script to finish.

 

Add the following two lines instead of the ones you described:

cd /boot/mediatomb

echo "./mediatomb.sh" | at now + 1 minute

 

I've not tried this, as I have no need for mediatomb at this time, but this should start mediatomb one minute after the "go" script runs.  (Some delay is needed, as it takes some amount of time for the disks in the unRAID array to come on-line anyway.

 

The "at" command is one that allows you to run commands at a time in the future.  It is a bit confusing on how to invoke it, as it reads the standard input for its commands.  It automatically remembers the environment, so it will know to start in the /boot/mediatomb folder.

 

Joe L.

 

Link to comment

There is an easy way to start the process and allow the "go" script to finish.

 

Add the following two lines instead of the ones you described:

cd /boot/mediatomb

echo "./mediatomb.sh" | at now + 1 minute

 

I've not tried this, as I have no need for mediatomb at this time, but this should start mediatomb one minute after the "go" script runs.  (Some delay is needed, as it takes some amount of time for the disks in the unRAID array to come on-line anyway.

 

The "at" command is one that allows you to run commands at a time in the future.  It is a bit confusing on how to invoke it, as it reads the standard input for its commands.  It automatically remembers the environment, so it will know to start in the /boot/mediatomb folder.

 

Joe L.

 

 

Sounds like a plan and I'll give it a go. Otherwise I just did some research of my own and adding "&" after the last line also seemed to let you reach the login without any apparent (other than scrambeling the text on the screen a bit first) problems and the UPnP media device can still access the server. I'll give your way a testrun as well because I like the point you brought up about giving the drives time to spin up.

Link to comment

There is an easy way to start the process and allow the "go" script to finish.

 

Add the following two lines instead of the ones you described:

cd /boot/mediatomb

echo "./mediatomb.sh" | at now + 1 minute

 

I've not tried this, as I have no need for mediatomb at this time, but this should start mediatomb one minute after the "go" script runs.  (Some delay is needed, as it takes some amount of time for the disks in the unRAID array to come on-line anyway.

 

The "at" command is one that allows you to run commands at a time in the future.  It is a bit confusing on how to invoke it, as it reads the standard input for its commands.  It automatically remembers the environment, so it will know to start in the /boot/mediatomb folder.

 

Joe L.

 

 

Sounds like a plan and I'll give it a go. Otherwise I just did some research of my own and adding "&" after the last line also seemed to let you reach the login without any apparent (other than scrambeling the text on the screen a bit first) problems and the UPnP media device can still access the server. I'll give your way a testrun as well because I like the point you brought up about giving the drives time to spin up.

The disks don't need to spin up, they need to be mounted on the appropriate mount points and the user-share file-system started.  (doing that does spin them up, but that is a side effect of the disk I/O needed to mount them)

 

And..., it is not just the disks, it is also the network interface.  It too is started by emhttp.   Somehow, I think the networking is involved almost as much as the disks.  :D

 

Joe L.

Link to comment

First, thank you very much for taking the time to prepare this for other users.  I've added it to the UnRAID Topical Index in a new topic of UPnP (needs more entries),  and to the How-To's wiki page.

 

One minor correction, since I imagine you will be editing Step 3 to adjust the go script lines, you should also remove this line:  "Keep in mind that the server needs to be stopped before you can edit this file."  Since the go script is only read and executed as part of the unRAID startup, you can do anything you want to it, at any time.  Your changes won't 'take effect' or be executed until the next boot.

 

If you are interested in the screen command, see this excellent post.

 

Although you can use Notepad without issue for editing the go script, we don't like to recommend it.  unRAID is designed to 'forgive' whatever end-of-lines are used in the go file, by executing a filtered version of it, first filtering carriage-returns out of it using fromdos.  But we prefer to recommend WordPad or other editing tool that preserves the Unix end-of-lines (line feeds only) for most other scripts and configuration files.  Please see this FAQ entry, "Why do my scripts have problems with end-of-lines?".  Apologies if you already knew all this.  In other words, Notepad is fine for the go file, but may cause problems with the config.xml file.  Surprisingly, WordPad preserves the Linux end-of-lines, so long as you don't create the file from scratch, or save it as a .doc file or other incompatible form!  (We should have a FAQ entry on this, with a link to the various discussions of good alternate editors.)

Link to comment

First, thank you very much for taking the time to prepare this for other users.  I've added it to the UnRAID Topical Index in a new topic of UPnP (needs more entries),  and to the How-To's wiki page.

Sounds good.

One minor correction, since I imagine you will be editing Step 3 to adjust the go script lines, you should also remove this line:  "Keep in mind that the server needs to be stopped before you can edit this file."  Since the go script is only read and executed as part of the unRAID startup, you can do anything you want to it, at any time.  Your changes won't 'take effect' or be executed until the next boot.

I only added that line because I wasn't able to edit the go script without stopping the server once. Seems to work now so I guess that must have been some other issue or me being to fast to open it after a reboot of the server. Corrected this part now.

If you are interested in the screen command, see this excellent post.

I was under the impression that screen was not possible in stock unRAID but I'll give it a go. It would be preferable to keep this guide as simple as possible in the end so if there are other ways of just hiding the script and letting it run in the background that would be good as well. (Guess that's kind of what screen ultimately does)

Although you can use Notepad without issue for editing the go script, we don't like to recommend it.  unRAID is designed to 'forgive' whatever end-of-lines are used in the go file, by executing a filtered version of it, first filtering carriage-returns out of it using fromdos.  But we prefer to recommend WordPad or other editing tool that preserves the Unix end-of-lines (line feeds only) for most other scripts and configuration files.  Please see this FAQ entry, "Why do my scripts have problems with end-of-lines?".  Apologies if you already knew all this.  In other words, Notepad is fine for the go file, but may cause problems with the config.xml file.  Surprisingly, WordPad preserves the Linux end-of-lines, so long as you don't create the file from scratch, or save it as a .doc file or other incompatible form!  (We should have a FAQ entry on this, with a link to the various discussions of good alternate editors.)

I really wanted to use WordPad but to me it seemed like it couldn't add stuff to the file, just view it. Notepad was the only program actually able to edit the file which is why I used it but I'll keep an eye on WordPad to see if I can get it running, much more user friendly handling of .xml files to begin with. (Using Vista if that carries any importance even though I doubt it).

 

I'll do some editing and cleanup of this How-To until we got a solid way of doing it. On the fix list right now is

Changing NotePad to WordPad Done

Trying screen and the tips from NAS and Joe L. Done

Link to comment

Double posting here but I've found another issue now that I've solved the first one and wanted to hear your toughts on it. If I stream from the MediaTomb server and want to Stop the array at the same time it wont stop, fair enough, but the problem is that it also gets out of sync with the parity and hence has to do a parity check. Also it wont Stop properly after failing the first time even if you turn off the streaming so you must do a hard-reboot or possibly shut it down from a terminal.

Link to comment

how does this work with the Xbox360? Do you need anything else configured to get the xbox to see this or just this setup?

 

I have a windows  machine acting as a front end and I would love to take it offline and just use my NAS without requiring another machine to talk back and forth.

 

Link to comment

This sounds awesome, thanks Zeiva!  Just one question, if anyone could clarify:

2: Extract the .gz and the .tar file ... the "mediatomb" folder. Copy this folder to the root of the unRAID flashdrive.

 

3: To start Mediatomb when you boot you need to edit the Go file found in the config folder. .... add the following to the file at the bottom

 

cd /boot/mediatomb

echo "./mediatomb.sh" | at now + 1 minute

 

Wouldn't the mediatomb directory be at the root of the flashdrive?  If so, wouldn't you write cd /mediatomb in step 3?

Or, should step 2 be: copy "mediatomb" into the boot directory on the flashdrive?

 

Other than that, everything else makes sense.

Link to comment

 

Wouldn't the mediatomb directory be at the root of the flashdrive?  If so, wouldn't you write cd /mediatomb in step 3?

Or, should step 2 be: copy "mediatomb" into the boot directory on the flashdrive?

 

Other than that, everything else makes sense.

 

No the root of the flash drive is mounted to /boot on the system..

 

if I create a folder on the flash called foobar, then the full path name for this folder on the unRAID system is /boot/foobar

 

 

Cheers,

Matt

Link to comment

It is as Biggy2872 says. It still annoys me that we've yet to find a solution to the de-sync of parity problem when stopping the array though. That is quite a serious issue acutally and when combined with the forced shutdown that has to follow it can cause some heavy dataloss.

Link to comment

This sounds awesome, thanks Zeiva!  Just one question, if anyone could clarify:

2: Extract the .gz and the .tar file ... the "mediatomb" folder. Copy this folder to the root of the unRAID flashdrive.

 

3: To start Mediatomb when you boot you need to edit the Go file found in the config folder. .... add the following to the file at the bottom

 

cd /boot/mediatomb

echo "./mediatomb.sh" | at now + 1 minute

 

Wouldn't the mediatomb directory be at the root of the flashdrive?  If so, wouldn't you write cd /mediatomb in step 3?

Or, should step 2 be: copy "mediatomb" into the boot directory on the flashdrive?

 

Other than that, everything else makes sense.

 

I can tell that you are used to DOS and Windows (like me), and not Linux, so you get to be my first invited 'guinea pig' for the new FAQ entry (unfinished!), "How is a Linux console different from a Windows console?"

 

I'm hoping it will help others understand some of the differences between Windows and Linux, particularly as to questions like the ones you asked.

Link to comment

Thanks Biggy2872!

 

RobJ, I'm actually pretty comfortable with Linux.  Isn't what Biggy describes more a peculiarity of how unRAID boots from USB and sets up the ramdisk?  Your FAQ seems to cover the basics nicely, though.

 

Zeiva, that does sound serious.  So is there no graceful way to shutdown MediaTomb?  And if I basically "never" stop the array, do I avoid this problem?

 

Link to comment

Thanks Biggy2872!

 

RobJ, I'm actually pretty comfortable with Linux.  Isn't what Biggy describes more a peculiarity of how unRAID boots from USB and sets up the ramdisk?  Your FAQ seems to cover the basics nicely, though.

 

Zeiva, that does sound serious.  So is there no graceful way to shutdown MediaTomb?  And if I basically "never" stop the array, do I avoid this problem?

 

 

Yes, its more related to how unRAID "installs" itself into ram rather than actually running from the USB. And yes if you don't stop the array you wont have this problem alexw. But when you DO stop the array (to change the array or power down the server etc) make sure no UPnP devices are active or using it. A graceful way of shutting down MediaTomb would be the ideal solution though.

 

If there is a shutdown script somewhere that can be manipulated to include a shutdown of MediaTomb that would be one acceptable solution.

Link to comment

Thanks Biggy2872!

 

RobJ, I'm actually pretty comfortable with Linux.  Isn't what Biggy describes more a peculiarity of how unRAID boots from USB and sets up the ramdisk?  Your FAQ seems to cover the basics nicely, though.

 

Zeiva, that does sound serious.  So is there no graceful way to shutdown MediaTomb?  And if I basically "never" stop the array, do I avoid this problem?

 

I don't know about graceful, but you can type

killall mediatomb

 

at the linux prompt and it will kill all the mediatomb processes.  That should let you stop the server without any mediatomb processes holding files open.

Link to comment
  • 2 weeks later...
  • 2 months later...

Thank you for your guide. I got Mediatomb running now.

 

I don't know it's my Windows screwing up my go and mediatomb.sh files or WinZip. When I view the files by using vi, I see those ^M at the end of each line. I have to manually delete those by using vi in order to get the script executed. I just want to put these out so someone don't have to spend an extra hour like myself to pull their hair out.

 

 

thanks,

~joy

Link to comment
  • 1 year later...
  • 1 month later...

I'm rather interested myself. Just picked up a TV this evening.

 

I just plugged in a USB stick to the back with a Dvix and Xvid file on it and it played perfect. I guess I just need to find an app for unRAID that will show up on the screen. Doesn't appear that the Samsung needs any kinda of transcoding. I guess I'm not completely surprised since my Samsung phone plays everything I feed it.

 

I'm using this device to feed it video and it works perfectly. However I'm not sure exactly what app it uses unless somebody else can figure it out and port it to unRAID.

http://wiki.dns323.info/

Link to comment

On my Samsung TV

 

I just tried this and its telling me that my Dvix and Xvid files are not supported formats. However when I use the same files from a USB stick or from another Nas device they play fine.

 

I'm wondering if there is something in the Config file that needs adjusted.

Link to comment

I found this and I'm trying to figure out exactly what it means or how to implement it.

http://forums.cnet.com/7723-13973_102-336205.html

 

samsung series 7 tv works with mediatomb with following conf

 

by !leet - April 20, 2009 9:13 AM PDT

 

In Reply to: DLNA from a Linux-based server? by JustNeil

 

I was able to coax mediatomb into being compatible with my samsung tv by adding the following custom http headers to it's dlna server via it's config.xml:

 

<custom-http-headers>

<add header="transferMode.dlna.org: Streaming"/>

<add header="contentFeatures.dlna.org: DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000"/>

</custom-http-headers>

 

Also it seems like the samsung tv wants all videos to be advertised as type video/mpeg even though their real type could be divx avi etc.

 

Hope this helps samsung tv owners until Tversity can do the same.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.