~roshless/PKGBUILDs

65a542dcaad40533c4f89d953d77cc6bd9aa323e — Roshless 27 days ago 1695c5a + e0ee3c3
Add 'netbox/' from commit 'e0ee3c3ac9c565c949af37704fbac2a635eb4f45'

git-subtree-dir: netbox
git-subtree-mainline: 1695c5a1a2f8974c76031ea2d67189d4cb8f86bc
git-subtree-split: e0ee3c3ac9c565c949af37704fbac2a635eb4f45
A netbox/.SRCINFO => netbox/.SRCINFO +53 -0
@@ 0,0 1,53 @@
pkgbase = netbox
	pkgdesc = IP address management (IPAM) and data center infrastructure management (DCIM) tool.
	pkgver = 2.3.1
	pkgrel = 2
	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-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-tables2
	depends = python-graphviz
	depends = python-lxml
	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
	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 = netbox.tmpfile
	source = gunicorn_config.py
	sha256sums = 284c830fcacf99febd1f650fb323cc9ce1c4c31044e4ee70eb791c53f3f10ddb
	sha256sums = dc83de37ff9151de3d309fd43c6eff3b30886882012b81fd3ff2f3a5a706bea6
	sha256sums = 1028bac96ddcd18c10646dff26027b4891fcab4381436e2b6ea3302887a5586f
	sha256sums = 7a5ae05cad7ec14193a43ef080776b5525c80b6258762a6cb6a108db83861ff9

pkgname = netbox


A netbox/PKGBUILD => netbox/PKGBUILD +70 -0
@@ 0,0 1,70 @@
# Maintainer: Anthony Ruhier <anthony.ruhier@gmail.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."
arch=('any')
url="https://github.com/digitalocean/${_name}"
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')

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')

package() {
	install -d -m775 "$pkgdir/etc/${_name}"
	install -d "$pkgdir/opt/"${_name}
	cp -r ${_name}-${_realver}/${_name}/. "$pkgdir/opt/${_name}"

	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 -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"
}

# vim: set ts=2 sw=2 ft=sh noet:

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

A netbox/netbox-system.service => netbox/netbox-system.service +12 -0
@@ 0,0 1,12 @@
[Unit]
Description=Netbox Daemon
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

[Install]
WantedBy=multi-user.target

A netbox/netbox.install => netbox/netbox.install +40 -0
@@ 0,0 1,40 @@
_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 ""
}

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}
}

A netbox/netbox.tmpfile => netbox/netbox.tmpfile +1 -0
@@ 0,0 1,1 @@
d /run/netbox 0775 netbox netbox