Creating PBI's for FreeNAS 9.1 RC1/RC2

Status
Not open for further replies.

Master Gollom

Dabbler
Joined
Jul 25, 2013
Messages
44
Hello,

I'm trying to create PBI's for FreeNAS 9.1 RC1/RC2. I managed to create the PBI but it won't start, FreeNAS is telling me that "Some Error occured". Well to really see what's wrong i'm restarting the jail and it comes up with this:

Code:
Request Method: POST
Request URL: http://192.168.1.203/jails/start/2
Software Version: FreeNAS-9.1.0-RC2-x64 (5f710b2)
Exception Type: TypeError
Exception Value:
warden_exception('/usr/local/share/warden/scripts/backend/startjail.sh: cannot create /dev/tty: Device not configured\n',) is not JSON serializable
Exception Location: /usr/local/lib/python2.7/site-packages/simplejson/encoder.py in default, line 223
Server time: Fri, 26 Jul 2013 03:08:11 -0700
Traceback
 
 
 
Environment:
 
Software Version: FreeNAS-9.1.0-RC2-x64 (5f710b2)
Request Method: POST
Request URL: http://192.168.1.203/jails/start/2
 
 
Traceback:
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
109. response = middleware_method(request, callback, callback_args, callback_kwargs)
File "/usr/local/www/freenasUI/../freenasUI/freeadmin/middleware.py" in process_view
165. return login_required(view_func)(request, *view_args, **view_kwargs)
File "/usr/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
25. return view_func(request, *args, **kwargs)
File "/usr/local/www/freenasUI/../freenasUI/jails/views.py" in jail_start
151. return JsonResp(request, error=True, message=e)
File "/usr/local/www/freenasUI/../freenasUI/freeadmin/views.py" in __init__
128. kwargs['content'] = simplejson.dumps(data)
File "/usr/local/lib/python2.7/site-packages/simplejson/__init__.py" in dumps
323. return _default_encoder.encode(obj)
File "/usr/local/lib/python2.7/site-packages/simplejson/encoder.py" in encode
246. chunks = self.iterencode(o, _one_shot=True)
File "/usr/local/lib/python2.7/site-packages/simplejson/encoder.py" in iterencode
322. return _iterencode(o, 0)
File "/usr/local/lib/python2.7/site-packages/simplejson/encoder.py" in default
223. raise TypeError(repr(o) + " is not JSON serializable")
 
Exception Type: TypeError at /jails/start/2
Exception Value: warden_exception('/usr/local/share/warden/scripts/backend/startjail.sh: cannot create /dev/tty: Device not configured\n',) is not JSON serializable
Request information
 
GET
 
No GET data
POST
 
VariableValue
__form_id u'dijit_form_Form_3'
FILES
 
No FILES data
COOKIES
 
VariableValue
csrftoken '7Vo3FZBGgIE7ZGqMxLN6Vj4ryWfBRbAm'
sessionid 'dwe0kkfcom45vcyax1nypfpjj36iedad'
fntreeSaveStateCookie 'root%2Croot%2F55%2F62%2Croot%2F77%2F84%2Croot%2F1%2F8%2Croot%2F132%2Croot%2F146%2Croot%2F146%2F149%2Croot%2F146%2F149%2F150%2Croot%2F145%2F148%2F149%2F153%2Croot%2F124%2Croot%2F55%2Croot%2F134%2Croot%2F90%2Croot%2F90%2F97%2Croot%2F145%2Croot%2F145%2F148%2Croot%2F145%2F148%2F149%2Croot%2F145%2F148%2F149%2F154%2Croot%2F13%2F34%2Croot%2F107%2Croot%2F41%2Croot%2F149%2Croot%2F142%2Croot%2F153%2Croot%2F155%2F162%2F164%2Croot%2F155%2Croot%2F154%2Croot%2F154%2F161%2Croot%2F154%2F157%2Croot%2F150%2Croot%2F151%2Croot%2F151%2F154%2Croot%2F155%2F163'
META
 
