Thursday 23 September 2010

How to install SABnzbd+ on FreeNAS (Official Guide)

Installing Sabnzbd

This guide was written using FreeNAS i386 0.69 and VirtualBox 3.2.4 r62467. The steps involved should all work on the latest version of FreeNAS, but your mileage may vary.

Prerequisites

This guide has been written for users with no knowledge of BSD and who don't have or necessarily know how to use SSH. If there is something in this guide that is unclear please correct it. This guide assumes you know what Sabnzbd is. If not, why are you trying to install it?
You will need about 500MB free on the OS partition (/) as the Python install requires around 500MB of temporary disk space. The final usage after this procedure will be about 150MB. You will also need your FreeNAS server configured with a static IP (not DHCP) to use Sabnzbd.

Procedure

Adding par2cmdline1. Install the following packages. In the Web GUI go to System → Packages and click the +. Add each of the listed packages using the interface here. Because of their dependencies you will need to add them in the order below. An archive of all the required packages can be downloaded here.1) If the addition of a package is successful you should see something like the image on the right.
  • par2cmdline
  • python25
  • py25-elementtree
  • py25-cElementTree
  • py25-chardet
  • py25-setuptools
  • py25-cheetah
  • py25-cherrypy-old
  • py25-feedparser
  • py25-openssl
  • py25-utils
  • unrar
  • unzip
  • sabnzbdplus
All Sabnzbd Dependencies Added
2. Create a new user to run Sabnzbd. It's a security risk to run Sabnzbd as root, which is what most tutorials advise you to do. Using the Web GUI go to Access → Users and Groups and add a new user called sabuser. Set their primary group as admin, home directory as /home/sabuser and check give full shell access to user. Make sure you click the Apply Changes button after this to create the user.Create New User
3. Allow the new user to write to the temporary directory. When you upload an NZB file via the web interface, Sabnzbd saves the NZB to /tmp while working with it. Using the Web GUI go to Advanced → Command. Enter chmod o+w /tmp and click the Execute button. If all goes well this command will return nothing.Chmod Output
4. Run Sabnzbd once to generate the configuration settings. Using the Web GUI go to Advanced → Command. Enter the command su - sabuser -c "/usr/local/bin/SABnzbd.py -d -f /home/sabuser/.sabnzbd/sabnzbd.ini". This should return nothing as shown below.Sabnzbd Start
Now we need to stop the Sabnzbd process that's running in the background. Using the command interface run the command ps aux | grep sabuser and note the process ID in the second field on the line beginning with sabuser.Ps Output
Next run the command kill pid, replacing pid with the ID you noted in the output of ps aux | grep sabuser. If all goes well this will return nothing.Kill Output
5. Edit the Sabnzbd configuration file to insert your server's IP. Using the Web GUI go to Advanced → File Editor and load the file /home/sabuser/.sabnzbd/sabnzbd.ini. Locate the line the reads ”host = localhost” and change this to read ”host = IP” where IP is your server's IP address. In my example, my server is 10.2.64.251. Click the Save button after you have made this change.Editing Sabnzbd Configuration
6. Add a PostInit command to start Sabnzbd. Using the Web GUI go to System → Advanced → Command Scripts. Add a PostInit command that does su - sabuser -c "/usr/local/bin/SABnzbd.py -d -f /home/sabuser/.sabnzbd/sabnzbd.ini" as shown in the screenshot.2)PostInit Command
7. Start Sabnzbd. To do this you can either restart your FreeNAS server (which will trigger the PostInit command) or go to Advanced → Command and execute su - sabuser -c "/usr/local/bin/SABnzbd.py -d -f /home/sabuser/.sabnzbd/sabnzbd.ini" again.
And you're done! You can access the web interface for Sabnzbd at http://IP:8080/sabnzbd where IP is your server's IP address. You can make any other changes to the Sabnzbd configuration through this interface.
1) If you are using a later version of FreeNAS than 0.69 you will need to add the appropriate packages for your underlying FreeBSD version and architecture. That is beyond the scope of this tutorial.
2) At this point most guides direct you to create a Shutdown command to exit Sabnzbd when your server is shutting down. All the commands I have seen recommended are incorrect, but moreover this step is not necessary. Sabnzbd correctly catches SIGTERM when your server is shutting down and exits cleanly.

Wednesday 22 September 2010

How to add SABnzbd+ to FreeNAS WebGUI

This little script will add a menu item to your FreeNAS WebGUI.





Open an SSH session to your FreeNAS box - (ssh root@192.168.1.250)

