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 https://github.com/RuudBurger/CouchPotatoServer.git 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/CouchPotato.py

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

9 comments:

  1. i have a syntax error with the command
    sudo usermod -d /opt/couchpotato
    what's wrong?

    ReplyDelete
  2. opps

    I think it should be;

    sudo usermod -d /opt/couchpotato couchpotato

    ReplyDelete
  3. thanks
    and now
    but next on Step 3
    i have this message
    sudo -u couchpotato python /couchpotato/CouchPotato.py
    python: can't open file '/couchpotato/CouchPotato.py': [Errno 2] No such file or directory

    when i use "cd" the py file exists..

    ReplyDelete
  4. and when i try
    sudo -u couchpotato python opt/couchpotato/CouchPotato.py

    its the same

    ReplyDelete
  5. Hi Julien,

    The command should be

    sudo -u couchpotato python /opt/couchpotato/CouchPotato.py

    Note the leading slash.

    ReplyDelete
  6. Alternatively, of course, if you are already in the couchpotato directory you can just run;

    sudo -u couchpotato python CouchPotato.py

    ReplyDelete
  7. arf sorry, next bug
    when i am already in the couchpotato directory, i have this :
    sudo -u couchpotato python CouchPotato.py
    Traceback (most recent call last):
    File "CouchPotato.py", line 20, in
    from couchpotato.environment import Env
    File "couchpotato/__init__.py", line 1, in
    from couchpotato.api import api_docs, api_docs_missing
    File "couchpotato/api.py", line 1, in
    from flask.blueprints import Blueprint
    ImportError: No module named flask.blueprints

    :((((

    ReplyDelete
  8. Hmm...

    Have a look here,
    https://github.com/RuudBurger/CouchPotatoServer/issues/827

    Looks like you are missing some of the couchpotato modules. Maybe try re-running the steps from start, particularly downloading (cloning) the couchpotato files.

    ReplyDelete
  9. i am turning crazy...
    Impossible i have repeat all the steps and it's always the same

    ReplyDelete