upgrade.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. # Uninstall any Python packages which are no longer needed
  11. COMMAND="${PIP} uninstall -r old_requirements.txt -y"
  12. echo "Removing old Python packages ($COMMAND)..."
  13. eval $COMMAND
  14. # Install any new Python packages
  15. COMMAND="${PIP} install -r requirements.txt --upgrade"
  16. echo "Updating required Python packages ($COMMAND)..."
  17. eval $COMMAND
  18. # Validate Python dependencies
  19. COMMAND="${PIP} check"
  20. echo "Validating Python dependencies ($COMMAND)..."
  21. eval $COMMAND || (
  22. echo "******** PLEASE FIX THE DEPENDENCIES BEFORE CONTINUING ********"
  23. echo "* Manually install newer version(s) of the highlighted packages"
  24. echo "* so that 'pip3 check' passes. For more information see:"
  25. echo "* https://github.com/pypa/pip/issues/988"
  26. exit 1
  27. )
  28. # Apply any database migrations
  29. COMMAND="${PYTHON} netbox/manage.py migrate"
  30. echo "Applying database migrations ($COMMAND)..."
  31. eval $COMMAND
  32. # Delete any stale content types
  33. COMMAND="${PYTHON} netbox/manage.py remove_stale_contenttypes --no-input"
  34. echo "Removing stale content types ($COMMAND)..."
  35. eval $COMMAND
  36. # Collect static files
  37. COMMAND="${PYTHON} netbox/manage.py collectstatic --no-input"
  38. echo "Collecting static files ($COMMAND)..."
  39. eval $COMMAND
  40. # Clear all cached data
  41. COMMAND="${PYTHON} netbox/manage.py invalidate all"
  42. echo "Clearing cache data ($COMMAND)..."
  43. eval $COMMAND