FreeBSD, SABnzbd+, and cherry-py

Get help with all aspects of SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
tehgooch
Newbie
Newbie
Posts: 12
Joined: January 15th, 2010, 7:41 pm

FreeBSD, SABnzbd+, and cherry-py

Post by tehgooch »

Installed 0.5.6 from packages on 8.2-RELEASE. I must execute

Code: Select all

/usr/local/bin/SABnzbd.py
as root before I can access the wizard. I tried executing

Code: Select all

/usr/local/etc/rc.d/sabnzbd start
, but I can't connect to port 8080. I am running this machine headless over a serial console (edit: clarification: I'm connecting via SSH from my windows box to install/configure, but the machine itself is only using a serial console. No screen at all.) - could this have something to do with it? Anyway, when going through the wizard everything is fine until it prompts me to input my newzbin/nzbmatrix credentials. I have them, but I don't want to set them up ATM so I hit next. I get the following error page:

Code: Select all

Should LastPass remember this password? Not NowNever...Save Site
500 Internal Server Error

The server encountered an unexpected condition which prevented it from fulfilling the request.

Traceback (most recent call last):
  File "/usr/local/lib/python2.6/site-packages/cherrypy/_cprequest.py", line 606, in respond
    cherrypy.response.body = self.handler()
  File "/usr/local/lib/python2.6/site-packages/cherrypy/_cpdispatch.py", line 25, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/usr/local/lib/python2.6/site-packages/sabnzbd/wizard.py", line 205, in five
    info['access_url'], info['urls'] = self.get_access_info()
  File "/usr/local/lib/python2.6/site-packages/sabnzbd/wizard.py", line 222, in get_access_info
    addresses = socket.getaddrinfo(host, None)
gaierror: [Errno 8] hostname nor servname provided, or not known
Powered by CherryPy 3.1.2
I realize FreeBSD might not be supported here, but any help would be appreciated. I'm not using IPv6 (yet) and I have not set up the firewall yet.
Last edited by tehgooch on March 14th, 2011, 11:00 pm, edited 1 time in total.
tehgooch
Newbie
Newbie
Posts: 12
Joined: January 15th, 2010, 7:41 pm

Re: FreeBSD, SABnzbd+, and cherry-py

Post by tehgooch »

Fixed it. Removed /root/.sabnzbd and ran it again as root. The wizard worked until the end, but it tried to load localhost. I tried loading it by IP again and was greeted by the wizard. I changed the config dir to /usr/local/etc/sabnzbd in the /usr/local/etc/rc.d/sabnzbd file and moved the config files in there. I also chown/grp'd the folder to _sabnzbd (I don't like running daemons as root if I don't have to!). I set the host to my IP address in the sabnzbd.ini file as well. I tried running /usr/local/etc/rc.d/sabnzbd and it starts, but I can't connect via port 8080.
tehgooch
Newbie
Newbie
Posts: 12
Joined: January 15th, 2010, 7:41 pm

Re: FreeBSD, SABnzbd+, and cherry-py

Post by tehgooch »

Just did some testing and it works fine as root... Strange, maybe I missed some permissions somewhere. I'd rather not have to run the sabnzbd daemon as root though. Hopefully this will help some confused FreeBSD user in the future.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: FreeBSD, SABnzbd+, and cherry-py

Post by shypike »

SABnzbd doesn't need to be root (unless you want to use a port below 1024).
You do need to make sure that it has read/execute permissions for all its program data
and write access to all it's working folders.
tehgooch
Newbie
Newbie
Posts: 12
Joined: January 15th, 2010, 7:41 pm

Re: FreeBSD, SABnzbd+, and cherry-py

Post by tehgooch »

Been pulling my hair out over this off and on for a while now. I still cannot get SABnzbd to run if the user is not root. It just won't run at all. No logs or anything. I've made double sure the permissions are correct (to the extent of chowning the whole python directory to _sabnzbd). At some point in trying to get it to run as a non-root user I started getting this messed up error in the 'Warnings' link and I can't get rid of it. I've gone through so many attempts to fix this I've lost count. So here is where I'm currently at:

