Browse Source

Upgrade script now looks for Python path as env var

jeremystretch 4 years ago
parent
commit
47ef8b9cac
3 changed files with 19 additions and 1 deletions
  1. 6 0
      docs/installation/3-netbox.md
  2. 7 0
      docs/installation/upgrading.md
  3. 6 1
      upgrade.sh

+ 6 - 0
docs/installation/3-netbox.md

@@ -223,6 +223,12 @@ Once NetBox has been configured, we're ready to proceed with the actual installa
 sudo /opt/netbox/upgrade.sh
 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
 !!! 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.
     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.
 
 

+ 7 - 0
docs/installation/upgrading.md

@@ -75,6 +75,13 @@ Once the new code is in place, verify that any optional Python packages required
 sudo ./upgrade.sh
 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:
 This script performs the following actions:
 
 
 * Destroys and rebuilds the Python virtual environment
 * Destroys and rebuilds the Python virtual environment

+ 6 - 1
upgrade.sh

@@ -2,8 +2,13 @@
 # This script will prepare NetBox to run after the code has been upgraded to
 # This script will prepare NetBox to run after the code has been upgraded to
 # its most recent release.
 # 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")"
 cd "$(dirname "$0")"
 VIRTUALENV="$(pwd -P)/venv"
 VIRTUALENV="$(pwd -P)/venv"
+PYTHON="${PYTHON:-python3}"
 
 
 # Remove the existing virtual environment (if any)
 # Remove the existing virtual environment (if any)
 if [ -d "$VIRTUALENV" ]; then
 if [ -d "$VIRTUALENV" ]; then
@@ -15,7 +20,7 @@ else
 fi
 fi
 
 
 # Create a new virtual environment
 # Create a new virtual environment
-COMMAND="python3 -m venv ${VIRTUALENV}"
+COMMAND="${PYTHON} -m venv ${VIRTUALENV}"
 echo "Creating a new virtual environment at ${VIRTUALENV}..."
 echo "Creating a new virtual environment at ${VIRTUALENV}..."
 eval $COMMAND || {
 eval $COMMAND || {
   echo "--------------------------------------------------------------------"
   echo "--------------------------------------------------------------------"