129 lines
4.1 KiB
Bash
129 lines
4.1 KiB
Bash
# Copyright 1999-2025 Gentoo Authors
|
|
# Distributed under the terms of the GNU General Public License v2
|
|
|
|
EAPI=8
|
|
|
|
PYTHON_COMPAT=( python3_{11..13} )
|
|
WEBAPP_MANUAL_SLOT="yes"
|
|
|
|
inherit python-r1 webapp
|
|
|
|
DESCRIPTION="IP address and data center infrastructure management tool"
|
|
HOMEPAGE="https://github.com/netbox-community/netbox"
|
|
SRC_URI="https://github.com/netbox-community/${PN}/archive/v${PV}.tar.gz -> ${P}.gh.tar.gz"
|
|
|
|
LICENSE="Apache-2.0"
|
|
SLOT="0"
|
|
KEYWORDS="amd64 arm arm64 x86"
|
|
IUSE="ldap vhosts"
|
|
REQUIRED_USE="${PYTHON_REQUIRED_USE}"
|
|
|
|
RDEPEND="acct-user/netbox
|
|
${PYTHON_DEPS}
|
|
<dev-python/django-5.0.10[${PYTHON_USEDEP}]
|
|
~dev-python/django-cors-headers-4.6.0[${PYTHON_USEDEP}]
|
|
~dev-python/django-debug-toolbar-4.4.6[${PYTHON_USEDEP}]
|
|
~dev-python/django-filter-24.3[${PYTHON_USEDEP}]
|
|
~dev-python/django-htmx-1.21.0[${PYTHON_USEDEP}]
|
|
~dev-python/django-graphiql-debug-toolbar-0.2.0[${PYTHON_USEDEP}]
|
|
~dev-python/django-mptt-0.16.0[${PYTHON_USEDEP}]
|
|
~dev-python/django-pglocks-1.0.4[${PYTHON_USEDEP}]
|
|
~dev-python/django-prometheus-2.3.1[${PYTHON_USEDEP}]
|
|
~dev-python/django-redis-5.4.0[${PYTHON_USEDEP}]
|
|
~dev-python/django-rich-1.13.0[${PYTHON_USEDEP}]
|
|
~dev-python/django-rq-3.0[${PYTHON_USEDEP}]
|
|
~dev-python/django-taggit-6.1.0[${PYTHON_USEDEP}]
|
|
~dev-python/django-tables2-2.7.0[${PYTHON_USEDEP}]
|
|
~dev-python/django-timezone-field-7.0[${PYTHON_USEDEP}]
|
|
~dev-python/djangorestframework-3.15.2[${PYTHON_USEDEP}]
|
|
~dev-python/drf-spectacular-0.28.0[${PYTHON_USEDEP}]
|
|
~dev-python/drf-spectacular-sidecar-2024.12.1[${PYTHON_USEDEP}]
|
|
~dev-python/feedparser-6.0.11[${PYTHON_USEDEP}]
|
|
~www-servers/gunicorn-23.0.0[${PYTHON_USEDEP}]
|
|
~dev-python/jinja-3.1.4[${PYTHON_USEDEP}]
|
|
~dev-python/markdown-3.7[${PYTHON_USEDEP}]
|
|
~dev-python/mkdocs-material-9.5.49[${PYTHON_USEDEP}]
|
|
~dev-python/mkdocstrings-0.27.0[${PYTHON_USEDEP}]
|
|
~dev-python/netaddr-1.3.0[${PYTHON_USEDEP}]
|
|
~dev-python/nh3-0.2.20[${PYTHON_USEDEP}]
|
|
~dev-python/pillow-11.0.0[${PYTHON_USEDEP}]
|
|
~dev-python/psycopg-3.2.3[${PYTHON_USEDEP}]
|
|
~dev-python/pyyaml-6.0.2[${PYTHON_USEDEP}]
|
|
~dev-python/requests-2.32.3[${PYTHON_USEDEP}]
|
|
~dev-python/rq-2.0[${PYTHON_USEDEP}]
|
|
~dev-python/social-auth-app-django-5.4.2[${PYTHON_USEDEP}]
|
|
~dev-python/social-auth-core-4.5.4[${PYTHON_USEDEP}]
|
|
~dev-python/strawberry-graphql-0.254.0[${PYTHON_USEDEP}]
|
|
~dev-python/strawberry-graphql-django-0.52.0[${PYTHON_USEDEP}]
|
|
~dev-python/svgwrite-1.4.3[${PYTHON_USEDEP}]
|
|
~dev-python/tablib-3.7.0[${PYTHON_USEDEP}]
|
|
~dev-python/tzdata-2024.2[${PYTHON_USEDEP}]
|
|
ldap? ( dev-python/django-auth-ldap[${PYTHON_USEDEP}] )"
|
|
DEPEND="${RDEPEND}"
|
|
|
|
DOCS=( {CHANGELOG,CONTRIBUTING,README}.md )
|
|
|
|
pkg_setup() {
|
|
python_setup
|
|
webapp_pkg_setup
|
|
}
|
|
|
|
src_install() {
|
|
webapp_src_preinst
|
|
|
|
insinto "${MY_HTDOCSDIR}"
|
|
doins -r netbox/.
|
|
|
|
exeinto "${MY_HTDOCSDIR}"
|
|
doexe netbox/generate_secret_key.py
|
|
doexe netbox/manage.py
|
|
|
|
webapp_src_install
|
|
|
|
newinitd "${FILESDIR}"/netbox-rqworker.initd netbox-rqworker
|
|
newconfd "${FILESDIR}"/netbox-rqworker.confd netbox-rqworker
|
|
diropts -o netbox -g netbox -m 0700
|
|
keepdir /var/log/netbox
|
|
}
|
|
|
|
pkg_postinst() {
|
|
elog "You may need to add your web-server user to netbox group"
|
|
elog "---"
|
|
|
|
webapp_pkg_postinst
|
|
}
|
|
|
|
pkg_config() {
|
|
einfo "Enter your vhost_root/vhost_htdocs. Default: localhost/htdocs"
|
|
read -r answer
|
|
[ -z "${answer}" ] && answer="localhost/htdocs"
|
|
path="/var/www/${answer}/netbox"
|
|
unset answer
|
|
|
|
if [ -f "${path}/netbox/configuration.py" ] ; then
|
|
einfo "Applies database migrations from ${path} ?"
|
|
einfo
|
|
while [ "$correct" != "true" ] ; do
|
|
einfo "Are you ready to continue? (y/n)"
|
|
read -r answer
|
|
if [[ "$answer" =~ ^[Yy]([Ee][Ss])?$ ]] ; then
|
|
correct="true"
|
|
elif [[ "$answer" =~ ^[Nn]([Oo])?$ ]] ; then
|
|
die "Aborting migration."
|
|
else
|
|
echo "Answer not recognized" || die "echo failed"
|
|
fi
|
|
done
|
|
# Apply database migrations
|
|
"${path}"/manage.py migrate || die "migrations failed"
|
|
fi
|
|
|
|
if [ ! -d "${path}/static" ] ; then
|
|
# Collect static files
|
|
"${path}"/manage.py collectstatic || die "collectstatic failed"
|
|
fowners -R netbox:netbox "${path}"/static
|
|
else
|
|
einfo "Not managing static files since ${path}/static exists"
|
|
fi
|
|
}
|