forked from jfqd/mi-qutic-netbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
customize
executable file
·55 lines (39 loc) · 1.52 KB
/
customize
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/bash
NETBOX_VERSION="v4.0.5"
PATH=/opt/local/gnu/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/sbin
# Exit if any command fails
set -o errexit
echo "* Use default python 3.11"
pkg_alternatives manual python311
pkg_alternatives manual py311-pip
echo "* Remove used pgsql stuff from base"
rm -rf /var/pgsql/*
echo "* Configuring image specific packages."
mkdir -p /{opt,var}/netbox
# TODO: create a pkgsrc pkg with all dependencies
echo "* Install build dependencies"
pkgin -y install build-essential rust
echo "* Download and extract netbox to /opt/netbox"
curl -L "https://github.com/netbox-community/netbox/archive/refs/tags/${NETBOX_VERSION}.tar.gz" | gtar xz -C /opt/netbox --strip-components=1
echo "* Add netbox user"
groupadd netbox
useradd -d /opt/netbox -c "netbox user" -s /usr/bin/false -g netbox netbox
echo "* Install netbox requirements"
python3 -m venv /opt/netbox/venv --system-site-packages
echo "* Copy configuration template"
cp /tmp/configuration.py /opt/netbox/netbox/netbox/
cp /opt/netbox/contrib/gunicorn.py /opt/netbox/netbox/
echo "* Setup permissions for netbox folder"
chown -R netbox:netbox /{opt,var}/netbox
gsed -i '/nh3.*/d' /opt/netbox/requirements.txt
sudo -u netbox \
TMPDIR=/var/tmp \
/opt/netbox/venv/bin/pip3 install -r /opt/netbox/requirements.txt
echo "* Remove build dependencies"
pkgin -y remove build-essential rust
pkgin -y autoremove
echo "* Cleanup home/admin because of delegate dataset usage"
rm -rf /home/admin/.[^.]*
echo "* Cleaning up"
rm -rf /root/*
sm-prepare-image -y