From 18959e90d39307c7144884255c51ed6a82ae6b30 Mon Sep 17 00:00:00 2001 From: Tobias Genannt Date: Thu, 1 Sep 2022 12:57:21 +0200 Subject: [PATCH] Destroyed Startup Scripts (markdown) --- Startup-Scripts.md | 47 ---------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 Startup-Scripts.md diff --git a/Startup-Scripts.md b/Startup-Scripts.md deleted file mode 100644 index 4c1c7cb..0000000 --- a/Startup-Scripts.md +++ /dev/null @@ -1,47 +0,0 @@ -When using `docker-compose`, all the python scripts present in `/opt/netbox/startup_scripts` will automatically be executed in the context of `./manage.py` after the application boots. - -That mechanism can be used for many things, e.g. to create Netbox custom fields: - -```python -# docker/startup_scripts/load_custom_fields.py -from django.contrib.contenttypes.models import ContentType -from extras.models import CF_TYPE_TEXT, CustomField - -from dcim.models import Device -from dcim.models import DeviceType - -device = ContentType.objects.get_for_model(Device) -device_type = ContentType.objects.get_for_model(DeviceType) - -my_custom_field, created = CustomField.objects.get_or_create( - type=CF_TYPE_TEXT, - name='my_custom_field', - description='My own custom field' -) - -if created: - my_custom_field.obj_type.add(device) - my_custom_field.obj_type.add(device_type) -``` - -## Initializer Scripts - -There's a bunch of scripts that come pre-built with the Netbox Docker image. -The [wiki page "Initializers"](Initializers) explains how to use them. - -## Disable Startup Scripts - -The execution of the startup scripts can be prevented by setting the environment variable `SKIP_STARTUP_SCRIPTS` to `true`, e.g. in the file `env/netbox.env`. - -## Custom Docker Image - -You can also build your own Netbox Docker image containing your own startup scripts, custom fields, users and groups -like this: - -```Dockerfile -ARG VERSION=latest -FROM netboxcommunity/netbox:$VERSION - -COPY startup_scripts/ /opt/netbox/startup_scripts/ -COPY initializers/ /opt/netbox/initializers/ -``` \ No newline at end of file