Tuesday, 21 September 2010

Script for installing SABnzbd on FreeNAS 0.7.1

1. Copy this text into a new text file and save as sabnzbd.sh


Script:

#!/bin/bash

#Define the architeture of the box
arch=`uname -m`
echo "      *******Archeticture of Machine is" $arch "*******"

echo
#Pull latest version number and assign to variable and then display it
stable=($(fetch -q -o - http://sabnzbdplus.sourceforge.net/version/latest | awk '/0/{gsub(/\015/,"");print}'))
beta=($(fetch -q -o - http://sabnzbdplus.sourceforge.net/version/latest | awk '/2/{gsub(/\015/,"");print}'))
echo "         Latest SABnzbd Stable version is: $stable"
echo "         Latest SABnzbd Beta version is: $beta"

#Menu
echo ""
echo "          Which Version do you wish to Install?"
echo "          ----- ------- -- --- ---- -- --------"
echo
echo "[1] Upgrade/Install SABnzbd 0.5.0 (tested good)"
echo "[2] Upgrade/Install latest STABLE SABnzbd $stable"
echo "[3] Upgrade/Install lastest BETA SABnzbd $beta"
echo "[4] Exit"
echo

#Reads the input user puts in assigns to "option"
read option

#Acts upon what user entered
case "$option" in
  "1")
echo 
echo "*******Selected Option 1: SABnzbd 0.5.0 (tested good)*******"
echo
echo "Downloading SABnzbd 0.5.0"
fetch "http://downloads.sourceforge.net/project/sabnzbdplus/sabnzbdplus/sabnzbd-0.5.0/SABnzbd-0.5.0-src.tar.gz"
;;

  "2")
echo 
echo "*******Selected Option 2: Latest STABLE SABnzbd $stable*******"
echo
echo "Downloading latest STABLE SABnzbd $stable"
fetch http://downloads.sourceforge.net/project/sabnzbdplus/sabnzbdplus/sabnzbd-${stable}/SABnzbd-${stable}-src.tar.gz
;;
  
  "3")
echo 
echo "*******Selected Option 2: Latest BETA SABnzbd $beta*******"
echo
echo "Downloading latest BETA SABnzbd ($beta)"
fetch http://downloads.sourceforge.net/project/sabnzbdplus/sabnzbdplus-beta/${beta}/SABnzbd-${beta}-src.tar.gz
;;
 "4")
echo
echo "Exiting"
exit
;;
    * )
echo
echo "Wrong selection nothing selected"
echo "Exiting"
exit
;;
esac

echo
echo
#Continues with script
echo "*******1. Installing the required prerequisites*******"
echo "--Installing SABnzb (0.4.8)--"
pkg_add -r sabnzbdplus
echo "--Installing py25-yenc--"
pkg_add -r py25-yenc
echo "--Installing unzip--"
pkg_add -r unzip
echo "--Installing py25-pysqlite-2.3.5--"
pkg_add -r "ftp://ftp.freebsd.org/pub/FreeBSD/ports/$arch/packages-7.2-release/All/py25-pysqlite-2.3.5.tbz"
echo "--Starting SABnzbd (to generate config file)--"
/usr/local/bin/SABnzbd.py -d -f /root/.sabnzbd/sabnzbd.ini
echo "--Shutting down SABnzb--"
/usr/bin/fetch "http://localhost:8080/sabnzbd/api?mode=shutdown"
echo "*******2. Removing outdated files/folders*******"
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
echo "--done--"
echo "*******3. Extracting updated version of SABnzbd*******"
cd /root/
echo "--Extracting upgrade--"
tar -xzf SABnzbd*
echo "--Extracted upgrade--"
cd SABnzbd*
echo "--done--"
echo "*******4. Moving/Installing newer version of SABnzbd*******"
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
echo "--done--"
echo "*******5. Deleting extra files*******"
cd /root/
rm  SABnzbd*.gz
rm -rf SABnzbd*
echo "--done--"
echo "*******Done - SABnzbd should be installed*******"


Copy the file onto your FreeNAS box on one of the shares you setup.

Run the script from the command line.

Follow my other post on how to create and run scripts on FreeNAS.




No comments:

Post a Comment