code: 
cd /rootfetch -o /root/sabnzbd.zip "http://sourceforge.net/apps/phpbb/freenas/download/file.php?id=517&sid=23ce6d53f6505e04088e4543ba1e84c1"unzip sabnzbd.zipchmod 0555 ./SABnzbdExt/sabnzbd.sh./SABnzbdExt/sabnzbd.sh


If your server is on a port, something other than 8080, you will need to edit the extensions_sabnzbd.php  file. 


CODE: 
cd /rootnano ./SABnzbdExt/sabnzbd/extensions_sabnzbd.php

..........

Tuesday 21 September 2010

How to install SABnzbd 0.5.4 on FreeNAS v0.7.1

Assuming IP of Freenas = 192.168.1.5
Assuming port of SABnzbd = 8080 (default per sabnzbd)
Assume that the everything is done through SSH unless mentioned otherwise.
This is for Full install only - embedded see this thread:https://sourceforge.net/apps/phpbb/freenas/viewtopic.php?f=15&t=4179
See Post #2 for some tricks and tips

Tested with FreeNAS 0.7.1 i386. The script should now fully support all architectures. 

The script has 3 options: Know good (hard coded link), latest stable version (dynamically updates when the script runs), latest beta version (same thing auto updates). All of these options should upgrade gracefully (go from stable to latest beta) and MAY downgrade gracefully.

Updated: 04/26/10

Credits: Grail (from LinuxQuestions), Ethan Spoelstra (ewspoelstra@computerphreaks.com)

Quick and easy method:

CODE: 
cd /root
fetch -o /root/sab.sh "https://sourceforge.net/apps/phpbb/freenas/download/file.php?id=1237"
chmod 0555 sab.sh
./sab.sh

....


output from above commands: 
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994 The Regents of the University of California.  All rights reserved. Welcome to FreeNAS! server:~# cd /root/server:~# fetch -o /root/sab.sh "https://sourceforge.net/apps/phpbb/freenas/download/file.php?id=1237" /root/sab.sh                                  100% of 3644  B 4639 kBpsserver:~# server:~# chmod 0555 sab.shserver:~# ./sab.sh      *******Archeticture of Machine is amd64 *******          Latest SABnzbd Stable version is: 0.5.4         Latest SABnzbd Beta version is:            Which Version do you wish to Install?          ----- ------- -- --- ---- -- -------- [1] Upgrade/Install SABnzbd 0.5.0 (tested good)[2] Upgrade/Install latest STABLE SABnzbd 0.5.4[3] Upgrade/Install lastest BETA SABnzbd [4] Exit 2 *******Selected Option 2: Latest STABLE SABnzbd 0.5.4******* Downloading latest STABLE SABnzbd 0.5.4SABnzbd-0.5.4-src.tar.gz                      100% of 1376 kB 1514 kBps *******1. Installing the required prerequisites*******--Installing SABnzb (0.4.8)--Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.2-release/Latest/sabnzbdplus.tbz... Done.Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.2-release/All/python25-2.5.4_1.tbz... Done. ====Note that some of the standard modules are provided as separateports since they require extra dependencies: bsddb           databases/py-bsddbgdbm            databases/py-gdbmsqlite3 databases/py-sqlite3tkinter         x11-toolkits/py-tkinter Install them as needed.==== Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.2-release/All/py25-openssl-0.8_1.tbz... Done.Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.2-release/All/py25-cherrypy-old-2.3.0,1.tbz... Done.Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.2-release/All/py25-chardet-1.0.1.tbz... Done.Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.2-release/All/py25-feedparser-4.1_2.tbz... Done.Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.2-release/All/py25-utils-0.3.0.tbz... Done.Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.2-release/All/py25-setuptools-0.6c9.tbz... Done.Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.2-release/All/py25-elementtree-1.2.6.tbz... Done.Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.2-release/All/py25-cheetah-2.0.1.tbz... Done.Processing Cheetah-2.0.1-py2.5-freebsd-7.2-RELEASE-amd64.eggAdding Cheetah 2.0.1 to easy-install.pth fileInstalling cheetah-compile script to /usr/local/binInstalling cheetah script to /usr/local/bin Installed /usr/local/lib/python2.5/site-packages/Cheetah-2.0.1-py2.5-freebsd-7.2-RELEASE-amd64.eggFetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.2-release/All/py25-cElementTree-1.0.5_1.tbz... Done.Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.2-release/All/unrar-3.80,5.tbz... Done.Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.2-release/All/par2cmdline-0.4_2.tbz... Done.--Installing py25-yenc--Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.2-release/Latest/py25-yenc.tbz... Done.--Installing unzip--Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.2-release/Latest/unzip.tbz... Done.--Installing py25-pysqlite-2.3.5--Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.2-release/All/py25-pysqlite-2.3.5.tbz... Done.Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.2-release/All/pkg-config-0.23_1.tbz... Done.Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.2-release/All/sqlite3-3.6.11.tbz... Done.--Starting SABnzbd (to generate config file)----Shutting down SABnzb--fetch: http://localhost:8080/sabnzbd/api?mode=shutdown: Connection refused*******2. Removing outdated files/folders*******--done--*******3. Extracting updated version of SABnzbd*******--Extracting upgrade----Extracted upgrade----done--*******4. Moving/Installing newer version of SABnzbd*******--done--*******5. Deleting extra files*******--done--*******Done - SABnzbd should be installed*******




