Skip to content

Commit

Permalink
Merge pull request #61 from linuxserver/init-restructure
Browse files Browse the repository at this point in the history
restructure init to allow for plugins as mods
  • Loading branch information
aptalca authored Aug 27, 2024
2 parents 99c8208 + b45c949 commit 3f0a283
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 27 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64

## Versions

* **26.08.24:** - Restructure init to allow for plugins as mods.
* **16.07.24:** - Add required packages for LDAP support.
* **01.06.24:** - Rebase to Alpine 3.20.
* **23.12.23:** - Rebase to Alpine 3.19.
Expand Down
1 change: 1 addition & 0 deletions readme-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ app_setup_block: |
# changelog
changelogs:
- { date: "26.08.24:", desc: "Restructure init to allow for plugins as mods."}
- { date: "16.07.24:", desc: "Add required packages for LDAP support."}
- { date: "01.06.24:", desc: "Rebase to Alpine 3.20."}
- { date: "23.12.23:", desc: "Rebase to Alpine 3.19."}
Expand Down
27 changes: 0 additions & 27 deletions root/etc/s6-overlay/s6-rc.d/init-netbox-config/run
Original file line number Diff line number Diff line change
Expand Up @@ -52,33 +52,6 @@ ln -sf /config/ldap_config.py /app/netbox/netbox/netbox/ldap_config.py

mv /defaults/uwsgi.ini /app/netbox/netbox/uwsgi.ini > /dev/null 2>&1

# build docs
if [[ ! -e "/app/netbox/netbox/project-static/docs/index.html" ]]; then
cd /app/netbox || exit 1
echo "Building local documentation"
mkdocs build -q
cd /app/netbox/netbox || exit 1
fi

# permissions
lsiown -R abc:abc \
/app/netbox/netbox/static \
/config

s6-setuidgid abc python3 ./manage.py migrate

if [[ -n "$SUPERUSER_EMAIL" ]] && [[ -n "$SUPERUSER_PASSWORD" ]]; then
cat << EOF | s6-setuidgid abc python3 /app/netbox/netbox/manage.py shell
from users.models import Token, User;

username = 'admin';
password = '$SUPERUSER_PASSWORD';
email = '$SUPERUSER_EMAIL';

if not User.objects.filter(username='admin'):
User.objects.create_superuser(username, email, password);
print('Superuser created.');
else:
print('Superuser creation skipped. Already exists.');
EOF
fi
34 changes: 34 additions & 0 deletions root/etc/s6-overlay/s6-rc.d/svc-netbox-prepare/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash

cd /app/netbox/netbox || exit 1

s6-setuidgid abc python3 ./manage.py migrate

if [[ -n "$SUPERUSER_EMAIL" ]] && [[ -n "$SUPERUSER_PASSWORD" ]]; then
cat << EOF | s6-setuidgid abc python3 /app/netbox/netbox/manage.py shell
from users.models import Token, User;

username = 'admin';
password = '$SUPERUSER_PASSWORD';
email = '$SUPERUSER_EMAIL';

if not User.objects.filter(username='admin'):
User.objects.create_superuser(username, email, password);
print('Superuser created.');
else:
print('Superuser creation skipped. Already exists.');
EOF
fi

# build docs
if [[ ! -e "/app/netbox/netbox/project-static/docs/index.html" ]]; then
cd /app/netbox || exit 1
echo "Building local documentation"
mkdocs build -q
cd /app/netbox/netbox || exit 1
fi

# permissions
lsiown -R abc:abc \
/app/netbox/netbox/static
1 change: 1 addition & 0 deletions root/etc/s6-overlay/s6-rc.d/svc-netbox-prepare/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
1 change: 1 addition & 0 deletions root/etc/s6-overlay/s6-rc.d/svc-netbox-prepare/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/svc-netbox-prepare/run
Empty file.
Empty file.

0 comments on commit 3f0a283

Please sign in to comment.