Page 1 of 1

Quick howto: SABnzbd on CentOS 5.x

Posted: July 10th, 2010, 5:22 am
by lennardw
Hi,

Here is a small howto on making SABnzbd work on CentOS 5.x (and therefore should also work on any other Red Hat like Distro). I'm not going to chew out everything in complete detail. Since you're using CentOS I'm assuming you have at least some basic experience with Linux.

CentOS uses python 2.4 for almost of it's internal scriping functions (like yum and the likes). Since python 2.4 is quite ancient (oldest man-pages were on clay tablets  :o ), it's better to also install python 2.6 next to it. This can be accomplished by installing it from EPEL. I'm not going to chew out how to how to install the EPEL repositories. Everything you need should be right here: http://fedoraproject.org/wiki/EPEL . (though always remember that it might be handy to use the yum priorities plug-in (Google it if you don't know what I'm talking about)

As root:
* To install python 2.6 and the python-yenc to increase SABnzbd's efficiency

Code: Select all

yum install python26 python-yenc

* Create a user for SABnzbd and su to that user

As your SABnzbd user:
* Download the latest version of SABnzbd to that home directory and unpack the directory
* Create a symlink This will make it easier for upgrades. Something like:

Code: Select all

 ln -s SABnzbd-0.5.3 sabnzbd 
* Create the directory .sabnzbd if it doesn't exist already
* Create a symlink for the ini-file. Something like:

Code: Select all

ln -s sabnzbd/sabnzbd.ini .sabnzbd/sabnzbd.ini
* Fire up SABnzbd once using:

Code: Select all

python26 sabnzbd/sabnzbd.py -d -f .sabnzbd/sabnzbd.ini
* Go to the options page, do your settings and all and take note of the API-key that has been generated or generate a new one
* Shut down SABnzbd using the web interface.

As root:
* Create a new stop-start script for SABnzbd (make the config adjustments for your system - It should be self-explainatory)

Code: Select all


#!/bin/bash
#
# chkconfig: - 16 84
# description: Start up SABnzbd
#
# processname: SABnzbd
#

# source function library
. /etc/rc.d/init.d/functions

# Get network config
. /etc/sysconfig/network

# Defaults
PATH=/usr/bin:/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin
PYTHON_LOCATION="/usr/bin/python26"

# Daemon info
DAEMON_USER="YOUR SABNZBD USER"
DAEMON_HOME="/home/$DAEMON_USER"
DAEMON_LOCATION="$DAEMON_HOME/sabnzbd/SABnzbd.py"
DAEMON_INIFILE="$DAEMON_HOME/.sabnzbd/sabnzbd.ini"
DAEMON_ARGS="-d -f $DAEMON_INIFILE"
DAEMON_URL="YOUR SABNZBD URL"
DAEMON_API="YOUR SABNZBD API KEY"

# For if you secured your web interface with a username and password
DAEMON_USEPASS="no"
DAEMON_USER="sabnzbd"
DAEMON_PASS="sabpass"

case "$1" in
start)
  echo "Starting SABnzbd."
  /usr/bin/sudo -u $DAEMON_USER -H $PYTHON_LOCATION $DAEMON_LOCATION $DAEMON_ARGS
;;
stop)
  echo "Shutting down SABnzbd."
  if [ $DAEMON_USEPASS == "yes" ]; then
  /usr/bin/wget -q --delete-after "$DAEMON_URL/sabnzbd/api?mode=shutdown&ma_username=$DAEMON_USER&ma_password=$DAEMON_PASS&apikey=$DAEMON_API"
  else
  /usr/bin/wget -q --delete-after "$DAEMON_URL/sabnzbd/api?mode=shutdown&apikey=$DAEMON_API"
  fi
;;
*)
  echo "Usage: $0 {start|stop}"
  exit 1
esac

exit 0
* then make it start and stop with your box if you want it to

Code: Select all

chkconfig SABnzbd on
(change SABnzbd to what you called your stop/start script)

All done  ;)
Just fire up your nice and shiny SABnzbd install using the service command and download all those legal Linux ISO's and the likes.



When upgrading: Just unpack it next to your previous version and change the symbolic link from the old to the new version!! This should always work unless the SABnzbd developers make EPIC changes to the config file.

Re: Quick howto: SABnzbd on CentOS 5.x

Posted: August 17th, 2012, 2:06 pm
by xgmranti
In CentOS 6.3 I made a few changes to get it going to the point of being able to start it with

Code: Select all

service sabnzbd start
Changed this from 'python26'

Code: Select all

PYTHON_LOCATION="/usr/bin/python2.6"
Changed the two variables because DAEMON_USER was interfering with the other variable at the top

Code: Select all

DAEMON_WEBUSER="sabnzbd"
DAEMON_WEBPASS="sabpass"
Changed to match the changed variables

Code: Select all

/usr/bin/wget -q --delete-after "$DAEMON_URL/sabnzbd/api?mode=shutdown&ma_username=$DAEMON_WEBUSER&ma_password=$DAEMON_WEBPASS&apikey=$DAEMON_API"
Thanks for getting me this far, I'll post when I figure out the rest.

Re: Quick howto: SABnzbd on CentOS 5.x

Posted: January 12th, 2014, 12:09 pm
by cyberk
The updated script in this post should really replace the one on the tutorial! Thank you both for the tutorial, I was able to get everything running and learned more about linux too!