diff --git a/README.md b/README.md index d4a3bfe..8889084 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/readme-vars.yml b/readme-vars.yml index 90e1764..e610ede 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -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."} diff --git a/root/etc/s6-overlay/s6-rc.d/init-netbox-config/run b/root/etc/s6-overlay/s6-rc.d/init-netbox-config/run index 152530a..c4c098c 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-netbox-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-netbox-config/run @@ -64,21 +64,3 @@ fi 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 diff --git a/root/etc/s6-overlay/s6-rc.d/svc-netbox/dependencies.d/init-services b/root/etc/s6-overlay/s6-rc.d/svc-netbox-prepare/dependencies.d/init-services similarity index 100% rename from root/etc/s6-overlay/s6-rc.d/svc-netbox/dependencies.d/init-services rename to root/etc/s6-overlay/s6-rc.d/svc-netbox-prepare/dependencies.d/init-services diff --git a/root/etc/s6-overlay/s6-rc.d/svc-netbox-prepare/run b/root/etc/s6-overlay/s6-rc.d/svc-netbox-prepare/run new file mode 100755 index 0000000..57d43d3 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-netbox-prepare/run @@ -0,0 +1,22 @@ +#!/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 diff --git a/root/etc/s6-overlay/s6-rc.d/svc-netbox-prepare/type b/root/etc/s6-overlay/s6-rc.d/svc-netbox-prepare/type new file mode 100644 index 0000000..bdd22a1 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-netbox-prepare/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/svc-netbox-prepare/up b/root/etc/s6-overlay/s6-rc.d/svc-netbox-prepare/up new file mode 100644 index 0000000..c716644 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-netbox-prepare/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/svc-netbox-prepare/run diff --git a/root/etc/s6-overlay/s6-rc.d/svc-netbox/dependencies.d/svc-netbox-prepare b/root/etc/s6-overlay/s6-rc.d/svc-netbox/dependencies.d/svc-netbox-prepare new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-netbox-prepare b/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-netbox-prepare new file mode 100644 index 0000000..e69de29