upgrade.sh 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. # This script will prepare NetBox to run after the code has been upgraded to
  3. # its most recent release.
  4. #
  5. # Once the script completes, remember to restart the WSGI service (e.g.
  6. # gunicorn or uWSGI).
  7. PYTHON="python3"
  8. PIP="pip3"
  9. # TODO: Remove this in v2.6 as it is no longer needed under Python 3
  10. # Delete stale bytecode
  11. COMMAND="find . -name \"*.pyc\" -delete"
  12. echo "Cleaning up stale Python bytecode ($COMMAND)..."
  13. eval $COMMAND
  14. # Uninstall any Python packages which are no longer needed
  15. COMMAND="${PIP} uninstall -r old_requirements.txt -y"
  16. echo "Removing old Python packages ($COMMAND)..."
  17. eval $COMMAND
  18. # Install any new Python packages
  19. COMMAND="${PIP} install -r requirements.txt --upgrade"
  20. echo "Updating required Python packages ($COMMAND)..."
  21. eval $COMMAND
  22. # Apply any database migrations
  23. COMMAND="${PYTHON} netbox/manage.py migrate"
  24. echo "Applying database migrations ($COMMAND)..."
  25. eval $COMMAND
  26. # Collect static files
  27. COMMAND="${PYTHON} netbox/manage.py collectstatic --no-input"
  28. echo "Collecting static files ($COMMAND)..."
  29. eval $COMMAND