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!

Kubuntu Muon Software Centre Crashes on Opening

I’ve recently installed Kubuntu 11.10 on my HP Proliant Microserver (N40L). This was my third attempt at installing a Linux OS that I wanted to operate using Wake on LAN and Remote Desktop (RDP) from my Windows 7 laptop, so I was determined it would be third time lucky and I wouldn’t have to try another OS or reinstall.

After Ubuntu’s unity interface caused issues over RDP where nothing on the desktop displayed, and prior to that Fedora just outright refused to Wake on LAN, I was pleased that Kubuntu both Woke on LAN and let me login (and actually do things) over Remote Desktop. The only problem was that the installation seemed to be broken, as any time I tried to open Kubuntu’s “Muon” Software Centre, it crashed on startup with an error saying

Executable: muon-installer PID: 2165 Signal: Segmentation fault (11)

I could still install software using the command line (which is how I got a remote desktop server installed to know that this worked!) but I’m not yet au-fait enough with this for this to be an acceptable solution, plus I didn’t like the idea of my shiny new toy being anything less than 100% capable, so off to Google I went.

I did find a thread on Ubuntu Forums which sounded very familiar: like another poster, (same error, 64-bit OS version, and I had to interrupt an update post-installation because it stalled about half-way), but none of the proposed solutions in the thread worked. The suggestion seems to be that Muon is just Kubuntu’s own fucked up mangling of KDE’s standard package manager.

I may tru Ubuntu again and try enabling the GNOME fallback, but someone in that thread did mention OpenSUSE – a distro I hadn’t considered to date. Maybe it will be ‘4th OS lucky’!

Excel Export to CSV Missing Last/Trailing Empty Columns

My god how I hate Excel. Often it’s because people use it for some purpose it’s not really suitable for, where a relational database (even Access!) would be much better because (they think) they know how to use Excel and god forbid anyone take the time to learn to do something properly. Sometimes however, Excel is just plain fucking stupid. This is one of those times.

Recently I was trying to save an Excel spreadsheet as a CSV, to import into SQL Server (importing direct from Excel without converting to CSV gives other problems, like the Excel driver ‘helping’ you by detecting the wrong column types).

It was during this apparently innocuous task that I discovered a massive fail in Excel, which resulted in the import failing because some columns were missing. SQL Server’s helpful error message read:

Data conversion failed when converting column x to column y. The conversion returned status value 2 and status text “The value could not be converted because of a potential loss of data.”

Trying the same thing using BULK INSERT gave the error:

Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 17

followed by the same message for a number of other rows.

Continue reading “Excel Export to CSV Missing Last/Trailing Empty Columns”

Take a Screenshot on your HTC Desire S / Evo 3D

I know you can take screenshots with Android 4.0/Ice Cream Sandwich, but I discovered a week or so back that, having upgraded my HTC Desire S to HTC Sense 3.0 (on Android 2.3.5) I can now do this without an ICS upgrade!

Here it is from the horse’s mouth: it seems all you have to do to take a screenshot on your HTC device is hold the power button and press the home button. Your screenshot will be captured and saved to your gallery.

I actually took my first screenshot on my Desire S following the upgrade to HTC Sense 3.0 by accident!! I was on a website in the browser and pressed something that made a message come up “Screenshot saved to Gallery”. What!? Screenshot?

Yes, it turns out you can take a screenshot on HTC Sense 3.0 (and presumably HTC Sense 3.5). I have since got myself an HTC Evo 3D (which comes with Sense 3.0) and verified that the same process works there, the only difference is that it saves to “Camera Shots”.

Much thanks to Andrew Girdwood, whose post  “How do you take a screen shot with your HTC Sensation” I came across on a Google search as his comments section was where I first discovered the answer.

Thunderbird “invalid security certificate” error

I recently upgraded my Ubuntu installation to 11.10 after not having used it in a while. Part of the upgrade to this new version (Oneiric Ocelot) is that automatically (I believe) adds Thunderbird to your installation, intending that you use it rather than previous client Evolution.

