PS3 Media Server As A Linux Service

In a previous blog I detailed how I’d managed to get PlayStation 3 Media Server (PMS) up and running on my Lubuntu box, and had it starting automatically.  At this stage there were 2 problems with the setup:

  1. PMS was running as root, which is a self-evidently Bad Thing TM
  2. It was serving every folder from “/” downwards – when all I really wanted was a TV and a Film folder, both mounted under /media

So my goal for today was to complete the following steps to rectify this and have my PMS running on startup, and only showing the correct folders.  My plan was:

  1. Create a user (‘pms’) to be responsible for running the PlayStation 3 Media Server program (reference)
  2. Give the user (minimal) permissions needed to do this (reference 1, reference 2)
  3. Change my startup routine to make sure the PMS started as the right user
  4. Sort out the configuration so only the right folders are shown to the clients

So let’s get started

Continue reading “PS3 Media Server As A Linux Service”

Installing PS3 Media Server on Lubuntu – and Running at Startup

One reason for purchasing the HP Proliant Microserver (N40L) was to run it as a media server (since the Linkstation Live NAS drive I already have, while a decent fileserver, doesn’t seem to play nicely with the PlayStation 3 for some reason).

I looked at a few options and eventually decided on PS3 Media Server as my DLNA server – despite the name, it supposedly serves media to all sorts of devices.  Oh and after trying Fedora 16 (no wake on LAN), Ubuntu (dodgy RDP display quirks), Kubuntu (software updater refused to work) and openSuse (just too different from Ubuntu) I settled on Lubuntu – a light-weight Ubuntu variant with the LXDE (Lightweight X11 Desktop Environment).

So my day has been spent trying to install the PS3 Media Server, get it to work (easy) and – now here’s the tricky part – get it to run as a service (i.e. in the background, and on startup – before I’ve logged in).  This involved a lot of learning about things I’d never heard of before, or had completely forgotten, like init.d, Linux run levels, shell scripts, putty, PPAs and loads more – but I’ll try and keep this as simple as I can.

So the first bit is easy, thanks to Ubuntu Help’s PS3 Media Server page.  Installation can be done using Ubuntu’s standard apt-get.  PS3 Media Server isn’t in Ubuntu’s built-in repositories but someone has helpfully created a “Personal Package Archive” or PPA (whatever that is) that apt-get can install from.  So you need to fire up your terminal and run:

sudo add-apt-repository ppa:happy-neko/ps3mediaserver
sudo apt-get update
sudo apt-get install ps3mediaserver

As far as I can tell these three steps tell Ubuntu to add a new repository (the ppa) to the package manager, update the list of packages available (to add the packages in the ppa) and then install the package it’s just found called ps3mediaserver.  Easy, right?

Now you can play about with it (you’ll find it at /usr/bin/ps3mediaserver) and a guide to some of the PMS settings is available online. But if you’re running a home server like my Microserver, you’ll probably want it to run at startup (before any user login).  This is trickier.

According to the docs, it’s not recommended to run PS3 Media Server as a daemon on Linux… oh dear.  (If you want an easy life, it seems you can run it as a Windows Service easily enough).  However it looks like it is possible.  First, I recommend learning a little about the /etc/init.d directory and rc.d – for which I found an explanation of init.d and  a helpful introduction to Linux services.

Basically the init.d directory seems to be a collection of scripts, each one designed to manage (stop/start) a specific application on start up.

In addition to this I’d been looking at Leigh Henderson’s guide to installing PS3 Media Server where the author had the same objective – running as a ‘headless’ service.  However, he had downloaded and installed the files himself (not using the PPA) which seems to work slightly differently.  Leigh talks about using a script (PMS.sh, which comes with the manual download) to start the program, which I simply didn’t have.

I did manage to take Leigh’s instructions and make them work for the apt-get installed version of the server though.  After messing about with the ps3mediaserver script that was already in init.d (a much more complicated beast), and not being able to make it do what I want, I decided to write my own version of Leigh’s simple script.

