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