Saturday, October 27, 2012

Installing Couch Potato v2

Ok, here are some basic instructions for installing Couch Potato v2 on Open Media Vault, although they'll probably work for most Debian-based distributions.

Step 1. Download the source code

First, let's create a directory for couchpotato to go.  As with the other pieces of software, I'm going to install it to the /opt directory, but you can put it wherever you want;

sudo mkdir /opt/couchpotato

If you don't already have git installed, then you'll need to install it;

sudo apt-get install git-core

Now download the python code; sudo git clone couchpotato/

Step 2. Create a dedicated user for running Couch Potato

For security reasons, it's nice to run Couch Potato under a dedicated user.  So let's create one;

sudo useradd couchpotato
sudo usermod -d /opt/couchpotato couchpotato
sudo chown -R couchpotato:users /opt/couchpotato

This will create a new user called couchpotato, assign the user to the directory /opt/couchpotato

Step 3. Test Run

We should now be able to do a little test run to see if it is working;

sudo -u couchpotato python /opt/couchpotato/

Now point your browser to the address http://<<yourserver>>:5050

If everything has gone ok, it should be working nicely.  Feel free to play around, make sure everything is working and set things up.  Then when you are ready, shutdown Couch Potato and move to the next step.

Step 4. Configure Couch Potato to start automatically

Couch Potato already has some example startup scripts that we can use.  The ubuntu version will do the trick, so copy it to the init.d directory;

sudo cp /opt/couchpotato/init/ubuntu /etc/init.d/couchpotato

Edit the settings;

sudo nano /etc/init.d/couchpotato

Make sure you set the APP_PATH to where you've got Couch Potato running (/opt/couchpotato in our case), and the RUN_AS to the dedicated user we've created (ie, couchpotato).

Now, wake it executable;

sudo chmod +x /etc/init.d/couchpotato

And as a final step, we need to set the script to be run on startup and shutdown;

sudo update-rc.d couchpotato defaults

By now, Couch Potato should run on startup.  But to start manually, you can run it directly;

sudo ./etc/init.d/couchpotato start

Addendum. Taking Care of Dependencies

This guide assumes you've already done through the steps to install SABnzbd which should mean that any dependencies have probably already been resolved.  If not, you may need to install python;

sudo apt-get install python

Sunday, October 7, 2012

Tweaking Samba Shares for XBMC

If you are like me, you're setting up your OMV server as a means of serving XBMC or something similar. However, in addition to feeding movies and music to my XBMC media player, I also like to browse my media collection via windows explorer (or the Finder on a Mac). The problem is that a lot of media players collect various supplementary files, like *.nfo files or *.jpg files for folder art. When browsing via samba, these tend to "mess" things up. I did a bit of research into samba to see if there was a neat way to configure things nicely.

The "hide" and "veto" options in samba

So when configuring a samba share, it is possible to make certain files "hidden" using the "hide files" instruction. This simulates checking the "hidden" attribute in windows. For example;

hide files = /*.tbn/*.nfo/*.jpg*/*.jpeg/

Note that each file or folder type to be hidden must be separated with a backslash (/) and that you also need backslashes at the start end end. In OMV, you can put this instruction in SMB/CIFS->Settings->Extra Options, and it will apply to ALL samba shares. Alternatively, if you want to only hide certain files per share, you can find a similar place under Edit Share->Extra Options. If you aren't using OMV you can still add this configuration, just place it in your smb.conf file (in /etc/samba/) either under [global] or under a specific share.


However, if you browse the samba share via a Mac, this won't work since OSX doesn't use the same approach for hiding files and doesn't have a "hidden" attribute. So as an alternative, you can use the "veto files" command. This instruction is handled in a similar way, and can placed in the same spot when configuring samba in OMV. For example;

veto files = /*.tbn/*.nfo/*.jpg*/*.jpeg/

However, instead of simply hiding your files, they are no longer shared. Now when you go to your shares, you won't see these files at all. Though, they still exist on the server.

Getting funky

The problem with this approach is that your media player needs to see these files. So vetoing them is counter-productive. What we want is to veto certain files, but only at certain times. Hrm...

A reasonably simply approach to this might be to configure things on a per-user basis. This is a little bit trickier, but still relatively easy. In OMV, we go back to configuring our shares and remove any references to either "hide" or "veto". Instead, we insert into Extra Options the following;

include = /etc/samba/smb.conf.%U

Again, this can be done either globally, or on a per-share basis. Basically, this instruction asks samba to look for additional configuration details whenever a user, %U, accesses a samba share. For example, if you have a user called Joe Smith, with a username jsmith and you want additional samba configurations specific to Joe, then create a file called /etc/samba/smb.conf.jsmith and put your instructions there. If samba cannot find a user-specific configuration file, then it ignores the include instruction. If you are using guest accounts in samba, then %U will be guest (ie, smb.conf.guest).

In OMV, the only way to add this additional configuration is to ssh to your server and create the file by hand.

Putting it together

Most users log into my media server with a guest account. So I've created a file called /etc/samba/smb.conf.guest which includes a single configuration;

veto files = / *.tbn / *.xml / *.jpg* / *.jpeg / *.png / *.nfo / .actors / metadata / Thumbs.db / extrafanart / extrathumbs / *.srr / *.sfv / *.nfo-orig /

I've then added the following include;

include = /etc/samba/smb.conf.%U

For both my Movies and TV shares, but not for any other shares.In addition, I've created a user specifically for XBMC, with the username xbmc. This user has access to all the media folders and sees all the content in these folders. As such, there is no need for a specific smb.conf.xbmc file.