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).
|
|
|
|
|
2019-05-02 13:02:53 -05:00
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
2017-06-09 12:13:47 -04:00
|
|
|
PYTHON="python3"
|
|
|
|
PIP="pip3"
|
|
|
|
|
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
|
|
|
|
2019-10-23 17:12:32 -04:00
|
|
|
# Validate Python dependencies
|
|
|
|
COMMAND="${PIP} check"
|
|
|
|
echo "Validating Python dependencies ($COMMAND)..."
|
|
|
|
eval $COMMAND || (
|
|
|
|
echo "******** PLEASE FIX THE DEPENDENCIES BEFORE CONTINUING ********"
|
|
|
|
echo "* Manually install newer version(s) of the highlighted packages"
|
|
|
|
echo "* so that 'pip3 check' passes. For more information see:"
|
|
|
|
echo "* https://github.com/pypa/pip/issues/988"
|
|
|
|
exit 1
|
|
|
|
)
|
|
|
|
|
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
|
|
|
|
2019-09-25 10:22:02 -04:00
|
|
|
# Delete any stale content types
|
|
|
|
COMMAND="${PYTHON} netbox/manage.py remove_stale_contenttypes --no-input"
|
|
|
|
echo "Removing stale content types ($COMMAND)..."
|
|
|
|
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
|