Page 1 of 1

Debian (Lenny/any) install script

Posted: January 2nd, 2011, 2:08 am
by bluechip
As root:
# cut and paste this in to a file (Eg. /root/setup_sabnzbd.sh )
# set execute privs: chmod 744 /root/setup_sabnzbd.sh
# run it: /root/setup_sabnzbd.sh

It will (should) automatically download the latest version and install it
...With luck you now have sab installed and running

Feel free to change PORT and PORTS (port-Secure) to any values you wish (they must be different) -
both values must be in the range 1025-65535 (1-1024 can only be used by root - and for security we will not run as root)
You can also safely edit the CACHE and DESTination directories (if you care.)

This is NOT intended to be worthy of a POSTINST script - but it /does/ contain eveything you need to know to write one :)

Code: Select all

#!/bin/bash

PORT=5481
PORTS=5485
CACHE=/var/cache
DEST=/usr/share

PKG=`wget -q http://sabnzbd.org/download/ -O - | \
     grep sourceforge\.net | grep Linux | \
     sed 's/.*href=\"\(.*\)\".*/\1/'`

LCL=$CACHE/`echo $PKG | sed 's/.*\(SAB.*\.gz\).*/\1/'`

wget -q $PKG -O $LCL

( cd $DEST && tar -xzf $LCL )

DIR=`ls -d $DEST/SABnzbd*`
mv $DIR $DEST/sabnzbd

apt-get install python2.5 python-cheetah python-yenc python-pyopenssl \
                par2 unrar unzip sudo

adduser --disabled-login --gecos ,,,, --no-create-home sabnzbd
mkdir /home/sabnzbd
chown sabnzbd:sabnzbd /home/sabnzbd

sudo -u sabnzbd -H -- \
  $DEST/sabnzbd/SABnzbd.py -b 0 -d -f /home/sabnzbd/.sabnzbd/sabnzbd.ini \
  -s 0.0.0.0:$PORT --https $PORTS

APIKEY=
while [ x$APIKEY == x ]; do
  APIKEY=`grep ^api_key /home/sabnzbd/.sabnzbd/sabnzbd.ini | \
          sed 's/.*=\(.*\)/\1/' | sed 's/\ //g'`
  echo -n "." ; sleep 1
done
echo ""

wget -q --delete-after \
  "http://127.0.0.1:$PORT/sabnzbd/api?mode=shutdown&apikey=$APIKEY"

cat <<EOF >/etc/init.d/sabnzbd
#!/bin/bash

case "\$1" in
  start)
    echo "Starting SABnzbd."
    /usr/bin/sudo -u sabnzbd -H -- \\
      $DEST/sabnzbd/SABnzbd.py -b 0 -d \\
      -f /home/sabnzbd/.sabnzbd/sabnzbd.ini
    ;;

  stop)
    echo "Shutting down SABnzbd."
    PORT=`grep ^port\  /home/sabnzbd/.sabnzbd/sabnzbd.ini | \
          sed 's/.*=\(.*\)/\1/' | sed 's/\ //g'`
    APIKEY=`grep ^api_key /home/sabnzbd/.sabnzbd/sabnzbd.ini | \
            sed 's/.*=\(.*\)/\1/' | sed 's/\ //g'`
    /usr/bin/wget -q --delete-after \\
      "http://127.0.0.1:\$PORT/sabnzbd/api?mode=shutdown&apikey=\$APIKEY"
    ;;

  *)
    echo "Usage: \$0 {start|stop}"
    exit 1
esac

exit 0
EOF
chmod 755 /etc/init.d/sabnzbd

ln -s -f /etc/init.d/sabnzbd /etc/rcS.d/S60sabnzbd

/etc/init.d/sabnzbd start

echo -e "\nSAB can now be found at http://127.0.0.1:$PORT or https://127.0.0.1:$PORTS"

Edit: s/unrar-free/unrar/ ... free version lacks certain features [see below]

Re: Debian (Lenny/any) install script

Posted: January 2nd, 2011, 2:10 am
by bluechip
Oh, and in case you want one ...this is a script which you might find useful if you want to remove SAB or write the PRERM script

Code: Select all

#!/bin/bash

/etc/init.d/sabnzbd stop
rm -f /etc/init.d/sabnzbd
rm -f /etc/rcS.d/S60sabnzbd
rm -rf /home/sabnzbd
deluser sabnzbd
rm -rf /usr/share/sabnzbd
rm -f /var/cache/SABnzbd*

Re: Debian (Lenny/any) install script

Posted: January 16th, 2012, 9:54 pm
by jeff10011
Hi,

I am trying to install Sabnzbd on my My Book Live. I am a noob but I managed to copy the script you provided to the root folder. However, once I run the script things seem to fall apart. Any help you could provide would really be appreciated.

Thanks!

Here is the printout from terminal


