upgrade.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. cd "$(dirname "$0")"
  8. PYTHON="python3"
  9. PIP="pip3"
  10. # TODO: Remove this in v2.6 as it is no longer needed under Python 3
  11. # Delete stale bytecode
  12. COMMAND="find . -name \"*.pyc\" -delete"
  13. echo "Cleaning up stale Python bytecode ($COMMAND)..."
  14. eval $COMMAND
  15. # Uninstall any Python packages which are no longer needed
  16. COMMAND="${PIP} uninstall -r old_requirements.txt -y"
  17. echo "Removing old Python packages ($COMMAND)..."
  18. eval $COMMAND
  19. # Install any new Python packages
  20. COMMAND="${PIP} install -r requirements.txt --upgrade"
  21. echo "Updating required Python packages ($COMMAND)..."
  22. eval $COMMAND
  23. # Apply any database migrations
  24. COMMAND="${PYTHON} netbox/manage.py migrate"
  25. echo "Applying database migrations ($COMMAND)..."
  26. eval $COMMAND
  27. # Collect static files
  28. COMMAND="${PYTHON} netbox/manage.py collectstatic --no-input"
  29. echo "Collecting static files ($COMMAND)..."
  30. eval $COMMAND