app-misc/fslurp: drop myself as a maintainer
[gentoo.git] / www-apps / netbox / netbox-2.5.11.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5 PYTHON_COMPAT=( python3_6 )
6 inherit python-single-r1 user readme.gentoo-r1
7
8 DESCRIPTION="IP address and data center infrastructure management tool"
9 HOMEPAGE="https://github.com/digitalocean/netbox"
10 SRC_URI="https://github.com/digitalocean/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
11
12 LICENSE="Apache-2.0"
13 SLOT="0"
14 KEYWORDS="~amd64"
15 IUSE="ldap webhooks"
16 REQUIRED_USE=${PYTHON_REQUIRED_USE}
17
18 RDEPEND="
19         ${PYTHON_DEPS}
20         >=dev-python/django-2.2[${PYTHON_USEDEP}]
21         >=dev-python/django-cors-headers-2.4.0[${PYTHON_USEDEP}]
22         >=dev-python/django-debug-toolbar-1.11[${PYTHON_USEDEP}]
23         >=dev-python/django-filter-2.0.0[${PYTHON_USEDEP}]
24         >=dev-python/django-mptt-0.9.1[${PYTHON_USEDEP}]
25         >=dev-python/django-tables2-2.0.3[${PYTHON_USEDEP}]
26         >=dev-python/django-taggit-0.23.0[${PYTHON_USEDEP}]
27         >=dev-python/django-taggit-serializer-0.1.7[${PYTHON_USEDEP}]
28         >=dev-python/django-timezone-field-3.0[${PYTHON_USEDEP}]
29         >=dev-python/djangorestframework-3.9.0[${PYTHON_USEDEP}]
30         >=dev-python/drf-yasg-1.14.0[${PYTHON_USEDEP},validation]
31         >=dev-python/graphviz-0.10.1[${PYTHON_USEDEP}]
32         >=dev-python/jinja-2.10[${PYTHON_USEDEP}]
33         >=dev-python/markdown-2.6.11[${PYTHON_USEDEP}]
34         >=dev-python/netaddr-0.7.19[${PYTHON_USEDEP}]
35         >=dev-python/pillow-5.3.0[${PYTHON_USEDEP}]
36         >=dev-python/psycopg-2.7.6.1[${PYTHON_USEDEP}]
37         >=dev-python/py-gfm-0.1.4[${PYTHON_USEDEP}]
38         >=dev-python/pycryptodome-3.7.2[${PYTHON_USEDEP}]
39         www-servers/gunicorn[${PYTHON_USEDEP}]
40         ldap? ( >=dev-python/django-auth-ldap-1.7[${PYTHON_USEDEP}] )
41         webhooks? ( dev-python/django-rq )"
42 DEPEND="${RDEPEND}"
43
44 PATCHES=(
45         "${FILESDIR}"/${P}-no-pip.patch
46         )
47
48 DISABLE_AUTOFORMATTING=YES
49 DOC_CONTENTS="
50 netbox is installed on your system. However, there are some manual steps
51 you need to complete from the installation guide [1].
52
53 On Gentoo, the configuration files you need to edit are located in
54 /etc/netbox, not /opt/netbox as shown in the installation guide.
55
56 If this is a new installation, please follow the installation guide
57 other than this difference. Also, if you need ldap or webhooks, set the
58 appropriate use flags when you emerge netbox to install the
59 dependencies.
60
61 Once that is done, you should be able to add the netbox service to the
62 default runlevel and start it.
63
64 If you have webhooks turned on,  you should also add the netbox-rqworker
65 service to the default runlevel and start it.
66
67 If this is an upgrade, follow these instructions:
68
69 Stop the netbox service. If the  netbox-rqworker service is running,
70 stop it as well.
71
72 Next, run the upgrade script as described in the upgrading guide[2].
73
74 Next, check for new configuration options and set them as appropriate
75 for your system.
76
77 Next, start the netbox service.
78
79 Finally, if you are using webhooks, start the netbox-rqworker service.
80
81 [1] https://netbox.readthedocs.io/en/stable/installation/
82 [2] https://netbox.readthedocs.io/en/stable/installation/upgrading/
83 "
84
85 pkg_setup() {
86         enewgroup ${PN}
87         enewuser ${PN} -1 -1 /var/lib/${PN} ${PN}
88 }
89
90 src_install() {
91         dodir /opt
92         cp -a ../${P} "${ED}"/opt
93         dosym ${P} /opt/netbox
94 dosym ../../etc/netbox/gunicorn_config.py /opt/netbox/gunicorn_config.py
95         dosym ../../../../etc/netbox/configuration.py \
96         /opt/netbox/netbox/netbox/configuration.py
97         dodir /etc/netbox
98         insinto /etc/netbox
99         newins netbox/netbox/configuration.example.py configuration.py
100         doins "${FILESDIR}"/gunicorn_config.py
101         fowners -R netbox:netbox /etc/netbox /opt/${P}
102         fowners -h netbox:netbox /opt/netbox
103         fperms o= /etc/netbox/configuration.py /etc/netbox/gunicorn_config.py
104         newinitd "${FILESDIR}"/${PN}.initd ${PN}
105         use webhooks &&
106                 newinitd "${FILESDIR}"/${PN}-rqworker.initd ${PN}-rqworker
107         keepdir /var/log/netbox
108         fowners -R netbox:netbox /var/log/netbox
109         readme.gentoo_create_doc
110 }
111
112 pkg_postinst() {
113         readme.gentoo_print_elog
114         local r
115         for r in $REPLACING_VERSIONS; do
116                 if [[ $r = "2.5.10" ]]; then
117                         ewarn "The home directory of the netbox user is now /var/lib/netbox"
118                         ewarn "Please adjust your system."
119                 fi
120         done
121 }