upgrade.sh 849 B

123456789101112131415161718192021222324252627
  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. # Install any new Python packages
  17. COMMAND="${PREFIX}pip install -r requirements.txt --upgrade"
  18. echo "Updating required Python packages ($COMMAND)..."
  19. eval $COMMAND
  20. # Apply any database migrations
  21. ./netbox/manage.py migrate
  22. # Collect static files
  23. ./netbox/manage.py collectstatic --noinput