Index: net-mgmt/netbox/Makefile =================================================================== --- net-mgmt/netbox/Makefile +++ net-mgmt/netbox/Makefile @@ -36,12 +36,18 @@ USE_GITHUB= yes GH_ACCOUNT= digitalocean -SUB_FILES= pkg-message -SUB_LIST= DATADIR=${DATADIR} PYTHON_VER=${PYTHON_VER} +SUB_FILES= netbox pkg-message +SUB_LIST= DATADIR=${DATADIR} PYTHON_CMD=${PYTHON_CMD} PYTHON_VER=${PYTHON_VER} WWWOWN=${WWWOWN} NO_BUILD= yes NO_ARCH= yes -OPTIONS_DEFINE= DOCS +OPTIONS_DEFINE= DOCS GUNICORN + +GUNICORN_DESC= Deploy with Gunicorn (WSGI) and start as service + +GUNICORN_RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}gunicorn>0:www/py-gunicorn@${PY_FLAVOR} +GUNICORN_USE= RC_SUBR=netbox +GUNICORN_VARS= USERS=${WWWOWN} GROUPS=${WWWGRP} post-patch: @${REINPLACE_CMD} -e 's|==|>=|' ${WRKSRC}/requirements.txt Index: net-mgmt/netbox/files/netbox.in =================================================================== --- /dev/null +++ net-mgmt/netbox/files/netbox.in @@ -0,0 +1,66 @@ +#!/bin/sh + +# $FreeBSD$ + +# This sample rc script is courtesy by Thomas Kurschel. It doesn't require +# sysutils/supervisor to start/stop NetBox as a service. Only www/py-gunicorn +# is needed as a WSGI. +# +# Of course a working HTTP server like Apache/nginx is still required to make +# use of the gunicorn WSGI. + +# +# PROVIDE: netbox +# REQUIRE: DAEMON +# KEYWORD: shutdown +# +# Add the following line to /etc/rc.conf.local or /etc/rc.conf +# to enable netbox: +# +# netbox_enable (bool): Set to NO by default. +# Set it to YES to enable netbox. +# netbox_config (str): Default to "/usr/local/etc/${name}.conf}" +# Config file for gunicorn's netbox config file +# netbox_command (str): Default to "/usr/local/bin/gunicorn-3.6" +# Path to gunicorn to run netbox +# netbox_bind (str): Default to "localhost:8001" +# Interface and port to bind to +# netbox_workers (int): Default to "3" +# Number of gunicorn works +# netbox_timeout (int): Default to "120" +# Worker timeout for gunicorn +# + +. /etc/rc.subr + +name="netbox" +rcvar=netbox_enable +netbox_path=%%DATADIR%% + +load_rc_config $name + +start_precmd="netbox_precmd" +command=${netbox_program:-%%LOCALBASE%%/bin/gunicorn} +procname=${netbox_procname:-%%PYTHON_CMD%%} +netbox_chdir=${netbox_path} + +pidfile=${netbox_pidfile:-/var/run/${name}/${name}.pid} +netbox_user=${netbox_user:-%%WWWOWN%%} +netbox_bind=${netbox_bind:-localhost:8001} +netbox_workers=${netbox_workers:-3} +netbox_timeout=${netbox_timeout:-120} + +command_args="${netbox_args} -D \ + --log-syslog --disable-redirect-access-to-syslog --log-syslog-prefix ${name} \ + --log-syslog-to unix:///var/run/log#dgram \ + -p ${pidfile} --pythonpath ${netbox_path} \ + -b ${netbox_bind} -w ${netbox_workers} -t ${netbox_timeout} \ + netbox.wsgi" + +netbox_precmd() +{ + install -d -o ${netbox_user} `dirname ${pidfile}` +} + +run_rc_command "$1" +