Then do steps 6-8 from below:

Manual Method (may work better for some):
1. Installing the required prerequisites (and generating config file)

CODE: 
pkg_add -r sabnzbdplus
pkg_add -r py25-yenc
pkg_add -r unzip
pkg_add -r "ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-7.2-release/All/py25-pysqlite-2.3.5.tbz"
/usr/local/bin/SABnzbd.py -d -f /root/.sabnzbd/sabnzbd.ini 
/usr/bin/fetch "http://localhost:8080/sabnzbd/api?mode=shutdown"

2. Removing outdated files/folders

CODE: 
rm -rf /usr/local/lib/python2.5/site-packages/cherrypy
rm -rf /usr/local/lib/python2.5/site-packages/sabnzbd
rm -rf /usr/local/share/sabnzbdplus/interfaces
rm -rf /usr/local/share/sabnzbdplus/language
rm -rf /usr/local/bin/SABnzbd.py

3. Downloading upgraded version of SABnzbd (0.5.0) and extracting

CODE: 
cd /root/
fetch "http://downloads.sourceforge.net/project/sabnzbdplus/sabnzbdplus/sabnzbd-0.5.0/SABnzbd-0.5.0-src.tar.gz"
tar -xzf SABnzbd*
cd SABnzbd*

4. Moving/Installing newer version of SABnzbd

CODE: 
mv cherrypy /usr/local/lib/python2.5/site-packages/cherrypy
mv sabnzbd /usr/local/lib/python2.5/site-packages/sabnzbd
mv interfaces /usr/local/share/sabnzbdplus/interfaces
mv language /usr/local/share/sabnzbdplus/language
mv SABnzbd.py /usr/local/bin/SABnzbd.py
chmod 0555 /usr/local/bin/SABnzbd.py
ln -s /usr/local/bin/python2.5 /usr/bin/python
ln -s /usr/local/share/sabnzbdplus/interfaces /usr/local/bin/interfaces
ln -s /usr/local/share/sabnzbdplus/language /usr/local/bin/language

5. Deleting extra files

CODE: 
cd /root/
rm  SABnzbd*.gz
rm -rf SABnzbd*

SABnzbd in now installed. We now need to configure a few minor things:

6. Set proper IP in sabnzbd.ini

CODE: 
nano /root/.sabnzbd/sabnzbd.ini
Replace the localhost in the "host =" spot to be your freenas box IP. Would look like this:
/root/.sabnzbd/sabnzbd.ini wrote:host = 192.168.1.5

7. Start updated SABnzbd for the first time
From SSH run the following command
CODE: 
/usr/local/bin/SABnzbd.py -d -f /root/.sabnzbd/sabnzbd.ini
Access SABnzbd via the following address (on your desktop machine): http://192.168.1.5:8080/sabnzbd
Go through the basic install wizard. Once completed it will update the sabnzbd.ini file (config file)

8. Add startup and shutdown scripts (so FreeNAS knows to turn SABnzbd on and off)
Obtain your unique SABnzbd "API Key" from this page: http://192.168.1.5:8080/sabnzbd/config/general/ - Add this key to the SHUTDOWN command below (where it say APIKEY; replace it with your API key)
Add the following entries to your System|Advanced|Command scripts section of FreeNAS web interface (http://192.168.1.5/system_rc.php):
Type: POSTINIT
CODE: 
/usr/local/bin/SABnzbd.py -d -f /root/.sabnzbd/sabnzbd.ini
Type: Shutdown
CODE:
/usr/bin/fetch "http://192.168.1.5:8080/sabnzbd/shutdown?session=APIKEY" >/dev/null



Script version of commands 1-5 (6-8 need to be done by hand)

 sab.sh
(3.56 KiB) Downloaded 1153 times