VariableValue
wsgi.multiprocess False
HTTP_REFERER 'http://192.168.1.203/'
REDIRECT_STATUS '200'
SERVER_SOFTWARE 'nginx/1.4.1'
SCRIPT_NAME u''
HTTP_X_CSRFTOKEN '7Vo3FZBGgIE7ZGqMxLN6Vj4ryWfBRbAm'
REQUEST_METHOD 'POST'
PATH_INFO u'/jails/start/2'
HTTP_ORIGIN 'http://192.168.1.203'
SERVER_PROTOCOL 'HTTP/1.1'
QUERY_STRING ''
CONTENT_LENGTH '27'
HTTP_USER_AGENT 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36'
HTTP_CONNECTION 'keep-alive'
HTTP_COOKIE 'sessionid=dwe0kkfcom45vcyax1nypfpjj36iedad; csrftoken=7Vo3FZBGgIE7ZGqMxLN6Vj4ryWfBRbAm; fntreeSaveStateCookie=root%2Croot%2F55%2F62%2Croot%2F77%2F84%2Croot%2F1%2F8%2Croot%2F132%2Croot%2F146%2Croot%2F146%2F149%2Croot%2F146%2F149%2F150%2Croot%2F145%2F148%2F149%2F153%2Croot%2F124%2Croot%2F55%2Croot%2F134%2Croot%2F90%2Croot%2F90%2F97%2Croot%2F145%2Croot%2F145%2F148%2Croot%2F145%2F148%2F149%2Croot%2F145%2F148%2F149%2F154%2Croot%2F13%2F34%2Croot%2F107%2Croot%2F41%2Croot%2F149%2Croot%2F142%2Croot%2F153%2Croot%2F155%2F162%2F164%2Croot%2F155%2Croot%2F154%2Croot%2F154%2F161%2Croot%2F154%2F157%2Croot%2F150%2Croot%2F151%2Croot%2F151%2F154%2Croot%2F155%2F163'
SERVER_NAME 'localhost'
REMOTE_PORT '60226'
wsgi.url_scheme 'http'
SERVER_PORT '80'
SERVER_ADDR '192.168.1.203'
DOCUMENT_ROOT '/usr/local/etc/nginx/html'
HTTP_CONTENT_LENGTH '27'
HTTP_X_REQUESTED_WITH 'XMLHttpRequest'
DOCUMENT_URI '/jails/start/2'
wsgi.input <flup.server.fcgi_base.InputStream object at 0x8117c9690>
HTTP_HOST '192.168.1.203'
wsgi.multithread True
HTTP_CONTENT_TYPE 'application/x-www-form-urlencoded'
REQUEST_URI '/jails/start/2'
HTTP_ACCEPT '*/*'
wsgi.version (1, 0)
GATEWAY_INTERFACE 'CGI/1.1'
wsgi.run_once False
wsgi.errors <flup.server.fcgi_base.TeeOutputStream object at 0x8117da310>
REMOTE_ADDR '192.168.1.10'
HTTP_ACCEPT_LANGUAGE 'en-US,en;q=0.8'
CONTENT_TYPE 'application/x-www-form-urlencoded'
CSRF_COOKIE u'7Vo3FZBGgIE7ZGqMxLN6Vj4ryWfBRbAm'
HTTP_ACCEPT_ENCODING 'gzip,deflate,sdch'


can someone please give me a push in the right direction, I have to be missing something. It doesn't work with transmission nor with sabnzbd. Fortunately a 9.1 transmission plugin is online since RC2 is out, but I really want to be able to create the plugins myself....

I have been trying to create the plugins with PCBSD 9.1 - Stable and PCBSD 9.1 Release...
 
D

dlavigne

Guest
cannot create /dev/tty: Device not configured\n',) is not JSON serializable

seems to be the bit it doesn't like.

Which programming language binding are you using? What do your control files look like in your module?
 

Master Gollom

