upgrade.sh 942 B

12345678910111213141516171819202122232425262728293031
  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. # Optionally use sudo if not already root, and always prompt for password
  8. # before running the command
  9. PREFIX="sudo -k "
  10. if [ "$(whoami)" = "root" ]; then
  11. # When running upgrade as root, ask user to confirm if they wish to
  12. # continue
  13. read -n1 -rsp $'Running NetBox upgrade as root, press any key to continue or ^C to cancel\n'
  14. PREFIX=""
  15. fi
  16. # Fall back to pip3 if pip is missing
  17. PIP="pip"
  18. type $PIP >/dev/null 2>&1 || PIP="pip3"
  19. # Install any new Python packages
  20. COMMAND="${PREFIX}${PIP} install -r requirements.txt --upgrade"
  21. echo "Updating required Python packages ($COMMAND)..."
  22. eval $COMMAND
  23. # Apply any database migrations
  24. ./netbox/manage.py migrate
  25. # Collect static files
  26. ./netbox/manage.py collectstatic --no-input