Now, I haven’t used Thunderbird in a while so its fancy new “detect my mail server settings” functionality was all new to me. It all actually went quite well, detecting my mail server name and ports by checking “common server names” based on my email address of steve@xxxxxx.co.uk (in my case mail.xxxxx.co.uk).

However my providers SSL certificate isn’t mapped to my domain so the certificate is flagged as “invalid”. There’s no option to accept this certificate so you have to go digging around in Preferences (Options on Windows versions).

What you need to do is go to Edit -> Preferences and go to Advanced -> Certificates -> View Certificates, From here, Add an Exception giving your server (e.g. mail.xxxxx.co.uk:143). Click ok and go back to account setup and it should allow you to proceed. Hope this helps and thanks to leepa at Mozzilazine Forums and also bpat1434.

Windows 7 Starter – Black Desktop Background after Activation

I purchased a netbook about 4-5 months back that came with a Windows 7 Starter licence key but no software. I managed to get a copy of Windows 7 Starter installed and all was running fine – though it never asked me to enter the product key!

But all was running fine until a few months later when I’d decided to sell the netbook. When I powered it up I got a message telling me that my copy of Windows was not “genuine” and that I may be a victim of software piracy. It had also turned off the desktop background, so my desktop was now a rather boring, plain black! Based on the fact the netbook had the product key on a sticker attached to it, I was pretty sure this was just another case of Microsoft’s draconian steps being a bit, shall we say, WRONG!

So I opened up the activation screen, activated the software. It took about 5-10 minutes (and I’ve no idea why, presumably it sends a little information to Microsoft, which says yay or nay, amirite?). Now the activation went fine, eventually, but while the message telling me the software wasn’t genuine was gone, my desktop was still black. And as we all know, Windows 7 Crippled Edition Starter doesn’t allow you to change your desktop.

Uh-oh – a buyer might not be best pleased by this, especially as I’d just taken a photo to list showing the nice pretty blue Windows 7 background.

Anyway, I Googled a bit and after a while I came across the solution. it’s actually fairly straightforward but just tricky to find – nobody at Microsoft Answers seemed to have an answer, but here it is:

  1. Open the Registry Editor (by opening the Start menu and typing “regedit” in the search/run box)
  2. Find the key under /HKEY_CURRENT_USER/Control Panel/Desktop called Wallpaper.  This should be empty (hence the plain background, presumably).
  3. Right-click this key and Modify the value to the location of the image (e.g. C:\Windows\Web\Wallpaper\Windows\img0.jpg )

Now I did this to restore the original image after Microsoft ballsed it up, but it did get me wondering if the same technique could be used to change your Windows 7 Starter background to any image you wanted and thus overcome the stupid restriction impost by Microsoft. To be continued…

Using Body OnLoad with SharePoint (2010)

I spent a decent amount of time trying to workaround not being able to access the body onload event of a SharePoint page, including looking at adding JavaScript event handlers programatically, before I came across this… almost an aside in another article.

In order to work around this limitation, SharePoint provides the “_spBodyOnLoadFunctionNames” array. When the body is loaded, the onload event handler executes each function whose name is contained in this array.

So apparently all one has to do to have a JavaScript function execute when the body loads is to add the name of the function (as a string) to that array, a la _spBodyOnLoadFunctionNames.push("functionName"); – simples!

D’oh!

In the end we just wanted to do to much for simple JavaScript so used the awesome jQuery library – which includes the $(document).ready() method to take care of that, but I’m sure the above will help somebody, somewhere, some day.

Change Windows Startup/Logon Background

Today I got a bargain netbook in the Carphone Warehouse clearance sale – I’d ordered one yesterday online within minutes of the sale starting to be told they were out of stock and were cancelling my order a few hours later. Gutted. So I trapsed round their shops today and eventually picked up a brand new Toshiba NB250 “half-price” for just £120! Bargain!