Dabbler
Joined
Jul 25, 2013
Messages
44
I'm using the control and control.py, just like transmission does. This Error that the device is not configured can be ignored since this error also came when I got a permission error with one of my first builds...

Starting the "control"-file from the command line no error appears, but sabnzbd's isn't running as well...getting desperate of failing.
And it seems there aren't many people trying to create their own pbi's....
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
And it seems there aren't many people trying to create their own pbi's....

I think its because many people are waiting for 9.1 to be officially released so the dust can settle on the jail code.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
I was actually looking at building a PBI myself, started looking into it but then I got dragged off to a party. Alcohol an figuring out how to create a PBI don't mix :confused:
 

Master Gollom

Dabbler
Joined
Jul 25, 2013
Messages
44
Hi,
well I'm still not very far, but at least I'm able to start sabnzbd from command line, but i can't figure out how plugins are startet in freenas? what file does freenas call when starting a plugin?

when i run python control.py start <ipaddress> <port> something happens but sabnzbd isn't running....

here is my control file

Code:
exec /usr/local/bin/python /usr/pbi/sabnzbdplus-$(uname -m)/control.py $*


and here is my control.py

Code:
#!/bin/sh
 
import os
import platform
import re
import sys
import stat
import signal
 
from flup.server.fcgi import WSGIServer
from subprocess import Popen, PIPE
 
HERE = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, os.path.join(HERE, "lib/python2.7/site-packages"))
 
sabnzbd_pbi_path = "/usr/pbi/sabnzbdplus-" + platform.machine()
sabnzbd_etc_path = os.path.join(sabnzbd_pbi_path, "etc")
sabnzbd_mnt_path = os.path.join(sabnzbd_pbi_path, "mnt")
sabnzbd_fcgi_pidfile = "/var/run/fcgi_sabnzbd.pid"
sabnzbd_fcgi_wwwdir = os.path.join(sabnzbd_pbi_path, "www")
sabnzbd_control = "/usr/local/etc/rc.d/sabnzbd"
 
 
def sabnzbd_fcgi_start(args):
    if len(args) < 2:
        return False
 
    ip = args[0]
    print ip
    port = long(args[1])
    print port
 
    pid = os.fork()
    if pid < 0:
        return False
    if pid != 0:
        sys.exit(0)
 
    os.setsid()
 
    os.environ['DJANGO_SETTINGS_MODULE'] = 'sabnzbdUI.settings'
    import django.core.handlers.wsgi
    app = django.core.handlers.wsgi.WSGIHandler()
 
    res = False
    with open(sabnzbd_fcgi_pidfile, "wb") as fp:
        fp.write(str(os.getpid()))
        fp.close()
 
        res = WSGIServer(app, bindAddress=(ip, port)).run()
 
    return res
 
 
def sabnzbd_fcgi_stop(args):
    res = False
    if os.access(sabnzbd_fcgi_pidfile, os.F_OK):
        with open(sabnzbd_fcgi_pidfile, "r") as fp:
            pid = long(fp.read())
            fp.close()
 
            os.kill(pid, signal.SIGHUP)
            res = True
 
    if os.access(sabnzbd_fcgi_pidfile, os.F_OK):
        os.unlink(sabnzbd_fcgi_pidfile)
 
    return res
 
 
def sabnzbd_fcgi_status(args):
    res = False
    if os.access(sabnzbd_fcgi_pidfile, os.F_OK):
        with open(sabnzbd_fcgi_pidfile, "r") as fp:
            pid = long(fp.read())
            fp.close()
            res = True
 
    return res
 
 
def sabnzbd_fcgi_configure(args):
    return True
 
 
def main(argc, argv):
    if argc < 2:
        sys.exit(1)
 
    commands = {
        'start': sabnzbd_fcgi_start,
        'stop': sabnzbd_fcgi_stop,
        'status': sabnzbd_fcgi_status,
        'configure': sabnzbd_fcgi_configure
    }
 
    if not commands.has_key(argv[0]):
        sys.exit(1)
 
    if not commands[argv[0]](argv[1:]):
        sys.exit(1)
 
    sys.exit(0)
 