1. Downloaded the source tarball and extracted to /usr/local/src
2. Modified SABnzbd.py to point to /usr/local/bin/python
3. Ran SABnzbd.py as root. It does not crash on step 5 anymore! Moved the resulting config files to /usr/local/etc/sabnzbd
4. Cobbled together this rc.d script from the one that comes with the sabnzbdplus port and one I found here on the forums. Neither worked completely properly alone and neither does mine (shutdown takes about 5 minutes, although it actually does shut down unlike the originals which would just hang forever).

Code: Select all

#!/bin/sh

. /etc/rc.subr

name="sabnzbd"
rcvar=${name}_enable

load_rc_config ${name}

: ${sabnzbd_enable:="NO"}
: ${sabnzbd_user:="root"}
: ${sabnzbd_group:="wheel"}
: ${sabnzbd_conf_dir:="/usr/local/etc/sabnzbd"}

required_dirs=${sabnzbd_conf_dir}

status_cmd="${name}_status"
stop_cmd="${name}_stop"
start_precmd=sabnzbd_check_dir

command="/usr/sbin/daemon"
command_args="-f /usr/local/src/SABnzbd-0.5.6/SABnzbd.py ${sabnzbd_flags} --daemon -b 0 -w 0 -l 0 -f ${sabnzbd_conf_dir}"

# SABnzbd can only be cleanly stopped by calling the http api
sabnzbd_stop() {
    echo "Stopping $name"
    if [ -f "${sabnzbd_conf_dir}/sabnzbd.ini" ]; then
        apikey=`grep ^api_key ${sabnzbd_conf_dir}/sabnzbd.ini | tr -d " _"`
        host=`grep -E '^host\ =\ [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' ${sabnzbd_conf_dir}/sabnzbd.ini | tr -dc '[0-9].'`
        if [ ${host}="0.0.0.0" ] ; then host="localhost" ; fi
        port=`grep -m1 ^port ${sabnzbd_conf_dir}/sabnzbd.ini | tr -dc '[0-9]'`
        fetch -o /dev/null "http://${host}:${port}/api?mode=shutdown&${apikey}" > /dev/null 2>&1
    else
        sabnzbd_pid=`ps -U ${sabnzbd_user} | grep "python.*SABnzbd.py.*--daemon" | grep -v 'grep' | awk '{print $1}'`
        if [ -n "${sabnzbd_pid}" ]; then
            kill ${sabnzbd_pid}
        fi
    fi
}

sabnzbd_status() {
    sabnzbd_pid=`ps -U ${sabnzbd_user} | grep "python.*SABnzbd.py.*--daemon" | grep -v 'grep' | awk '{print $1}'`
    if [ -n "${sabnzbd_pid}" ]; then
        echo "$name is running as ${sabnzbd_pid}"
    else
       echo "$name is not running"
    fi
}

sabnzbd_check_dir() {
    if [ ! -f "${required_dirs}" -a ! -d "${required_dirs}" -a ! -L "${required_dirs}" ]; then
        mkdir -p ${required_dirs}
        chown ${sabnzbd_user}:${sabnzbd_group} ${required_dirs}
    fi
}

run_rc_command "$1"
5. Okay, it starts up and actually works. Or so it seems. After about 5 minutes this error appears in the 'Warnings" link:

Code: Select all

