Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions SPECS/netbox.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
%define __python /opt/rh/rh-python38/root/usr/bin/python
%define __python3 python3.12
%define __python3_binary /usr/bin/%{__python3}
%define __psql_version 16
%define __psql_binary /usr/pgsql-%{__psql_version}/bin/psql

Name: netbox
Version: 3.5.4
Version: 4.1.11
Release: 1
Summary: The premier source of truth powering network automation.

Expand All @@ -11,7 +15,7 @@ Source: https://github.com/%{name}-community/%{name}/archive/refs/tags/v%{versio
Source2: netbox.logrotate
Source3: netbox.logfile

Requires: gcc libxml2-devel libxslt-devel libffi-devel libpq5-devel openssl-devel redhat-rpm-config rh-redis6-redis rh-python38 rh-python38-python-pip rh-python38-python-devel
Requires: gcc libxml2-devel libxslt-devel libffi-devel libpq5-devel openssl-devel postgresql%{__psql_version}-server redhat-rpm-config redis pwgen %{__python3} %{__python3}-pip %{__python3}-devel

%description
NetBox is the source of truth for everything on your network, from physical
Expand Down Expand Up @@ -106,21 +110,20 @@ cp %{name}-%{version}/contrib/*.timer %{buildroot}%{_unitdir}

%post
if [ $1 -eq 1 ]; then
systemctl enable --now rh-redis6-redis
systemctl enable --now redis
chown -R nobody /opt/netbox/netbox/{media,reports,scripts}

export pgsql_pw=$(pwgen 16 1)
export pgsql_pw=$(pwgen 32 1)
export secret=$(pwgen 64 1)

sudo -Hiu postgres /usr/pgsql-13/bin/psql -c 'CREATE DATABASE netbox;' -c "CREATE USER netbox WITH PASSWORD '$pgsql_pw'; ALTER DATABASE netbox OWNER TO netbox;"
sudo -Hiu postgres /usr/pgsql-13/bin/psql netbox -c "GRANT CREATE ON SCHEMA public TO netbox;"
sudo -Hiu postgres %{__psql_binary} -c 'CREATE DATABASE netbox;' -c "CREATE USER netbox WITH PASSWORD '$pgsql_pw'; ALTER DATABASE netbox OWNER TO netbox;"
sudo -Hiu postgres %{__psql_binary} netbox -c "GRANT CREATE ON SCHEMA public TO netbox;"

sed -e "s/'PASSWORD': '', # PostgreSQL password/'PASSWORD': '$pgsql_pw', # PostgreSQL password/" \
-e "s/^SECRET_KEY = ''$/SECRET_KEY = '$secret'/" \
-i /opt/netbox/netbox/netbox/configuration.py

source /opt/rh/rh-python38/enable
/opt/netbox/upgrade.sh
PYTHON=%{__python3_binary} /opt/netbox/upgrade.sh

chmod -R o-rwx /var/log/netbox
chown -R nobody:nobody /var/log/netbox
Expand All @@ -131,5 +134,11 @@ if [ $1 -eq 1 ]; then
fi

%changelog
* Wed Mar 12 2025 Patrick Reichel <[email protected]> - 4.1.11-1
- Switch to version 4.1.11

* Wed Oct 23 2024 Patrick Reichel <[email protected]> - 4.1.5-1
- Switch to version 4.1.5

* Wed Sep 20 2023 Ole Ernst <[email protected]> - 3.5.4-1
- Initial RPM release