if __name__ == '__main__':
    main(len(sys.argv), sys.argv[1:])
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
I could be way off base but have you placed in the rc.conf the enable line for the application?
 

Master Gollom

Dabbler
Joined
Jul 25, 2013
Messages
44
checked, doesn't work....but when I run ./user/local/etc/rc.d/sabnzbd start it starts....
and this error message in my first post, when I'm starting the jail....I still don't get it
 

Master Gollom

Dabbler
Joined
Jul 25, 2013
Messages
44
This is what I get when FreeNAS boot's up:

Code:
Jul 31 13:18:20 freenas manage.py: [plugins.utils:80] Couldn't retrieve http://192.168.1.203/plugins/sabnzbdplus/3/_s/status: HTTP Error 404: NOT FOUND
Jul 31 13:18:21 freenas manage.py: [common.pipesubr:57] Popen()ing: /usr/local/bin/warden list  -v
Jul 31 13:18:22 freenas manage.py: [freeadmin.navtree:473] Couldn't retrieve http://192.168.1.203/plugins/sabnzbdplus/3/_s/treemenu: HTTP Error 404: NOT FOUND
Jul 31 13:18:22 freenas manage.py: [py.warnings:193] /usr/local/lib/python2.7/site-packages/django/http/request.py:193: DeprecationWarning: HttpRequest.raw_post_data has been deprecated. Use HttpRequest.body instead.  warnings.warn('HttpRequest.raw_post_data has been deprecated. Use HttpRequest.body instead.', DeprecationWarning)
Jul 31 13:18:22 freenas manage.py: [common.pipesubr:57] Popen()ing: /usr/local/bin/warden list  -v


but Sabnzb is running now....but it's not managable via GUI
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
Have you made any further progress. I'm interested in how you got the plugin to work, not specifically Sabnzb.
 

Master Gollom

Dabbler
Joined
Jul 25, 2013
Messages
44
Yeah I've made some progress. The Icon now shows up in the treemenu under plugins. But I still didn't manage to start the plugin over the gui. There are important things missing on the wiki, so it took me some time to figure some things out. Since I don't see any errors in the /var/log/messages log i don't know where to look why the gui is still telling me "Some error occurred" or "an error occurred".
It'd be really nice if one of the plugins devs from the core team could give me an advice or a push in the right direction. It seems that I'm not that far away from a working plugin.....
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
I think it would be nice if we had a complete guide "by example" of how to take a port and create a FreeNAS PBI from it. I'm trying to get started into this myself but I toasted my VM so I need to start from scratch and load up FreeBSD 9.1 again. I'm not a Linux person so I'm slow like a turtle.

Once I figure out how to build one PBI, I will post a guide with the example, well unless you beat me to it :cool:.
 

Master Gollom

Dabbler
Joined
Jul 25, 2013
Messages
44
Well, why don't we try this together? I'm don't use FreeBSD 9.1, I took PcBSD 9.1 instead, and I used the STABLE version, since I had troubles getting a successful PBI-Build with the Release version.
To install the PBI-Creator, just use AppCafe to download and install it.

So far I can tell you that the wiki page is missing the "UI" part of the pbi's, which contains a lot of python scripts and since I'm not a python guy, it takes me some time to figure things out. You might have a look at the python scripts from the transmission source, but copy/paste doesn't work :) for example there is the "status"-function in which you're looking if the process is running, you have to change the code a bit....later on I'll get on my notebook, switch the tv on and work (well mostly try and error) a bit on the pbi's :)
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
I wasn't thinking about creating the PBI on PcBSD but I'll give it a shot, I might have better luck.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
Great news. I just finished downloading PcBSD and I'll have it loaded into a VM shortly. Hopefully tomorrow I will have everything working.
 
Status
Not open for further replies.
Top