Error when trying to run nzbhydra in jail

Status
Not open for further replies.

Rudi Pittman

Contributor
Joined
Dec 22, 2015
Messages
161
I've done a git clone of the app nznhydra available here: https://github.com/theotherp/nzbhydra

When running it with "python2.7 nzbhydra.py --nobrowser" I get the following error:

root@aria2_1:/usr/local/www/nginx/nzbhydra # python2.7 nzbhydra.py --nobrowser
Traceback (most recent call last):
File "nzbhydra.py", line 24, in <module>
from nzbhydra import indexers
File "/usr/local/www/nginx-dist/nzbhydra/nzbhydra/indexers.py", line 13, in <module>
from nzbhydra import config, database
File "/usr/local/www/nginx-dist/nzbhydra/nzbhydra/database.py", line 17, in <module>
from playhouse.sqlite_ext import SqliteExtDatabase
File "/usr/local/www/nginx-dist/nzbhydra/libs/playhouse/sqlite_ext.py", line 74, in <module>
FTS_VER = sqlite3.sqlite_version_info[:3] >= (3, 7, 4) and 'FTS4' or 'FTS3'
AttributeError: 'NoneType' object has no attribute 'sqlite_version_info'
root@aria2_1:/usr/local/www/nginx/nzbhydra #


I've read it and still can't tell exactly what the issue is. Can someone point me in the right direction?
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
I'm assuming you need to install py27-sqlite3
 

Rudi Pittman

Contributor
Joined
Dec 22, 2015
Messages
161
Thank you! That did the trick. The only guides I could find were for linux (ubuntu specifically) and the package names were different. Supposedly nzbhydra can be use to to configure headphones, couchpotato, sickrage, lazy librarian etc so you have one place to add/remove nzb providers and they are automatically available to all the programs...as often as the free sites vanish it will simplify maintenance.


Are there new instructions on how to get the app to autostart because the old ones of adding a line to /etc/rc.local don't seem to be working. I had to start it by running /etc/rc.local manually when jail came up.

Contents of /etc/rc.local

/usr/local/bin/startaria.sh > /dev/null 2>&1 /dev/null &
python2.7 /usr/local/www/nginx/nzbhydra/nzbhydra.py --nobrowser > /dev/null 2>&1 /dev/null &
 
Last edited:

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949

Rudi Pittman

Contributor
Joined
Dec 22, 2015
Messages
161
I appreciate the example. I was trying to hunt down one earlier. Did not realize couchpotato was in python. I managed to throw one together that starts/stops nzbhydra but it gives me a warning so I may look at re-doing it. The warning was:
/usr/local/etc/rc.d/nzbhydra:

WARNING: $command_interpreter /usr/local/bin/python != python"

/usr/local/bin/python is symbolically linked to /usr/local/bin/python2.7 because that's the only way I managed to get it to work.

Script used was:
#!/bin/sh

# REQUIRE: LOGIN

. /etc/rc.subr

name=nzbhydra
rcvar=`set_rcvar`
command=/usr/local/www/nginx/nzbhydra/nzbhydra.py
command_interpreter=/usr/local/bin/python
start_cmd="/usr/sbin/daemon $command --nobrowser"

load_rc_config $name
run_rc_command "$1"
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
this worked fine for me.

Code:
#!/bin/sh

# PROVIDE: nzbhydra
# REQUIRE: LOGIN
# KEYWORD: shutdown

. /etc/rc.subr

name="nzbhydra"
rcvar="${name}_enable"
load_rc_config ${name}

: ${nzbhydra_enable:="NO"}
#: ${nzbhydra_user:="www"}

command="/usr/local/bin/python2.7"
command_args="/usr/local/www/nginx/nzbhydra/nzbhydra.py --nobrowser --daemon"

run_rc_command "$1"
 

Rudi Pittman

Contributor
Joined
Dec 22, 2015
Messages
161
this worked fine for me.

Code:
#!/bin/sh

# PROVIDE: nzbhydra
# REQUIRE: LOGIN
# KEYWORD: shutdown

. /etc/rc.subr

name="nzbhydra"
rcvar="${name}_enable"
load_rc_config ${name}

: ${nzbhydra_enable:="NO"}
#: ${nzbhydra_user:="www"}

command="/usr/local/bin/python2.7"
command_args="/usr/local/www/nginx/nzbhydra/nzbhydra.py --nobrowser --daemon"

run_rc_command "$1"

Thanks again for your help!
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
no prob
 

Rudi Pittman

Contributor
Joined
Dec 22, 2015
Messages
161

After running yours a while I note that it does not work for stopping where the one I was using did even though it gave the warning so I've gone back to it till I can revisit. I mention this in case anyone else was reading this thread.

# /usr/local/etc/rc.d/nzbhydra stop
nzbhydra not running?
# ps aux | grep nzbhydra
root 82726 0.0 0.4 255688 120504 ?? SsJ 4:58PM 0:20.46 python /usr/local/www/nginx/nzbhydra/nzbhydra.py --nobrowser (python2.7)
root 99823 0.0 0.0 16316 1932 1 S+J 9:05PM 0:00.00 grep nzbhydra
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
dont run the script directly. if that isn't working we can just add the pidfile option and it for sure should work.

service nzbhydra start/stop/status
 

Rudi Pittman

Contributor
Joined
Dec 22, 2015
Messages
161
dont run the script directly. if that isn't working we can just add the pidfile option and it for sure should work.

service nzbhydra start/stop/status

