RaspberryPi Adding SABnzbd, Sick Beard and Couch Potato

por | 4 enero, 2013

http://www.cylindric.net/blog/raspberrypi-adding-sabnzbd-sickbeard-and-couchpotato/

RaspberryPi – rPiDownloader Part 2 – Adding SABnzbd, Sick Beard and Couch Potato

Posted by on August 8, 2012 Leave a comment (32) Go to comments

This is part two of a series showing how to get a Raspberry Pi working as a great little unified downloader-appliance. The aim is to get a system that will provide an easy way of monitoring a collection of TV series for new or old episodes using Sick Beard, grab new movies using Couch Potato, and download them all seamlessly using SABnzbd. The end-result will be a completely web-based easy-to-use appliance!

In this second part, we’ll be adding SABnzbd, Sick Beard and Couch Potato to our Pi…

We’re going to be installing the apps into the /usr/local directory.  The data will be in /var We’ll also create users for each service to keep things nice and safe.

There are some pre-requisites we need first:

sudo apt-get -y install python2.6 python-cheetah python-openssl par2

Some of the apps we’ll be using, especially SABnzbd, are particular about the version of unrar they use, so we should install the non-free ‘official’ version. We need to build that from source (thanks to Anonymous for the steps):

sudo sh -c "echo \"deb-src http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi\" >> /etc/apt/sources.list"
sudo apt-get update
sudo apt-get -y build-dep unrar-nonfree
sudo apt-get source -b unrar-nonfree
sudo dpkg -i unrar*.deb

You’re going to need to know your IP address, and wherever you see the address “172.29.14.110″, replace that with your IP address.

We’re going to use a usergroup for each of the service users, so set that up first:

sudo addgroup nzb

SABnzbd

Now we are ready to grab SABnzbd. Rather than use the full wget URL I’ve used here, go to the SABnzbd SourceForge site and copy the “download now” link from there, to make sure you get the latest “source” version.

Create the user for SABnzbd:

sudo useradd --system --user-group --no-create-home --groups nzb sabnzbd

Download SABnzbd, extract it and move it to the correct location, and set the permissions required:

wget http://downloads.sourceforge.net/project/sabnzbdplus/sabnzbdplus/0.7.3/SABnzbd-0.7.3-src.tar.gz
tar xzf SABnzbd-0.7.3-src.tar.gz
sudo mv SABnzbd-0.7.3 /usr/local/sabnzbd
sudo chown -R sabnzbd:nzb /usr/local/sabnzbd

Create a directory to hold the data:

sudo mkdir /var/sabnzbd
sudo chown sabnzbd:nzb /var/sabnzbd

Try it out (replace the ip address with yours!), this will also create the necessary config files:

sudo su sabnzbd -c "/usr/local/sabnzbd/SABnzbd.py -f /var/sabnzbd -s 172.29.14.110:8080"

You should now be able to point your browser to the SABnzbd address, and complete the wizard. I would strongly recomment You must set a username and password on Step Two, to restrict access. Bear in mind that the rPi has limited resources, so don’t max out the NNTP server connections. For example, my provider allows 50 connections, but just put 5 for the rPi.

Now that all works, press [Ctrl]+[C] to kill the server for now.

Sick Beard

sudo useradd --system --user-group --no-create-home sickbeard
git clone git://github.com/midgetspy/Sick-Beard.git
sudo mv Sick-Beard /usr/local/sickbeard
sudo chown -R sickbeard:nzb /usr/local/sickbeard
sudo chmod ug+rw /usr/local/sickbeard/autoProcessTV/
sudo mkdir /var/sickbeard
sudo chown sickbeard:nzb /var/sickbeard

Fire it up to create the config files and try it:

sudo su sickbeard -c "/usr/local/sickbeard/SickBeard.py --datadir /var/sickbeard --config /var/sickbeard/sickbeard.ini"

Test it! http://172.29.14.110:8081

CouchPotato

sudo useradd --system --user-group --no-create-home couchpotato
git clone git://github.com/RuudBurger/CouchPotatoServer.git
sudo mv CouchPotatoServer /usr/local/couchpotato
sudo chown -R couchpotato:couchpotato /usr/local/couchpotato
sudo mkdir /var/couchpotato
sudo chown -R couchpotato:couchpotato /var/couchpotato
sudo su couchpotato -c "/usr/local/couchpotato/CouchPotato.py --data_dir=/var/couchpotato --config_file=/var/couchpotato/couchpotato.ini"

Test at http://172.29.14.110:5050. Again, [Ctrl]+[C] will terminate it.

Auto-Start

To enable all three services to run automatically at startup, we need to create three init scripts and register them.

SABnzbd

Create an init file by typing the next command, and then copying the following text:

