~roshless/PKGBUILDs

f0c395732d6c76fd7cc4f4d290ff946ad31f18a7 — Roshless 25 days ago 9896ab7
upgpkg: netbox 2.11.0-1

revamp and do upstream release
9 files changed, 118 insertions(+), 133 deletions(-)

M netbox/.SRCINFO
M netbox/PKGBUILD
D netbox/gunicorn_config.py
A netbox/netbox-rq.service
M netbox/netbox.install
R netbox/{netbox-system.service => netbox.service}
A netbox/netbox.sysusers
M netbox/netbox.tmpfile
A netbox/upgrade.sh
M netbox/.SRCINFO => netbox/.SRCINFO +27 -30
@@ 1,53 1,50 @@
pkgbase = netbox
	pkgdesc = IP address management (IPAM) and data center infrastructure management (DCIM) tool.
	pkgver = 2.3.1
	pkgrel = 2
	pkgver = 2.11.0
	pkgrel = 1
	url = https://github.com/digitalocean/netbox
	install = netbox.install
	arch = any
	license = Apache-2.0
	depends = python
	depends = gunicorn
	depends = libffi
	depends = libpgf
	depends = openssl
	depends = python-coreapi
	depends = python-pycryptodomex
	depends = python-django
	depends = python-django-cacheops
	depends = python-django-cors-headers
	depends = python-django-debug-toolbar
	depends = python-django-filter
	depends = python-django-mptt
	depends = python-django-rest-framework
	depends = python-django-rest-swagger
	depends = python-django-pglocks
	depends = python-django-prometheus
	depends = python-django-rq
	depends = python-django-tables2
	depends = python-graphviz
	depends = python-lxml
	depends = python-django-taggit
	depends = python-django-timezone-field
	depends = python-django-rest-framework
	depends = python-drf-yasg
	depends = python-jinja
	depends = python-markdown
	depends = python-natsort
	depends = python-ncclient
	depends = python-netaddr
	depends = python-openapi-codec
	depends = python-paramiko
	depends = python-pillow
	depends = python-py-gfm
	depends = python-pytz
	depends = python-psycopg2
	depends = python-simplejson
	depends = python-xmltodict
	depends = python-yaml
	depends = python-psycopg2-binary
	depends = python-pycryptodome
	depends = python-pyaml
	depends = python-redis
	depends = python-svgwrite
	conflicts = netbox-git
	replaces = netbox-git
	backup = etc/netbox/gunicorn_config.py
	backup = etc/netbox/configuration.py
	source = https://github.com/digitalocean/netbox/archive/v2.3.1.tar.gz
	source = netbox-system.service
	source = https://github.com/digitalocean/netbox/archive/v2.11.0.tar.gz
	source = netbox.service
	source = netbox-rq.service
	source = netbox.sysusers
	source = netbox.tmpfile
	source = gunicorn_config.py
	sha256sums = 284c830fcacf99febd1f650fb323cc9ce1c4c31044e4ee70eb791c53f3f10ddb
	sha256sums = dc83de37ff9151de3d309fd43c6eff3b30886882012b81fd3ff2f3a5a706bea6
	sha256sums = 1028bac96ddcd18c10646dff26027b4891fcab4381436e2b6ea3302887a5586f
	sha256sums = 7a5ae05cad7ec14193a43ef080776b5525c80b6258762a6cb6a108db83861ff9
	source = upgrade.sh
	md5sums = ef794d344ab5a3b2d9c854867580d0cf
	md5sums = 55dcba60ed4cb66b350d3d8f2946aef9
	md5sums = ad07c0c741a231b8d8012221bee2c167
	md5sums = b653f7da646e78ad5c69d3960bbafd9c
	md5sums = 17532f81746d5378abbf9721c526247b
	md5sums = 97c618de19719135aa84458789b025b1

pkgname = netbox


M netbox/PKGBUILD => netbox/PKGBUILD +59 -60
@@ 1,70 1,69 @@
# Maintainer: Anthony Ruhier <anthony.ruhier@gmail.com>
# Maintainer: Roshless <pkgs@roshless.com>