Ok..thats a new one on me...I'll make sure to use service in front from now on. I was running it manually to chase down a "traceback" error that cropped up in the application..of course the issue went away once I restarted it..so much for that idea.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
here's the script with the pidfile defined

Code:
#!/bin/sh

# PROVIDE: nzbhydra
# REQUIRE: LOGIN
# KEYWORD: shutdown

. /etc/rc.subr

name="nzbhydra"
rcvar="${name}_enable"
load_rc_config ${name}

: ${nzbhydra_enable:="NO"}

pidfile="/var/run/nzbhydra.pid"
command="/usr/local/bin/python2.7"
command_args="/usr/local/www/nginx/nzbhydra/nzbhydra.py --pidfile ${pidfile} --nobrowser --daemon"

run_rc_command "$1"
 

Rudi Pittman

Contributor
Joined
Dec 22, 2015
Messages
161
here's the script with the pidfile defined

Code:
#!/bin/sh

# PROVIDE: nzbhydra
# REQUIRE: LOGIN
# KEYWORD: shutdown

. /etc/rc.subr

name="nzbhydra"
rcvar="${name}_enable"
load_rc_config ${name}

: ${nzbhydra_enable:="NO"}

pidfile="/var/run/nzbhydra.pid"
command="/usr/local/bin/python2.7"
command_args="/usr/local/www/nginx/nzbhydra/nzbhydra.py --pidfile ${pidfile} --nobrowser --daemon"

run_rc_command "$1"

That did the trick. Hopefully others will be interested in nzbhydra and this info. I should mention nzbhydra also makes binsearch and womble available to all the programs....some such as headphones and lazy librarian didn't have those by default.
 

Rudi Pittman

Contributor
Joined
Dec 22, 2015
Messages
161
Joshua,

I've reported an "internal server error" to the author that only occurs when --daemon is used. (https://github.com/theotherp/nzbhydra/issues/373) Is there a simple way to convert your script to use /usr/sbin/daemon to call the program temporarily till he tracks down the error? I tried inserting it and broke things to the point I temporarily went back to my kludgy version (which also works around the bug because it uses daemon).
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Here's one that should work. ideally the bug is fixed in nzbhydra

Code:
#!/bin/sh

# PROVIDE: nzbhydra
# REQUIRE: LOGIN
# KEYWORD: shutdown

. /etc/rc.subr

name="nzbhydra"
rcvar="${name}_enable"
load_rc_config ${name}

: ${nzbhydra_enable:="NO"}

procname="/usr/local/bin/python2.7"
command="/usr/sbin/daemon"
command_args="-f ${procname} /usr/local/www/nginx/nzbhydra/nzbhydra.py --nobrowser"

run_rc_command "$1"
 
Last edited:

Rudi Pittman

Contributor
Joined
Dec 22, 2015
Messages
161
The author finally resolved the internal server error so everything is back to normal. I was thinking I'd like to assign nzbhydra to run under user nzbhydra instead of www which would allow ipfw to forward it's port 80 traffic to a transparent proxy. I attempted to create a user similar to this one for polipo:

polipo:*:173:173:polipo web cache:/nonexistent:/sbin/nologin

using the command: pw useradd -n nzbhydra -s /sbin/nologin

however what I ended up with was:

nzbhydra:*:1001:1001:User &:/home/nzbhydra:/sbin/nologin

Can you tell me what I need to change to setup the user correctly with the name "nzbhydra", no home directory and no login? Additionally would I just move the dir to /opt and edit the startup scripts appropriately or is another directory a better choice?
 

Rudi Pittman

Contributor
Joined
Dec 22, 2015
Messages
161
Answering my own question: I found the proper way to do the useradd was
pw add user myuser -g mygroup -s /nonexistent -h -

and to redirect all their traffic to a transparent proxy like privoxy you add a line to the ipfw.rules being applied that redirects all traffic for uid "nzbhydra" in this case. Have not gotten that part working but once I do it will be simple enough to do the same for other programs which will allow me to run a vpn in one jail yet have it used by multiple plugins so I don't have 6 different exterior connections to the same vpn.

I believe the ipfw rule will be something like:

00100 fwd <privoxy jail ip>,8118 tcp from me to any dst-port 80 uid nzbhydra
 

Rudi Pittman

Contributor
Joined
Dec 22, 2015
Messages
161
Once I assign a user and group in the startup script does it automatically know to use it or do I need to alter the startup command so it's triggered by su -m nzbhydra whatevercommand?
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
It should use a user if you have something like the below. You'll obviously need to restart the service first though, and make sure and pidfile / database directories are writable by the user.
Code:
: ${nzbhydra_user:="nzbhydra"}


I personally think application files pulled directly from github like this should be in /usr/local/share/nzbhydra/nzbhydra. If I end up writing a port/plugin for this that is where I would put it, and /usr/local/share/nzbhydra would be owned by the default user of the port so it could update the application files can be updated, since alot of these type of programs update themselves.
 

Rudi Pittman

Contributor
Joined
Dec 22, 2015
Messages
161
Thank you. I saw how to assign the user but wasn't sure if it automatically picked it up. He just released a substantial update and it's working quite well. I'll play around with moving it and assigning the user. I think it would be a good plugin but I know you already have more than enough to support. It's a shame there is not a "dummy's" method to build a plugin...have a script that asks for the name of the plugin so it knows what to name the jail, the user, the group, etc, the startup script and the git repo and have it modify a generic build to fit the app. That much I could handle. ;)
 
Status
Not open for further replies.
Top