Despite my initial trepidation, it seems all that was necessary was to call the executable /usr/bin/ps3mediaserver instead of his script at /opt/pms/PMS.sh.

i.e. create a script in /etc/init.d (I called mine pmsautostart) with the following content:

#!/bin/bash
nohup /usr/bin/ps3mediaserver &
exit

You’ll need root permissions (sudo) to save this file.  The nohup help tells me that nohup simply runs a command but then ignores ‘hangup’ signals.  As far as I can tell these are signals sent from the OS when a user logs out, telling the program to quit.

And you should be good to go!  Please let me know if the above works for you.

Note that I take no responsibility if you repeat what I did and break your OS.  I’m just learning this stuff myself and, for example, already know that this solution leaves your PS3 Media Server running as root (and I’m sure this is a bad idea so my next task will be trying to figure out how to run it as someone else).  Nevertheless, you’ve been warned!

PS – The only other thing I haven’t figured out so far is how to get PS3 Media Server to not show every directory on my system to the PS3.  I tried restricting the shared folders using the GUI but that doesn’t seem to do anything. If you figure this out before I do please let me know that too!

What’re you lookin’ at?

Well I thought it was interesting so here’s the top 10 posts on nerd. by number of views (based on the last 500 page hits courtesy of Statcounter.com).

  1. Review: Why the Netgear WG311 v3 Sucks (72)
    Slightly dodgy network card that Netgear don’t seem that fussed about fixing.

    Bad on XP, it got worse on Vista (see number 4).

  2. Playing iPod Video on Your TV (45)
    Seems to be a lot of people looking for instructions for the iPod Classic. Here’s a tip: sell it.
  3. Server application unavailable: installing IIS on .NET 2.0 (44)
    Seems to be a common problem. Sadly Microsoft’s error message is about as relevant as ever.
  4. Installing Vista (AKA More Netgear WG311 Misery) (31)
    Even more messed up. Thank goodness for Linksys!
  5. Thunderbird/Outlook/Google Calendar Integration (25)
    How to integrate your Thunderbird calendar at home with your Outlook in work, via Google Calendar.
  6. Orange Answerphone (Voicemail) Number for PAYG (23)
    Such a simple problem. Who knew it would be so hard to find?
  7. Stop Monitor.exe Hogging CPU (20)
    Why can’t people just give you a standard installation instead of trying to do everything for you? Help sounds good, until their useful tools start killing your PC.
  8. How to run IIS Web Server in Windows XP Home (20)
    Microsoft’s official line is it can’t be done, but it’s not that tricky.
  9. Making Firefox Scroll With Syanptics TouchPad (19)
    Discovering the solution to making Firefox scroll on my Acer Aspire laptop.
  10. NAS or Home Server (17)
    I deliberate over whether I can justify spending the extra to build or buy a home server before eventually deciding that a Linkstation Live will meet my needs for less than half the price.

NAS or Home Server

I need a NAS or a Home Server, I just can’t decide which.

I currently have a desktop PC in a bedroom, a laptop which spends most of its time in the living room, and a Buffalo LinkTheater which sits under the TV (also in the living room). I have a lot of files on the desktop PC that I watch, through the LinkTheater, on my TV. One of the problems with this is that it requires the PC to be switched on when I want to watch something, but a bigger problem is that the hard drives are filling up. For extra storage, the natural option seemed to be a LinkStation Live NAS which would store the files and allow the LinkTheater to stream them, but then I read about the efforts made by other nerds to turn the LinkStation into a web server. How great would it be if I could turn it into a testing server for the web sites I design?

After a little more reading it seems that this is not an easy thing to do with the LinkStation Live. The OpenLink hacked LinkStation firmware allows installation of extra software, but from what I can tell doesn’t seem to be compatible with ARM-based boxes like the LinkStation Live, only with older LinkStations (at least the lack of installation instructions suggest this). I’m now investigating the possibility of getting a cheap Home Server instead, though I have some constraints: it must be small, so I can stick it in a corner out of the way, and it must be silent.

