1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Upgrade script now looks for Python path as env var

This commit is contained in:
jeremystretch
2021-07-19 15:13:30 -04:00
parent 7058d6ca5a
commit 47ef8b9cac
3 changed files with 19 additions and 1 deletions

View File

@ -223,6 +223,12 @@ Once NetBox has been configured, we're ready to proceed with the actual installa
sudo /opt/netbox/upgrade.sh
```
Note that Python 3.7 or later is required for NetBox v3.0 and later releases. If the default Python installation on your server does not meet this requirement, you'll need to install Python 3.7 or later separately, and pass the path to the support installation as an environment variable named `PYTHON`. (Note that the environment variable must be passed _after_ the `sudo` command.)
```no-highlight
sudo PYTHON=/usr/bin/python3.7 /opt/netbox/upgrade.sh
```
!!! note
Upon completion, the upgrade script may warn that no existing virtual environment was detected. As this is a new installation, this warning can be safely ignored.

View File

@ -75,6 +75,13 @@ Once the new code is in place, verify that any optional Python packages required
sudo ./upgrade.sh
```
!!! warning
If the default version of Python is not at least 3.7, you'll need to pass the path to a supported Python version as an environment variable when calling the upgrade script. For example:
```no-highlight
sudo PYTHON=/usr/bin/python3.7 ./upgrade.sh
```
This script performs the following actions:
* Destroys and rebuilds the Python virtual environment

View File

@ -2,8 +2,13 @@
# This script will prepare NetBox to run after the code has been upgraded to
# its most recent release.
# This script will invoke Python with the value of the PYTHON environment
# variable (if set), or fall back to "python3". Note that NetBox v3.0+ requires
# Python 3.7 or later.
cd "$(dirname "$0")"
VIRTUALENV="$(pwd -P)/venv"
PYTHON="${PYTHON:-python3}"
# Remove the existing virtual environment (if any)
if [ -d "$VIRTUALENV" ]; then
@ -15,7 +20,7 @@ else
fi
# Create a new virtual environment
COMMAND="python3 -m venv ${VIRTUALENV}"
COMMAND="${PYTHON} -m venv ${VIRTUALENV}"
echo "Creating a new virtual environment at ${VIRTUALENV}..."
eval $COMMAND || {
echo "--------------------------------------------------------------------"