sudo nano /etc/init.d/sabnzbd
#!/bin/sh
### BEGIN INIT INFO
# Provides:          SABnzbd
# Required-Start:    $network $remote_fs $syslog
# Required-Stop:     $network $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start SABnzd at boot time
# Description:       Start SABnzbd.
### END INIT INFO

case "$1" in
start)
  echo "Starting SABnzbd."
  /usr/bin/sudo -u sabnzbd -H /usr/local/sabnzbd/SABnzbd.py -d -f /var/sabnzbd/sabnzbd.ini
;;
stop)
  echo "Shutting down SABnzbd."
  p=`ps aux | grep -v grep | grep SABnzbd.py | tr -s \ | cut -d ' ' -f 2`
  if [ -n "$p" ]; then
    kill -2 $p > /dev/null
    while ps -p $p > /dev/null; do sleep 1; done
  fi
;;
*)
  echo "Usage: $0 {start|stop}"
  exit 1
esac
exit 0
sudo chmod 755 /etc/init.d/sabnzbd
sudo update-rc.d sabnzbd defaults
sudo /etc/init.d/sabnzbd start

Sick Beard

sudo nano /etc/init.d/sickbeard
#!/bin/sh
### BEGIN INIT INFO
# Provides:          SickBeard
# Required-Start:    $network $remote_fs $syslog
# Required-Stop:     $network $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start SickBeard at boot time
# Description:       Start SickBeard.
### END INIT INFO

case "$1" in
start)
  echo "Starting SickBeard."
  /usr/bin/sudo -u sickbeard -H /usr/local/sickbeard/SickBeard.py -d --datadir /var/sickbeard --config /var/sickbeard/sickbeard.ini
;;
stop)
  echo "Shutting down SickBeard."
  p=`ps aux | grep -v grep | grep SickBeard.py | tr -s \ | cut -d ' ' -f 2`
  if [ -n "$p" ]; then
    sb_api_key=`grep -m 1 api_key ${sb_config} | cut -d ' ' -f 3`;
    sb_port=`grep -m 1 web_port ${sb_config} | cut -d ' ' -f 3`;
    wget -q --delete-after http://localhost:${sb_port}/api/${sb_api_key}/\?cmd=sb.shutdown
    while ps -p $p > /dev/null; do sleep 1; done
  fi
;;
*)
  echo "Usage: $0 {start|stop}"
  exit 1
esac

exit 0
sudo chmod 755 /etc/init.d/sickbeard
sudo update-rc.d sickbeard defaults
sudo /etc/init.d/sickbeard start

Couch Potato

sudo nano /etc/init.d/couchpotato
#!/bin/sh
### BEGIN INIT INFO
# Provides: CouchPotato
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start CouchPotato at boot time
# Description: Start CouchPotato.
### END INIT INFO
case "$1" in
start)
 echo "Starting CouchPotato."
 /usr/bin/sudo -u couchpotato -H /usr/local/couchpotato/CouchPotato.py --daemon --data_dirdir=/var/couchpotato --config_file=/var/couchpotato/couchpotato.ini
;;
stop)
 echo "Shutting down CouchPotato."
  p=`ps aux | grep -v grep | grep CouchPotato.py | tr -s \ | cut -d ' ' -f 2`
  couch_api_key=`grep -m 1 api_key /var/couchpotato/couchpotato.ini | cut -d ' ' -f 3`;
  couch_port=`grep -m 1 port /var/couchpotato/couchpotato.ini | cut -d ' ' -f 3`;
 wget -q --delete-after http://localhost:${couch_port}/api/${couch_api_key}/app.shutdown
 while ps -p $p > /dev/null; do sleep 1; done
;;
*)
 echo "Usage: $0 {start|stop}"
 exit 1
esac
exit 0
sudo chmod 755 /etc/init.d/couchpotato
sudo update-rc.d couchpotato defaults
sudo /etc/init.d/couchpotato start

That’s it. That’s the basics sorted. Everything should now be running and working, but nothing is configured specifically for being integrated, or for saving the files to the network. That’s next…

Special thanks to NASDestruction for getting me going, and comments below correcting my mistakes :)

(Edit 27/08/2012: completely changed the Couch Potato section to use the latest version)

Leave a comment ?

