2016-07-01 13:21:51 -04:00
|
|
|
#!/bin/bash
|
2016-06-29 15:43:42 -04:00
|
|
|
# This script will prepare NetBox to run after the code has been upgraded to
|
|
|
|
# its most recent release.
|
|
|
|
#
|
|
|
|
# Once the script completes, remember to restart the WSGI service (e.g.
|
|
|
|
# gunicorn or uWSGI).
|
|
|
|
|
2017-06-09 12:13:47 -04:00
|
|
|
PYTHON="python3"
|
|
|
|
PIP="pip3"
|
|
|
|
|
2018-11-30 11:12:10 -05:00
|
|
|
# TODO: Remove this in v2.6 as it is no longer needed under Python 3
|
2017-04-27 14:42:52 -04:00
|
|
|
# Delete stale bytecode
|
2018-11-30 11:12:10 -05:00
|
|
|
COMMAND="find . -name \"*.pyc\" -delete"
|
2017-04-27 14:42:52 -04:00
|
|
|
echo "Cleaning up stale Python bytecode ($COMMAND)..."
|
2017-05-01 16:53:51 -04:00
|
|
|
eval $COMMAND
|
2017-04-27 14:42:52 -04:00
|
|
|
|
2017-10-09 17:40:15 -04:00
|
|
|
# Uninstall any Python packages which are no longer needed
|
2018-11-30 11:12:10 -05:00
|
|
|
COMMAND="${PIP} uninstall -r old_requirements.txt -y"
|
2017-10-09 17:40:15 -04:00
|
|
|
echo "Removing old Python packages ($COMMAND)..."
|
|
|
|
eval $COMMAND
|
|
|
|
|
2016-06-29 15:43:42 -04:00
|
|
|
# Install any new Python packages
|
2018-11-30 11:12:10 -05:00
|
|
|
COMMAND="${PIP} install -r requirements.txt --upgrade"
|
2016-07-01 13:21:51 -04:00
|
|
|
echo "Updating required Python packages ($COMMAND)..."
|
|
|
|
eval $COMMAND
|
2016-06-29 15:43:42 -04:00
|
|
|
|
|
|
|
# Apply any database migrations
|
2017-05-26 09:55:22 -04:00
|
|
|
COMMAND="${PYTHON} netbox/manage.py migrate"
|
2017-05-18 14:53:35 -04:00
|
|
|
echo "Applying database migrations ($COMMAND)..."
|
2017-04-27 14:42:52 -04:00
|
|
|
eval $COMMAND
|
2016-06-29 15:43:42 -04:00
|
|
|
|
|
|
|
# Collect static files
|
2017-05-26 09:55:22 -04:00
|
|
|
COMMAND="${PYTHON} netbox/manage.py collectstatic --no-input"
|
2017-04-27 14:42:52 -04:00
|
|
|
echo "Collecting static files ($COMMAND)..."
|
|
|
|
eval $COMMAND
|