_name=netbox
pkgname=${_name}
pkgver=2.3.1
_realver="${pkgver}"
pkgrel=2
pkgdesc="IP address management (IPAM) and data center infrastructure management (DCIM) tool."
pkgname='netbox'
pkgver=2.11.0
pkgrel=1
pkgdesc='IP address management (IPAM) and data center infrastructure management (DCIM) tool.'
arch=('any')
url="https://github.com/digitalocean/${_name}"
url='https://github.com/digitalocean/netbox'
license=('Apache-2.0')
depends=('python'
         'gunicorn'
         'libffi'
	 'libpgf'
	 'openssl'
	 'python-coreapi'
	 'python-pycryptodomex'
	 'python-django'
	 'python-django-cors-headers'
	 'python-django-debug-toolbar'
	 'python-django-filter'
	 'python-django-mptt'
	 'python-django-rest-framework'
	 'python-django-rest-swagger'
	 'python-django-tables2'
	 'python-graphviz'
	 'python-lxml'
	 'python-markdown'
	 'python-natsort'
	 'python-ncclient'
	 'python-netaddr'
	 'python-openapi-codec'
	 'python-paramiko'
	 'python-pillow'
	 'python-py-gfm'
	 'python-pytz'
	 'python-psycopg2'
	 'python-simplejson'
	 'python-xmltodict'
	 'python-yaml')
depends=(
  'python'
  'gunicorn'
  'python-django'
	'python-django-cacheops'
	'python-django-cors-headers'
	'python-django-debug-toolbar'
	'python-django-filter'
	'python-django-mptt'
	'python-django-pglocks'
	'python-django-prometheus'
	'python-django-rq'
	'python-django-tables2'
	'python-django-taggit'
	'python-django-timezone-field'
	'python-django-rest-framework'
	'python-drf-yasg'
	'python-jinja'
	'python-markdown'
	'python-netaddr'
	'python-pillow'
	'python-psycopg2-binary'
	'python-pycryptodome'
	'python-pyaml'
	'python-redis'
	'python-svgwrite'
)

conflicts=("${_name}-git")
replaces=("${_name}-git")
install="${_name}.install"
source=("${url}/archive/v${_realver}.tar.gz"
        "${_name}-system.service"
        "${_name}.tmpfile"
	"gunicorn_config.py")
sha256sums=('284c830fcacf99febd1f650fb323cc9ce1c4c31044e4ee70eb791c53f3f10ddb'
            'dc83de37ff9151de3d309fd43c6eff3b30886882012b81fd3ff2f3a5a706bea6'
            '1028bac96ddcd18c10646dff26027b4891fcab4381436e2b6ea3302887a5586f'
            '7a5ae05cad7ec14193a43ef080776b5525c80b6258762a6cb6a108db83861ff9')
backup=('etc/netbox/gunicorn_config.py' 'etc/netbox/configuration.py')
conflicts=("$pkgname-git")
replaces=("$pkgname-git")
source=("https://github.com/digitalocean/netbox/archive/v$pkgver.tar.gz"
        "$pkgname.service"
        "$pkgname-rq.service"
        "$pkgname.sysusers"
        "$pkgname.tmpfile"
        "upgrade.sh")
backup=('etc/netbox/configuration.py')

package() {
	install -d -m775 "$pkgdir/etc/${_name}"
	install -d "$pkgdir/opt/"${_name}
	cp -r ${_name}-${_realver}/${_name}/. "$pkgdir/opt/${_name}"
	#install -dm775 "$pkgdir/etc/$pkgname"
	install -d "$pkgdir/var/lib/"$pkgname
	cp -r $pkgname-$pkgver/$pkgname/. "$pkgdir/var/lib/$pkgname"

	install -D -m644 ${_name}-system.service "$pkgdir/usr/lib/systemd/system/${_name}.service"
	install -D -m644 ${_name}.tmpfile "$pkgdir/usr/lib/tmpfiles.d/${_name}.conf"
	install -Dm644 $pkgname.service "$pkgdir/usr/lib/systemd/system/$pkgname.service"
	install -Dm644 $pkgname-rq.service "$pkgdir/usr/lib/systemd/system/$pkgname-rq.service"
	install -Dm644 $pkgname.tmpfile "$pkgdir/usr/lib/tmpfiles.d/$pkgname.conf"
	install -Dm644 $pkgname.sysusers "$pkgdir/usr/lib/sysusers.d/$pkgname.conf"

	install -d "$pkgdir/etc/${_name}"
	install -D -m644 gunicorn_config.py "$pkgdir/etc/netbox/gunicorn_config.py"
	install -D -m644 ${_name}-${_realver}/${_name}/${_name}/configuration.example.py "$pkgdir/etc/netbox/configuration.py"
	ln -s /etc/netbox/configuration.py "$pkgdir/opt/netbox/netbox/configuration.py"
	install -d "$pkgdir/etc/$pkgname"
	install -D -m644 $pkgname-$pkgver/$pkgname/$pkgname/configuration.example.py "$pkgdir/etc/netbox/configuration.py"
	install -D -m755 upgrade.sh "$pkgdir/etc/netbox/upgrade.sh"
	ln -s "/etc/netbox/configuration.py" "$pkgdir/var/lib/netbox/netbox/configuration.py"
}