Basically I want to be able to completely forget about it when I’m not using it.

Obviously since a 500GB NAS (the LinkStation) can be obtained for under £150, I don’t want to spend too much more than that on the server – which all but rules out a Windows Home Server based system. That’s not a problem, I want to work on my Linux knowledge anyway. I’ve spent part of today searching on Google and ebay for terms like “xpc x100“, “shuttle pc“, “sff pc” (small form factor) and “mini pc“. Finally I came to “ITX PC“; Mini-ITX (along with Nano-ITX and Pico-ITX) being a standard form factor for motherboards that use low amounts of power and are therefore suitable for use as the basis of fanless (and therefore quiet) systems. I should have remembered this from a project I did last year in university involving in-car PCs.

So far I’ve come across a couple of UK shops so far, none of which have managed to give exactly what I wanted. Mini-ITX.com, as well as news and reviews, have bundles that basically amount to DIY kits for the type of system I’m looking for. The Intel Bundle comes close but I’d need to add a new hard drive as 80GB would not last any time at all. Another UK company, LinITX, offer build-your-own systems based on their skeleton systems, but the ones in my price range (like their Home Server bundle) are too big, at normal PC size, and don’t include hard drives. ITX-Warehouse just looked too dear; their only self-build barebones system was over £300.

Sorry if anyone was looking for a conclusion to this post, but I’m still looking for now. I may look further into hacking the LinkStation into a web server or I may just take the (relatively) easy option of getting a home server.

Buffalo Linktheater – Workaround for DivX Codec Issues

I was treated to a Buffalo Linktheater Wireless A & G (that’s the version with no DVD player, I think that was a US-only thing) media streamer by my wonderful girlfriend for Christmas. I’ll post a review (hopefully) in the near future, but first I need to get it set up properly. I successfully streamed some video files to it while at my parents’ house for Christmas week. I finally got round to setting it up in my own house tonight to discover a few kinks.

I have been using Windows Media Player 11 (as it’s already built in to Vista, it’s also a free download for XP) as the server to stream from. The problem is that when I tried to browse a particular folder the Linktheater seems to freeze for a while before opening it, and then showing it as empty. When I checked my PC an error message had appeared informing me that “Windows Media Player Network Sharing Service has stopped working”. On clicking “search online” for more information Windows informed me that:

This problem was caused by DivX Codec. DivX Codec was created by DivX, Inc..
DivX, Inc. is aware of this problem and working as quickly as possible to make a solution available.

The Application Event Log contains an entry for each crash with Event ID 1000 and Task Category 100 and a description something along the lines of:

Faulting application wmpnetwk.exe, version 11.0.6000.6324, time stamp 0x4549b540, faulting module divxdec.ax, version 6.8.0.0, time stamp 0x47547cff, exception code 0xc0000005, fault offset 0x0005c021, process id 0xe1c, application start time 0x01c84be4834cb5f8.

which doesn’t really help much.

Workaround

I split the folder in two, and one of the new ones worked fine. I continued like this until I had narrowed the culprit down to be one of two files. However at this stage the folders all displayed their contents fine, including the one containing only the suspects. Now they just wouldn’t play.

After a lot of moving files and much more crashing and restarting of the Windows Media Player Network Sharing Service, I narrowed the culprit down to a particular video file. I’m not sure what the problem was as it had worked fine when streamed from an XP computer also using Windows Media Player 11; in fact it was watched start to finish without any problems.

It may be an issue specific to Vista or the DivX 6.8 codec, either way I’m happy it’s sorted.

If anyone finds out any more about the cause of this kind of problem or a quicker solution, please do let me know. Meanwhile I hope the above helps someone. Oh and the Buffalo Linktheater Wireless A & G is available from Dabs for about £95.