32 Comments.

  1. Great tutorial. I would add “apt-get install git-core” just before the sickbeard install as git is not installed from default build.

  2. thanks for the guide!

    two typos:
    1.
    sabnzbd autos tart script has wrong config file path

    2.
    autostart couch patato should read
    sudo nano /etc/init.d/couchpotato

  3. Thanks for sharing!

    sabnzbd seems fairy picky about its unrar though. Here’s how to install the non-free version. Maybe add this rather than suppressing the warning:
    add in /etc/apt/sources.list
    deb-src http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi
    sudo apt-get update
    sudo apt-get build-dep unrar-nonfree
    sudo apt-get source -b unrar-nonfree
    sudo dpkg -i unrar*.deb

  4. Hey mate thanks for the tut.

    But i think you Sabnzbd auto start script doesnt work. You say i have to change the api key in the auto start script but can find that.

    • Ah, sorry about that. I’m still in the process of finalising the scripts. I actually found a way of not needing to enter the API key manually, so use the new script that’s there now.

  5. CouchPotato autostart script

    –data_dirdir=… gives an error. Changed to –data_dir=… and it sorted the situation. Great tutorial. Thanks

  6. Would be nice to also include Headphones in this guide :) although with SickBeard & Couchpotato examples it’s pretty self explanatory.

    sudo useradd –system –user-group –no-create-home headphones
    git clone git://github.com/rembo10/headphones.git
    sudo mv headphones /usr/local/headphones
    sudo chown -R headphones:headphones /usr/local/headphones
    sudo chmod ug+x /usr/local/headphones/Headphones.py
    sudo mkdir /var/headphones
    sudo chown -R headphones:headphones /var/headphones

    sudo su headphones -c “/usr/local/headphones/Headphones.py –datadir=/var/headphones –config=/var/headphones/headphones.ini”

    Test: http://:8181

  7. Thanks for the headphones guide – works great!!
    Can someone please assist with the script / init file to auto start headphones at boot??
    Greatly appreciated

  8. Hello!

    For Headphones auto start:


    cd /usr/local/headphones/
    sudo cp init.ubuntu /etc/init.d/headphones
    sudo chmod +x /etc/init.d/headphones
    sudo update-rc.d headphones defaults

    Hope it helps!
    /Arky

  9. Actually, there is a little change in the script:
    Change

    APP_PATH=/usr/local/sbin/headphones

    To

    APP_PATH=/usr/local/headphones

    Then it will work.

  10. Actually scratch that.

    Here is the script:

    sudo nano /etc/init.d/headphones


    ### BEGIN INIT INFO
    # Provides: headphones
    # Required-Start: $local_fs $network $remote_fs
    # Required-Stop: $local_fs $network $remote_fs
    # Should-Start: $NetworkManager
    # Should-Stop: $NetworkManager
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: starts and stops headphones
    # Description: Automatic music downloader for SABnzbd. For more information see:
    # http://http://headphones.codeshy.com/forum/
    ### END INIT INFO

    #Required — Must Be Changed!
    USER=»xxxxxxx» #Set Linux Mint, Ubuntu, or Debian user name here.

    #Required — Defaults Provided (only change if you know you need to).
    HOST=»XXX.XXX.X.XX» #Set headphones address here.
    PORT=»XXXX» #Set headphones port here.

    #Optional — Unneeded unless you have added a user name and password to Headphones.
    SBUSR=»XXXXXX» #Set Headphones user name (if you use one) here.
    SBPWD=»XXXXXX» #Set Headphones password (if you use one) here.

    #Script — No changes needed below.
    case «$1» in
    start)
    #Start Headphones and send all messages to /dev/null.
    cd /usr/local/headphones
    echo «Starting Headphones»
    sudo su headphones -c «/usr/local/headphones/Headphones.py –datadir=/var/headphones –config=/var/headphones/headphones.ini» > /dev/null 2>&1 &
    ;;
    stop)
    #Shutdown Headphones and delete the index.html files that wget generates.
    echo «Stopping Headphones»
    wget -q –user=$SBUSR –password=$SBPWD «http://$HOST:$PORT/shutdown/» –delete-after
    sleep 6s
    ;;
    *)
    echo «Usage: $0 {start|stop}»
    exit 1
    esac

    exit 0

  11. Sorry to intrude, but i seem to get the following:
    sudo apt-get update
    Err http://mirrordirector.raspbian.org whezzy/main Sources
    404 Not Found
    Err http://mirrordirector.raspbian.org whezzy/contrib Sources
    404 Not Found
    Err http://mirrordirector.raspbian.org whezzy/non-free Sources
    404 Not Found
    Err http://mirrordirector.raspbian.org whezzy/rpi Sources
    404 Not Found
    W: Failed to fetch http://mirrordirector.raspbian.org/raspbian/dists/whezzy/main/source/Sources 404 Not Found

    W: Failed to fetch http://mirrordirector.raspbian.org/raspbian/dists/whezzy/contrib/source/Sources 404 Not Found

    W: Failed to fetch http://mirrordirector.raspbian.org/raspbian/dists/whezzy/non-free/source/Sources 404 Not Found

    W: Failed to fetch http://mirrordirector.raspbian.org/raspbian/dists/whezzy/rpi/source/Sources 404 Not Found

    &

    pi@raspberrypi ~ $ sudo apt-get build-dep unrar-nonfree
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: You must put some ‘source’ URIs in your sources.list
    pi@raspberrypi ~ $ sudo apt-get source -b unrar-nonfree
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: You must put some ‘source’ URIs in your sources.list
    pi@raspberrypi ~ $ sudo dpkg -i unrar*.deb
    dpkg: error processing unrar*.deb (–install):
    cannot access archive: No such file or directory
    Errors were encountered while processing:
    unrar*.deb

    Can you help
    Thanks

  12. One change to the Couch Potato start script. the line

    /usr/bin/sudo -u couchpotato -H /usr/local/couchpotato/CouchPotato.py –daemon –data_dirdir=/var/couchpotato –config_file=/var/couchpotato/couchpotato.ini
    ;;

    the –data_dirdir=/var/couchpotato should be changed to

    –data_dir /var/couchpotato
    as there is an extra dir and the = is not needed. cheers.

  13. Nice tutorial, i changed your init.d scripts slightly to start everything with a nice value of 19, just so it doesn’t slow everything down when they are running.

    e.g.


    /usr/bin/sudo -u sabnzbd -H nice -n 19 /usr/local/sabnzbd/SABnzbd.py -d -f /var/sabnzbd/sabnzbd.ini

  14. For some reason couchpotato is no longer working. when trying to start couchpotato, i get these errors (can anyone help?):

    Starting CouchPotato.
    Traceback (most recent call last):
    File “/usr/local/couchpotato/CouchPotato.py”, line 127, in
    l = Loader()
    File “/usr/local/couchpotato/CouchPotato.py”, line 35, in __init__
    settings.setFile(self.options.config_file)
    File “/usr/local/couchpotato/couchpotato/core/settings/__init__.py”, line 61, in setFile
    self.p.read(config_file)
    File “/usr/lib/python2.7/ConfigParser.py”, line 305, in read
    self._read(fp, filename)
    File “/usr/lib/python2.7/ConfigParser.py”, line 546, in _read
    raise e
    ParsingError: File contains parsing errors: /var/couchpotato/couchpotato.ini
    [line 299]: ‘enab’

    Traceback (most recent call last):
    File “/usr/local/couchpotato/CouchPotato.py”, line 127, in
    l = Loader()
    File “/usr/local/couchpotato/CouchPotato.py”, line 35, in __init__
    settings.setFile(self.options.config_file)
    File “/usr/local/couchpotato/couchpotato/core/settings/__init__.py”, line 61, in setFile
    self.p.read(config_file)
    File “/usr/lib/python2.7/ConfigParser.py”, line 305, in read
    self._read(fp, filename)
    File “/usr/lib/python2.7/ConfigParser.py”, line 546, in _read
    raise e
    ConfigParser.ParsingError: File contains parsing errors: /var/couchpotato/couchpotato.ini
    [line 299]: ‘enab’

    • I had my CP set to send messages to my phone (via Pushover) – got a message the other morning telling my CouchPotato had updated itself to the latest version. Since the update I can’t access it and trying to start it manually gives me similar error messages.

      Log here: http://pastebin.com/tB3YVr9G

    • Sorted.

      SSH into your Pi
      Navigate to /etc/init.d/ and remove the couchpotato file (sudo rm couchpotato)
      Reboot
      Follow the CouchPotato instructions again (ie, create a new, fresh couchpotato file in the /etc/init.d/ directory) – remember to modify the “–data_dirdir=” to “–data_dir=” (remove the extra ‘dir’)

      Worked for me…

  15. In the Sickbeard autostart, sb_config is used but is is never declared?

    At least I can’t find it and the shutdown part of the script gets in an endless loop.
    I replaced it with kill -9 $p;

  16. :?:

    Is SABnzbd also slow on your raspberry pi? When using SSL connections I can only download with ~500kb/s. :-(

    • I Had the same problem, try to increase your server connections to more than 8, and update to latest version

      I have 10mbps and Im downloading with ssl at 948KB/s sysload 1.68 which is great for me.

  17. Hello,

    Im a complete noob on RPI, just got it yesterday but I was wondering, would it be possible to have this setup AND xbmc in the same RPI?

    • You’d be pushing it running it on the same Pi. The best idea would be to setup two and use one for XBMC and one for this.

  18. Having an issue with installing unrar-nonfree. First it was something to do with my public key missing so I ran:

    wget http://archive.raspbian.org/raspbian.public.key -O – | sudo apt-key add –

    That fixed that issue although I seem to be missing the debhelper package required for unrar-nonfree.

    I tried getting this from another repository although I don’t really know what I’m doing.

    Can someone help me with this section please?
    Thanks in advance.