Install SABnzbd on FreeBSD

FreeBSD comes with an extensive ports collection that contains SABnzbd. Unfortunately, even in the latest FreeBSD 8.1 release, it contains SABnzbd v0.4.12 which is old and lacks a lot of cool features. There wasn’t a clear guide on how to upgrade SABnzbd to the latest version, so I decided to find out how it can be done.

What has changed?
I started out with the v0.4.12 port, but I have updated the Makefile, distinfo, so it will download the latest version of SABnzbd (currently v0.5.3). Because the new version uses a different set of files, the pkg-plist file has been updated to match the files in v0.5.3.

The v0.4.12 distribution installed some files in the Python directory, which I don’t like. It’s not a part of Python, so it shouldn’t install files in the Python directories. All SABnzbd related files are now stored in its own directory. On most installations this will be /usr/local/shared/sabnzbdplus. Even the SABnzbd.py file that is used to run the application is now stored inside this directory. A symbolic link will be created during installation from /usr/local/bin to make sure the program can be found.

Two patches are necessary to the SABnzbd.py file. First Python must be told to first look for packages in the SABnzbd directories, because SABnzbd comes with its own version of CherryPy. Another change is that the SABnzbd directory will be hardcoded to the correct path. The original version tries to detect the path automatically, but this fails when you start it from /usr/local/bin.

The last addition that I made was to include an RC-script that allows that SABnzbd can be started as a daemon during system startup.

How to install SABnzbd
The following steps should be performed to download and install SABnzbd on your FreeBSD installation:

  1. Log on with root privileges on your FreeBSD server.
  2. Go to the ports directory.
  3. Fetch the latest version of my distribution.
  4. Unpack the archive and remove the archive itself.
  5. Change to the new SABnzbd directory.
  6. Install the new version and clean up.

In code this looks like:

[root@freebsd /]# cd /usr/ports/news
[root@freebsd /usr/ports/news]# wget http://blog.ramondeklein.nl/wp-content/uploads/2010/07/sabnzbdplus-0.5.3.tar.gz
[root@freebsd /usr/ports/news]# tar -xvzf sabnzbdplus-0.5.3.tar.gz
[root@freebsd /usr/ports/news]# rm sabnzbdplus-0.5.3.tar.gz
[root@freebsd /usr/ports/news]# cd sabnzbdplus-0.5.3
[root@freebsd /usr/ports/news/sabnzbdplus-0.5.3]# make install && make clean

Now you can start SABnzbd by typing SABnzbd.py. Go to http://your-freebsd-server:8080 to check if the server is running correctly. Refer to the SABnzbd manuals for more information about configuring SABnzbd itself.

Read the next paragraphs if you want to run SABnzbd as a daemon with more restrictive privileges.

How to run SABnzbd as a daemon
Add the following lines to your /etc/rc.conf file to make sure it starts during system startup:

# SABnzbd settings
sabnzbd_enable="YES"

The default daemon runs as root, but it is better to run SABnzbd under a less-privileged account. Add the following lines to your /etc/rc.conf file to make sure the daemon runs under the ‘ramon’ account:

# SABnzbd settings
sabnzbd_enable="YES"
sabnzbd_user="ramon"

You don’t need to restart the system to test if the daemon can be started. Type the following command to start the SABnzbd daemon:

/usr/local/etc/rc.d/sabnzbd start

Stopping the daemon can be done using the following command:

/usr/local/etc/rc.d/sabnzbd stop

Always make sure you stop the daemon before you make any changes to the configuration files by hand.

Known issues

  • Make sure you run SABnzbd.py with root privileges at least once. This enables that the compiled versions can be stored. Other users probably don’t have the required privileges to store these files.
  • During deinstallation the compiled Python files are not removed. This result in some error messages. You can delete these files yourself when you deinstall the distribution.

SABnzbd distributions
The following list contains the SABnzbd distributions that I have created:

12 thoughts on “Install SABnzbd on FreeBSD

  1. I used your guide on a fresh 8.1-STABLE and get the following when trying to run SABnzbd.py (I can run the built in 0.4.12 version just fine, but not 0.5.3 after this guide)

    (run as root)

    mediaserver# SABnzbd.py
    Sorry, requires Python module sqlite3 (pysqlite2 in python2.4)
    Try: apt-get install python-pysqlite2

  2. Ha.. update — I realized by doing a pkg_info | grep py26 that I didn’t have py26-sqlite3 installed for whatever reason. I did a ‘make deinstall’ on sab-0.5.3 and then pkg_add -r py26-sqlite3 and then reinstalled sab-0.5.3 and now it’s working fine. :)

  3. Thanks for this, it looks like exactly what I am looking for. I have to ask though, will it work on FreeBSD 7.0? I tried upgrading to 5.3 once before and nearly broke python completely.

  4. I haven’t tested it on any other platform than FreeBSD 8.1, so I don’t know how it will behave on FreeBSD 7.0. I have contacted the ports maintainer for SABnzbd and I will try to submit a patch, so this will be encorporated in the FreeBSD tree. Then it should work fine…

  5. Ok. Thanks.

    I may get a bit impatient and try to install it as soon as my queue is empty, if I do I’ll drop a post in to let you and anyone else know how it went.

  6. Looks like I may have to upgrade to 8.x, my 7.0 won’t install python26 for some reason.

    It’s about time I upgraded anyway.

  7. Hi again

    I have started with a completely fresh install 8.1, and I think I have broken something while trying to get the daemon script working. It was kind-of working initially but I couldn’t get to the webgui either locally or remotely. After one attempt I did ‘#SABnzbd.py stop’ and the startup config web-pages opened in ‘Links’. I used the pages to configure it but since then it won’t start. I have tried removing the sabnzbd.ini and .sabnzbd but the error wont go away.

    I am getting this error when running #SABnzbd.py

    2010-08-17 14:53:33,048::INFO::[_cplogging:55] [17/Aug/2010:14:53:33] ENGINE Bus STARTING
    2010-08-17 14:53:33,051::INFO::[_cplogging:55] [17/Aug/2010:14:53:33] ENGINE Started monitor thread ‘_TimeoutMonitor’.
    2010-08-17 14:53:33,156::ERROR::[_cplogging:55] [17/Aug/2010:14:53:33] ENGINE Error in HTTP server: shutting down
    Traceback (most recent call last):
    File “/usr/local/share/sabnzbdplus/python/cherrypy/process/servers.py”, line 75, in _start_http_thread
    self.httpserver.start()
    File “/usr/local/share/sabnzbdplus/python/cherrypy/wsgiserver/__init__.py”, line 1629, in start
    raise socket.error, msg
    error: [Errno 49] Can’t assign requested address
    2010-08-17 14:53:33,156::INFO::[_cplogging:55] [17/Aug/2010:14:53:33] ENGINE Bus STOPPING

    I have just finished re-installing rtorrent w/rtgui so I can confirm apache, php etc is working.

    Do you have any suggestions?

    Thanks

  8. I gave up and reinstalled your port from scratch.

    You can delete the post above if you like, I’m not sure what happened but it is working now :) It does seem a bit unstable, and for some reason I can’t use a different port for the webgui but for now it is up and running :D

    thanks for the great work

  9. Pingback: Sabnzbdplus på FreeBSD 8.1-RELEASE

  10. Hello, first thank you for the very useful script & guide,
    would you mind updating it for 0.5.4 please? or made it like it can always download the latest version?
    thank you in advance

  11. For those interested, the current version of sabnzbd+ has been bumped to 0.5.4 in FreeBSD 8.1.

    Install ports/www/py-cherrypy first as is a pre-requisite that for some reason isn’t picked up.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>