mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-27 02:48:38 -06:00
implement skipping startup scripts, but not required ones
This commit is contained in:
parent
c3bce3c7a1
commit
4d2c0bbcba
@ -53,10 +53,11 @@ fi
|
||||
# Run the startup scripts (and initializers)
|
||||
if [ "$SKIP_STARTUP_SCRIPTS" == "true" ]; then
|
||||
echo "↩️ Skipping startup scripts"
|
||||
else
|
||||
echo "import runpy; runpy.run_path('../startup_scripts')" | ./manage.py shell --interface python
|
||||
fi
|
||||
|
||||
echo "import runpy; runpy.run_path('../startup_scripts')" | ./manage.py shell --interface python
|
||||
|
||||
|
||||
# copy static files
|
||||
./manage.py collectstatic --no-input
|
||||
|
||||
|
@ -1,15 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import runpy
|
||||
from os import scandir
|
||||
import os
|
||||
|
||||
from distutils.util import strtobool
|
||||
from os.path import dirname, abspath
|
||||
|
||||
this_dir = dirname(abspath(__file__))
|
||||
skip_startup_scripts = bool(strtobool(os.environ.get('SKIP_STARTUP_SCRIPTS', "false")))
|
||||
|
||||
def filename(f):
|
||||
return f.name
|
||||
|
||||
with scandir(this_dir) as it:
|
||||
with os.scandir(this_dir) as it:
|
||||
for f in sorted(it, key = filename):
|
||||
if not f.is_file():
|
||||
continue
|
||||
@ -20,6 +23,9 @@ with scandir(this_dir) as it:
|
||||
if not f.name.endswith('.py'):
|
||||
continue
|
||||
|
||||
if skip_startup_scripts and "required" not in f.name:
|
||||
continue
|
||||
|
||||
print(f"▶️ Running the startup script {f.path}")
|
||||
try:
|
||||
runpy.run_path(f.path)
|
||||
|
Loading…
Reference in New Issue
Block a user