Media:~# sh setup_sabnzbd.sh
Reading package lists... Done
Building dependency tree
Reading state information... Done
python2.5 is already the newest version.
E: Couldn't find package python-cheetah
adduser: The user `sabnzbd' already exists.
mkdir: cannot create directory `/home/sabnzbd': File exists
chown: invalid group: `sabnzbd:sabnzbd'
sudo: unable to execute /usr/share/sabnzbd/SABnzbd.py: Permission denied
grep: /home/sabnzbd/.sabnzbd/sabnzbd.ini: No such file or directory

Re: Debian (Lenny/any) install script

Posted: January 16th, 2012, 10:08 pm
by bluechip
everything from "adduser:" onwards are errors (probably) caused by running the install script twice without running the uninstall script in the middle
...somehow you have a used on your system called sabnzbd - this is the desired start-point
The lack of the package: python-cheetah is concerning - maybe sab no longer needs this? maybe it no longer exists? ...bit of research required on your behalf there ...you will need to start by knowing what OS you're running and then do a package search

Re: Debian (Lenny/any) install script

Posted: January 16th, 2012, 10:49 pm
by jeff10011
Thank you very much for the speedy reply. I think I have been able to solve most of the issues thanks to your advice but I seem to still be encounter one. For some reason it won't create sabnzbd directory.

Code: Select all

Media:~# sh setup_sabnzbd.sh
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python2.5 is already the newest version.
python-cheetah is already the newest version.
python-yenc is already the newest version.
Note, selecting python-openssl instead of python-pyopenssl
python-openssl is already the newest version.
par2 is already the newest version.
unrar-free is already the newest version.
unzip is already the newest version.
sudo is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 253 not upgraded.
Adding user `sabnzbd' ...
Adding new group `sabnzbd' (1003) ...
Adding new user `sabnzbd' (1001) with group `sabnzbd' ...
Not creating home directory `/home/sabnzbd'.
grep: /home/sabnzbd/.sabnzbd/sabnzbd.ini: No such file or directory

Re: Debian (Lenny/any) install script

Posted: January 17th, 2012, 9:30 am
by bluechip
Take a look in the script at these two lines:

Code: Select all

adduser --disabled-login --gecos ,,,, --no-create-home sabnzbd
mkdir /home/sabnzbd
You may also wish to type `ls /home` and notice that the directory has been made :/

Re: Debian (Lenny/any) install script

Posted: January 17th, 2012, 11:15 am
by jcfp
bluechip wrote:[...]
apt-get install python2.5 python-cheetah python-yenc python-pyopenssl \
                par2 unrar-free unzip sudo
[...]
You want the non-free unrar (or rar) there for use with sab and usenet, not "unrar-free".

Re: Debian (Lenny/any) install script

Posted: January 19th, 2012, 11:43 am
by bluechip
jcfp wrote:You want the non-free unrar (or rar) there for use with sab and usenet, not "unrar-free".
May I ask why `unrar-free` is not suitable?
I notice that `unrar-free` "Can't handle some archives in the RAR 3.0 format" [cite: http://packages.debian.org/sid/unrar-free ] ...but I fail to understand why this would make a difference ...what does sab use rar for?

Re: Debian (Lenny/any) install script

Posted: January 19th, 2012, 1:07 pm
by jcfp
Iirc those "some archives in rar 3.0 format" include some newer style of multi-part archives, anything encrypted, and large file support. As an example, see the discussion in this Ubuntu bug report for some of the ongoing issues with unrar. Seems there was some rar v3.0 support at some point in the free version, only to be removed again because of patents and license trouble. Knowing how strict Debian can be in such situations, I doubt they'll distribute a version of unrar-free with functional rar 3.0 support unless by mistake.

Re: Debian (Lenny/any) install script

Posted: January 20th, 2012, 1:43 pm
by bluechip
Cheers jcfp ... I have corrected the script to in light of this new knowledge ... BC

Re: Debian (Lenny/any) install script

Posted: May 11th, 2012, 4:39 am
by matatr0n
Hello an thanks for the script!

i have tried to use your script for installing sabnzbd on my mybooklive.

i have copied your script to /root/ and opend my puttyterminal to login as root.

after i started

Code: Select all

sh setup_sabnzbd.sh


i have some errors and i dont know how i fix them (i'am a ultra linux noob :()

Code: Select all

MyBookLive:~# sh setup_sabnzbd.sh
: command not foundine 2:
: command not foundine 3:
: command not foundine 7:
: command not foundine 10:
: command not foundine 11:
can anyone help me out what this error means ?

greets from germany
mata

Re: Debian (Lenny/any) install script

Posted: October 12th, 2012, 4:55 am
by Alonzzo2
Hi,

I didn't manage to install this script (and found no alternative) - here is my error (same one as @jeff10011 had, but I don't know how he solved it...)
sudo: unable to execute /usr/share/sabnzbd/SABnzbd.py: Permission denied


I've noticed that the script does NOT successfully install any of the python packages except for the first one, I thought this might be relaed but im not sure it does since it seems like a certificate issue, so I checked to see if the sabnzbd user does exists and it does, so I can't see what could be the problem....

Help anyone??

Thanks