2011-04-10 23:20:55,433 ERROR: [10/Apr/2011:23:20:55] ENGINE Error in 'start' listener <bound method Server.start of <cherrypy._cpserver.Server object at 0x802ad1750>> Traceback (most recent call last): File "/usr/local/src/SABnzbd-0.5.6/cherrypy/process/wspbus.py", line 147, in publish output.append(listener(*args, **kwargs)) File "/usr/local/src/SABnzbd-0.5.6/cherrypy/_cpserver.py", line 90, in start ServerAdapter.start(self) File "/usr/local/src/SABnzbd-0.5.6/cherrypy/process/servers.py", line 62, in start self.wait() File "/usr/local/src/SABnzbd-0.5.6/cherrypy/process/servers.py", line 103, in wait wait_for_occupied_port(host, port) File "/usr/local/src/SABnzbd-0.5.6/cherrypy/process/servers.py", line 275, in wait_for_occupied_port raise IOError("Port %r not bound on %r" % (port, host)) IOError: Port 8080 not bound on '0.0.0.0' 
2011-04-10 23:20:55,434 ERROR: [10/Apr/2011:23:20:55] ENGINE Shutting down due to error in start listener: Traceback (most recent call last): File "/usr/local/src/SABnzbd-0.5.6/cherrypy/process/wspbus.py", line 184, in start self.publish('start') File "/usr/local/src/SABnzbd-0.5.6/cherrypy/process/wspbus.py", line 147, in publish output.append(listener(*args, **kwargs)) File "/usr/local/src/SABnzbd-0.5.6/cherrypy/_cpserver.py", line 90, in start ServerAdapter.start(self) File "/usr/local/src/SABnzbd-0.5.6/cherrypy/process/servers.py", line 62, in start self.wait() File "/usr/local/src/SABnzbd-0.5.6/cherrypy/process/servers.py", line 103, in wait wait_for_occupied_port(host, port) File "/usr/local/src/SABnzbd-0.5.6/cherrypy/process/servers.py", line 275, in wait_for_occupied_port raise IOError("Port %r not bound on %r" % (port, host)) IOError: Port 8080 not bound on '0.0.0.0' 
2011-04-10 23:20:55,439 ERROR: Failed to start web-interface
6. With a little bit of playing around that I found if I set "host" in sabnzbd.ini to anything BUT 0.0.0.0 it will crash a few minutes after this. With 0.0.0.0 I still get the error, however everything *seems* to work okay with one exception. SABnzbd will still not shut down / restart through the web interface (I have to do ps -ax and kill -9 the pid). It will also crash in the exact same manner if I enable SSL. This one is a real head-scratcher for me. I don't really know anything about python. I tried to look in the python files mentioned, but I couldn't really make head nor tails out of it (I'm not a programmer. I made a crappy PHP website for a class once, and I'm sure it would fall over if you looked at it funny.)
Last edited by tehgooch on April 11th, 2011, 3:02 am, edited 1 time in total.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: FreeBSD, SABnzbd+, and cherry-py

Post by shypike »

SABnzbd relies on a whole tool chain.
CherryPy --> PyOpenSSL --> OpenSSH libs --> Operating system
This chain is outside our control, with the exception that we have done a few patches on CherryPy.
We verify correct working on Ubuntu, Windows and OSX.
Try to use the latest of everything in the chain (Python 2.5x, 2.6.x or 2.7.x, PyOpenSSL 0.10 or 0.11).

Nothing in the design of SABnzbd requires root access, except when you want to use a web port below 1024.
Tuxie
Newbie
Newbie
Posts: 1
Joined: August 14th, 2011, 8:05 am

Re: FreeBSD, SABnzbd+, and cherry-py

Post by Tuxie »

I ran into this issue, found the solution and decided to share to others who come here from Google.
The problem was that my FreeBSD server didn't have a domain name properly configured. After changing hostname to "server.local" instead of just "server" in /etc/rc.conf and running "hostname server.local" it works fine. You should probably also edit your /etc/hosts file and make the 127.0.0.1 and ::1 entries look like "127.0.0.1 server.local server localhost.local localhost" etc. Change "server" and "local" to your real hostname and domainname.

If properly configured, hostname should report this:

Code: Select all

~$ hostname -f
server.local
~$ hostname -s
server
Post Reply