# vim: set ts=2 sw=2 ft=sh noet:
md5sums=('ef794d344ab5a3b2d9c854867580d0cf'
         '55dcba60ed4cb66b350d3d8f2946aef9'
         'ad07c0c741a231b8d8012221bee2c167'
         'b653f7da646e78ad5c69d3960bbafd9c'
         '17532f81746d5378abbf9721c526247b'
         '97c618de19719135aa84458789b025b1')

D netbox/gunicorn_config.py => netbox/gunicorn_config.py +0 -5
@@ 1,5 0,0 @@
command = '/usr/bin/gunicorn'
pythonpath = '/opt/netbox/netbox'
bind = '127.0.0.1:8001'
workers = 3
user = 'netbox'

A netbox/netbox-rq.service => netbox/netbox-rq.service +14 -0
@@ 0,0 1,14 @@
[Unit]
Description=netbox request queue worker
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=netbox
WorkingDirectory=/var/lib/netbox
ExecStart=/usr/bin/python /var/lib/netbox/manage.py rqworker
#PrivateTmp=true

[Install]
WantedBy=multi-user.target

M netbox/netbox.install => netbox/netbox.install +5 -35
@@ 1,40 1,10 @@
_NAME=netbox

_create_user() {
	getent passwd ${_NAME} > /dev/null || useradd -d /opt/${_NAME} -s /bin/false -r ${_NAME} > /dev/null
}

post_install() {
    _create_user

	# Create a directory in /run if it does not exist
	if [ ! -d /run/${_NAME} ]; then
		mkdir /run/${_NAME}
		chown ${_NAME}. /run/${_NAME}
		chmod 775 /run/${_NAME}
	fi

    echo ""
    echo -e "Follow the instructions on http://netbox.readthedocs.io/en/latest/installation/netbox/"
    echo -e "to finish the configuration, and enable and start the systemd "
    echo -e "service: "
    echo "    systemctl enable --now netbox.service"
    echo ""
    echo -e "Tweak the netbox and gunicorn configuration in "
    echo "/etc/netbox/configuration.py and /etc/netbox/gunicorn_config.py"
    echo ""
    chown -R netbox:netbox /var/lib/netbox
    echo "Configure netbox in /etc/netbox/configuration.py"
    echo "After configuring run /etc/netbox/upgrade.sh as root"
}

post_upgrade() {
    _create_user

    echo ""
    echo "To end the migration, use the following commands:"
    echo "    /opt/netbox/manage.py migrate"
    echo "    /opt/netbox/manage.py collectstatic --noinput"
    echo ""
}

post_remove() {
	userdel -f ${_NAME}
    chown -R netbox:netbox /var/lib/netbox
    sh /etc/netbox/upgrade.sh
}

R netbox/netbox-system.service => netbox/netbox.service +2 -2
@@ 5,8 5,8 @@ After=network.target
[Service]
User=netbox
Type=simple
PIDFile=/run/netbox/netbox.pid
ExecStart=/usr/bin/gunicorn -c /etc/netbox/gunicorn_config.py --pythonpath /opt/netbox -p /run/netbox/netbox.pid netbox.wsgi
WorkingDirectory=/var/lib/netbox
ExecStart=/usr/bin/gunicorn -w 2 -b unix:/run/netbox/netbox.sock --pythonpath /var/lib/netbox netbox.wsgi

[Install]
WantedBy=multi-user.target

A netbox/netbox.sysusers => netbox/netbox.sysusers +1 -0
@@ 0,0 1,1 @@
u netbox - "netbox service user" /var/lib/netbox

M netbox/netbox.tmpfile => netbox/netbox.tmpfile +2 -1
@@ 1,1 1,2 @@
d /run/netbox 0775 netbox netbox
d /var/lib/netbox 0700 netbox netbox -
d /run/netbox 0775 netbox netbox -

A netbox/upgrade.sh => netbox/upgrade.sh +8 -0
@@ 0,0 1,8 @@
#/bin/sh

python /var/lib/netbox/manage.py migrate
python /var/lib/netbox/manage.py trace_paths --no-input
python /var/lib/netbox/manage.py collectstatic --noinput
python /var/lib/netbox/manage.py remove_stale_contenttypes --no-input
python /var/lib/netbox/manage.py clearsessions
python /var/lib/netbox/manage.py invalidate all