Saturday, May 29, 2010

Killing a daemon in Ubuntu

To kill the ushare daemon:
  start-stop-daemon --signal KILL --stop --name ushare

Friday, May 28, 2010

Setting up Ubuntu - media server

So I'm studying the Open University's Linux course, T155. I decided that rather than sit at the desktop computer whilst studying this (like I did for 6 years and 8 months when doing my OU degree), I'd use my wife's laptop downstairs. It's only a ten week course, and I'm pretty sure I already know a fair bit on basic Linux stuff, so an isolated study environment is not necessary.

However, the laptop runs Windows Vista. I've only ever used it to check my emails etc on this laptop, and any OS can manage that. But, heaven forbid, I now need to use it for a little more than that, e.g. access a shared drive, move files around and use Virtual Box to run Ubuntu.

To cut a long story short... it's painful. I've actually found myself feeling real anger whist watching the little circle thingy that spins round when Vista is working out how to open a folder. So I've partitioned the hard drive and whacked Ubuntu straight on as a 'proper' OS. My intention is to completely move away from Windows, but we'll see how it goes... I need to make sure everything is as accessable as in Windows as other people need to use this laptop too. I also need to ensure there are ways to do all the stuff I do in Windows.

One of these things is to stream media to my XBox360, a task handled admirably by Tversity under Windows. Alas, there is no Linux version as yet, so the search started for an alternative. There are a number of choices, but the one that seems to work for me best is uShare. This is a really simple, lightweight UPnP application. As the title of this blog suggests, I'm going to log stuff I don't want to forget in case I need to do it again, so here are the steps I took to get uShare working in Ubuntu 9.04:
  1. download and install uShare. The easiest way to do this is via the Synaptic Package Manager GUI
  2. we need to state which files to share. Edit the ushare.conf file in /etc (I'm going to do what I wish others would do and assume people don't know much about working with the Linux terminal, so here are the exact steps):
    • sudo gedit /etc/ushare.conf
    • change the USHARE_DIR= to point to directories you want to share, eg USHARE_DIR=/home/john/Documents/Videos
    • change the ENABLE_XBOX line to read ENABLE_XBOX=yes
  3. You can start uShare in the terminal with:
    • ushare start
  4. And that's it!

I wasn't quite satisfied with this, as I wanted to have the media server start automatically after booting up - I don't want to have to explain to others that they need to open a terminal and execute commands to be able to watch a film!

After Googling, it was plain to see this was not a trivial task. There were loads of results on how to configure Linux to start uShare automatically, but none of them worked for me. After hours of trying, I ended up using one of the first tips I'd read (sorry - can't remember the link). I created a file with:

  sleep 30
  ushare -x

in it. (I found it wouldn't work without the sleep bit. I suspect uShare was starting before my wireless network was up and running, deciding something was wrong and bombing out, so I gave it a 30 second 'rest'). I then made it executable:
  • right click the file
  • select properties
  • open the permissions tab
  • check "Allow executing file as program".
You now make an entry in the list of startup applications:
  • go to System | Preferences | Startup Applications
  • click "Add"
  • give it a name
  • browse to your new file
  • add a description if you want
Hey presto, uShare will now start automatically.