But it seems Toshiba netbooks have a disgustingly garish OEM/branded background screen that’s displayed during startup and logon (though Win 7 starter still has the standard Windows 7 desktop background).  Turns out this isn’t too tricky to get rid of (and yes, it works on Windows 7 Starter).

Just head on into the registry and find the key called: HKLM\Software\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background – change the value from 1 to 0 and you’re back to the default Windows background.

You can apparently also change the background to any picture you want if you’re so inclined, but I just want something slightly less distasteful than Toshiba’s background so I’m done there.  Hope this helps someone.

Why is Windows being such a dick?

I recently bought a netbook on eBay that had come with Windows 7 starter but the owner had wiped this and replaced it with Linux.  I needed a new netbook and figured the fact this one came without Windows would keep the price down.  I was right and I purchased a netbook for £68, now all I had to do was get a copy of Windows 7 to install using the product-key which was still stuck underneath.

In the mean time I installed the new Ubuntu 11.04 and set up a number of partitions to get it ready. I set up a /boot partition of about 500MB (for Grub etc.?), a / partition for Ubuntu and a /home partition for my documents.  I also set up a “Win” partition to leave a space for Windows and a final NTFS partition to use for documents etc. when I was booted into Windows or to share across to Linux.  Linux seemed to be working fine and I got on the internet etc.  It was all very smooth, much more so than when I installed Ubuntu 9.10 or whatever it was back in the day.

I got hold of a copy of Windows and began trying to install it from SD card.  When it came to selecting a partition for Windows to live on, I picked my 40GB Win partition but Windows started throwing a strop and told me something it seems to have told a few others before me:

Setup was unable to create a new system partition or locate an existing system partition. See the Setup log files for more information.

Not impressed, I booted into Linux and tried to set a boot flag on this partition.  That took it off my original boot partition though, as a hard drive can only have one boot partition.

In the end I gave up and wiped all the partitions using the Windows installer.  I then created a 40GB partition for Windows, which proceeded to also create a 100MB “system” partition at the start of the drive.  I’m wondering if I’d left my room for Windows at the start of the drive in the first place if maybe I would have avoided this, but as it is – I now have to install Ubuntu all over again.  Fail!!  Thanks Micro$oft!

Skype Installation Shows Ubuntu Not Ready for Masses

The horrifically footery and niggly process I’ve just gone through to install Skype is sad proof that Ubuntu, and Linux, is still not ready for prime time. The fact you have to get a bit hacky to get a product as mainstream as Skype working is a sad indictment of the state of the OS.

Step 1: Add the Ubuntu Partner Repository following the instructions from Ubuntu’s wiki.

As my installation was Ubuntu 10.04 (Lucid Lynx) upgraded from 9.10 (Karmic Koala) I had to edit the repository information and change the distribution from ‘karmic’ to ‘lucid’ as for some reason this had not been automatically updated as part of the upgrade.

After doing this, and reloading the package information, the Synaptic Package Manager still didn’t find Skype when I searched, so I had to follow

Step 2: Revert to the terminal and enter

sudo apt-get update && sudo apt-get install skype

This was a command I’d picked up from Googling previously and finding this guide.  I figured it was worth a shot.  This seemed to work, gave me a lot of information and asked me if I wanted to continue. I did.

The terminal did a lot of stuff in the background as I’ve been typing this, eventually telling me:

Setting up skype (2.1.0.81-1ubuntu5) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

and returning me to the command prompt. Umm… ok? Still not sure this had worked I started looking for Skype and guessed (correctly) that it would be under Internet (I’m using Ubuntu Netbook Edition).  I opened it, accepted the Licence Agreement and signed in. Very slowly.

A good 2-3 minutes later I’m signed in.  Unfortunately, I only use Skype for talking to my girlfriend who’s currently studying in Malaysia and as it is currently 5:40 am there, she’s not online for me to test it out properly on a call.  However I don’t need to do that to ask this question:

How many ordinary users are going to go through all that just to install Skype, and how many will give up and go back to Windows?